Hi, this is the second version of my patch series that introduces a new heuristic for packing refs with the "files" backend. This heuristic is designed to avoid needlessly rewriting the "packed-refs" file when there are only a small set of loose refs. The number of loose refs required scales with the size of the "packed-refs" file. There is only one change compared to v1, namely a deduplication of the log2 functions we have in our tree. Thanks! Patrick Patrick Steinhardt (3): wrapper: introduce `log2u()` t0601: merge tests for auto-packing of refs refs/files: use heuristic to decide whether to repack with `--auto` bisect.c | 12 +--- refs/files-backend.c | 65 ++++++++++++++++++++++ refs/packed-backend.c | 18 ++++++ refs/packed-backend.h | 7 +++ t/t0601-reffiles-pack-refs.sh | 101 ++++++++++++++++++++++++++++------ wrapper.h | 18 ++++++ 6 files changed, 194 insertions(+), 27 deletions(-) Range-diff against v1: -: ----------- > 1: df8c5dffffe wrapper: introduce `log2u()` 1: 3a8063e8b2c = 2: 4a59cec205d t0601: merge tests for auto-packing of refs 2: 9a63abfe3b8 ! 3: 49f953142b1 refs/files: use heuristic to decide whether to repack with `--auto` @@ refs/files-backend.c: static int should_pack_ref(struct files_ref_store *refs, return 0; } -+static size_t fastlog2(size_t sz) -+{ -+ size_t l = 0; -+ if (!sz) -+ return 0; -+ for (; sz; sz /= 2) -+ l++; -+ return l - 1; -+} -+ +static int should_pack_refs(struct files_ref_store *refs, + struct pack_refs_opts *opts) +{ @@ refs/files-backend.c: static int should_pack_ref(struct files_ref_store *refs, + * packed refs. This heuristic may be tweaked in the future, but should + * serve as a sufficiently good first iteration. + */ -+ limit = fastlog2(packed_size / 100) * 5; ++ limit = log2u(packed_size / 100) * 5; + if (limit < 16) + limit = 16; + base-commit: 4590f2e9412378c61eac95966709c78766d326ba -- 2.46.0.519.g2e7b89e038.dirty