aboutsummaryrefslogtreecommitdiff
path: root/refs/packed-backend.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2024-09-12 11:47:23 -0700
committerJunio C Hamano <gitster@pobox.com>2024-09-12 11:47:23 -0700
commit143682ec43d5772ee9327ed84eb0cdc007b1f489 (patch)
treef31ec1d5710d11b704afef67f270152226e8b537 /refs/packed-backend.c
parent3bf057a0cd6a75125a5bd239372f9fc4fea6c338 (diff)
parentc3459ae9ef26ee1b49d4de0af128444967910361 (diff)
downloadgit-143682ec43d5772ee9327ed84eb0cdc007b1f489.tar.xz
Merge branch 'ps/pack-refs-auto-heuristics'
"git pack-refs --auto" for the files backend was too aggressive, which has been a bit tamed. * ps/pack-refs-auto-heuristics: refs/files: use heuristic to decide whether to repack with `--auto` t0601: merge tests for auto-packing of refs wrapper: introduce `log2u()`
Diffstat (limited to 'refs/packed-backend.c')
-rw-r--r--refs/packed-backend.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/refs/packed-backend.c b/refs/packed-backend.c
index 7a0a695ca2..07c57fd541 100644
--- a/refs/packed-backend.c
+++ b/refs/packed-backend.c
@@ -1250,6 +1250,24 @@ int packed_refs_is_locked(struct ref_store *ref_store)
return is_lock_file_locked(&refs->lock);
}
+int packed_refs_size(struct ref_store *ref_store,
+ size_t *out)
+{
+ struct packed_ref_store *refs = packed_downcast(ref_store, REF_STORE_READ,
+ "packed_refs_size");
+ struct stat st;
+
+ if (stat(refs->path, &st) < 0) {
+ if (errno != ENOENT)
+ return -1;
+ *out = 0;
+ return 0;
+ }
+
+ *out = st.st_size;
+ return 0;
+}
+
/*
* The packed-refs header line that we write out. Perhaps other traits
* will be added later.