Skip to content

Commit 3ab3185

Browse files
peffgitster
authored andcommitted
pack-objects: support filters with bitmaps
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 84243da commit 3ab3185

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

builtin/pack-objects.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3040,7 +3040,7 @@ static int pack_options_allow_reuse(void)
30403040

30413041
static int get_object_list_from_bitmap(struct rev_info *revs)
30423042
{
3043-
if (!(bitmap_git = prepare_bitmap_walk(revs, NULL)))
3043+
if (!(bitmap_git = prepare_bitmap_walk(revs, &filter_options)))
30443044
return -1;
30453045

30463046
if (pack_options_allow_reuse() &&
@@ -3419,7 +3419,6 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
34193419
if (filter_options.choice) {
34203420
if (!pack_to_stdout)
34213421
die(_("cannot use --filter without --stdout"));
3422-
use_bitmap_index = 0;
34233422
}
34243423

34253424
/*

t/perf/p5310-pack-bitmaps.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ test_perf 'rev-list count with blob:limit=1k' '
5757
--filter=blob:limit=1k >/dev/null
5858
'
5959

60+
test_perf 'simulated partial clone' '
61+
git pack-objects --stdout --all --filter=blob:none </dev/null >/dev/null
62+
'
63+
6064
test_expect_success 'create partial bitmap state' '
6165
# pick a commit to represent the repo tip in the past
6266
cutoff=$(git rev-list HEAD~100 -1) &&

t/t5310-pack-bitmaps.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,20 @@ test_expect_success 'clone from bitmapped repository' '
107107
test_cmp expect actual
108108
'
109109

110+
test_expect_success 'partial clone from bitmapped repository' '
111+
test_config uploadpack.allowfilter true &&
112+
git clone --no-local --bare --filter=blob:none . partial-clone.git &&
113+
(
114+
cd partial-clone.git &&
115+
pack=$(echo objects/pack/*.pack) &&
116+
git verify-pack -v "$pack" >have &&
117+
awk "/blob/ { print \$1 }" <have >blobs &&
118+
# we expect this single blob because of the direct ref
119+
git rev-parse refs/tags/tagged-blob >expect &&
120+
test_cmp expect blobs
121+
)
122+
'
123+
110124
test_expect_success 'setup further non-bitmapped commits' '
111125
test_commit_bulk --id=further 10
112126
'

0 commit comments

Comments
 (0)