Skip to content

Commit a3d54f9

Browse files
committed
Merge branch 'jk/pack-shallow-always-without-bitmap'
Reachability bitmaps do not work with shallow operations. Fixes regression in 2.0. * jk/pack-shallow-always-without-bitmap: pack-objects: turn off bitmaps when we see --shallow lines
2 parents 212d781 + f7f9108 commit a3d54f9

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

builtin/pack-objects.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2494,6 +2494,7 @@ static void get_object_list(int ac, const char **av)
24942494
if (get_sha1_hex(line + 10, sha1))
24952495
die("not an SHA-1 '%s'", line + 10);
24962496
register_shallow(sha1);
2497+
use_bitmap_index = 0;
24972498
continue;
24982499
}
24992500
die("not a rev '%s'", line);

t/t5311-pack-bitmaps-shallow.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/sh
2+
3+
test_description='check bitmap operation with shallow repositories'
4+
. ./test-lib.sh
5+
6+
# We want to create a situation where the shallow, grafted
7+
# view of reachability does not match reality in a way that
8+
# might cause us to send insufficient objects.
9+
#
10+
# We do this with a history that repeats a state, like:
11+
#
12+
# A -- B -- C
13+
# file=1 file=2 file=1
14+
#
15+
# and then create a shallow clone to the second commit, B.
16+
# In a non-shallow clone, that would mean we already have
17+
# the tree for A. But in a shallow one, we've grafted away
18+
# A, and fetching A to B requires that the other side send
19+
# us the tree for file=1.
20+
test_expect_success 'setup shallow repo' '
21+
echo 1 >file &&
22+
git add file &&
23+
git commit -m orig &&
24+
echo 2 >file &&
25+
git commit -a -m update &&
26+
git clone --no-local --bare --depth=1 . shallow.git &&
27+
echo 1 >file &&
28+
git commit -a -m repeat
29+
'
30+
31+
test_expect_success 'turn on bitmaps in the parent' '
32+
git repack -adb
33+
'
34+
35+
test_expect_success 'shallow fetch from bitmapped repo' '
36+
(cd shallow.git && git fetch)
37+
'
38+
39+
test_done

0 commit comments

Comments
 (0)