Skip to content

Commit 9245ddd

Browse files
drafnelgitster
authored andcommitted
t7700: demonstrate mishandling of objects in packs with a .keep file
Objects residing in pack files that have an associated .keep file are not supposed to be repacked into new pack files, but they are. Signed-off-by: Brandon Casey <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9db56f7 commit 9245ddd

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

t/t7700-repack.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/sh
2+
3+
test_description='git repack works correctly'
4+
5+
. ./test-lib.sh
6+
7+
test_expect_failure 'objects in packs marked .keep are not repacked' '
8+
echo content1 > file1 &&
9+
echo content2 > file2 &&
10+
git add . &&
11+
git commit -m initial_commit &&
12+
# Create two packs
13+
# The first pack will contain all of the objects except one
14+
git rev-list --objects --all | grep -v file2 |
15+
git pack-objects pack > /dev/null &&
16+
# The second pack will contain the excluded object
17+
packsha1=$(git rev-list --objects --all | grep file2 |
18+
git pack-objects pack) &&
19+
touch -r pack-$packsha1.pack pack-$packsha1.keep &&
20+
objsha1=$(git verify-pack -v pack-$packsha1.idx | head -n 1 |
21+
sed -e "s/^\([0-9a-f]\{40\}\).*/\1/") &&
22+
mv pack-* .git/objects/pack/ &&
23+
git repack -A -d -l &&
24+
git prune-packed &&
25+
for p in .git/objects/pack/*.idx; do
26+
idx=$(basename $p)
27+
test "pack-$packsha1.idx" = "$idx" && continue
28+
if git verify-pack -v $p | egrep "^$objsha1"; then
29+
found_duplicate_object=1
30+
echo "DUPLICATE OBJECT FOUND"
31+
break
32+
fi
33+
done &&
34+
test -z "$found_duplicate_object"
35+
'
36+
37+
test_done
38+

0 commit comments

Comments
 (0)