]> git.ipfire.org Git - thirdparty/git.git/commitdiff
pack-objects: support filters with bitmaps
authorJeff King <peff@peff.net>
Fri, 14 Feb 2020 18:22:41 +0000 (13:22 -0500)
committerJunio C Hamano <gitster@pobox.com>
Fri, 14 Feb 2020 18:46:22 +0000 (10:46 -0800)
Just as rev-list recently learned to combine filters and bitmaps, let's
do the same for pack-objects. The infrastructure is all there; we just
need to pass along our filter options, and the pack-bitmap code will
decide to use bitmaps or not.

This unsurprisingly makes things faster for partial clones of large
repositories (here we're cloning linux.git):

  Test                               HEAD^               HEAD
  ------------------------------------------------------------------------------
  5310.11: simulated partial clone   38.94(37.28+5.87)   11.06(11.27+4.07) -71.6%

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/pack-objects.c
t/perf/p5310-pack-bitmaps.sh
t/t5310-pack-bitmaps.sh

index 2bb81c2133166c4fd0874690cf79ab86182c7591..6bc9bc1ce2942c2a3fa621bca95eab6b63030fac 100644 (file)
@@ -3040,7 +3040,7 @@ static int pack_options_allow_reuse(void)
 
 static int get_object_list_from_bitmap(struct rev_info *revs)
 {
-       if (!(bitmap_git = prepare_bitmap_walk(revs, NULL)))
+       if (!(bitmap_git = prepare_bitmap_walk(revs, &filter_options)))
                return -1;
 
        if (pack_options_allow_reuse() &&
@@ -3419,7 +3419,6 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
        if (filter_options.choice) {
                if (!pack_to_stdout)
                        die(_("cannot use --filter without --stdout"));
-               use_bitmap_index = 0;
        }
 
        /*
index 8b43a545c1dbd016265fef10702e4a2688b9bc4a..7743f4f4c9ff728001b4d9d8201654a288c1ef9b 100755 (executable)
@@ -57,6 +57,10 @@ test_perf 'rev-list count with blob:limit=1k' '
                --filter=blob:limit=1k >/dev/null
 '
 
+test_perf 'simulated partial clone' '
+       git pack-objects --stdout --all --filter=blob:none </dev/null >/dev/null
+'
+
 test_expect_success 'create partial bitmap state' '
        # pick a commit to represent the repo tip in the past
        cutoff=$(git rev-list HEAD~100 -1) &&
index 2c64d0c4412a83d22cc0a0468d8456d3c95177ca..8318781d2bbf6c345cda1fab26848771918f8a5a 100755 (executable)
@@ -107,6 +107,20 @@ test_expect_success 'clone from bitmapped repository' '
        test_cmp expect actual
 '
 
+test_expect_success 'partial clone from bitmapped repository' '
+       test_config uploadpack.allowfilter true &&
+       git clone --no-local --bare --filter=blob:none . partial-clone.git &&
+       (
+               cd partial-clone.git &&
+               pack=$(echo objects/pack/*.pack) &&
+               git verify-pack -v "$pack" >have &&
+               awk "/blob/ { print \$1 }" <have >blobs &&
+               # we expect this single blob because of the direct ref
+               git rev-parse refs/tags/tagged-blob >expect &&
+               test_cmp expect blobs
+       )
+'
+
 test_expect_success 'setup further non-bitmapped commits' '
        test_commit_bulk --id=further 10
 '