Skip to content

Commit 869a3d3

Browse files
drafnelgitster
authored andcommitted
t7700: demonstrate repack flaw which may loosen objects unnecessarily
If an unreferenced object exists in both a local pack and in either a pack residing in an alternate object database or a local kept pack, then the pack-objects call made by repack will loosen that object only to have it immediately pruned by repack's call to prune-packed. Signed-off-by: Brandon Casey <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4d6acb7 commit 869a3d3

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

t/t7700-repack.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,5 +113,22 @@ test_expect_success 'packed unreachable obs in alternate ODB are not loosened' '
113113
test_must_fail git show $csha1
114114
'
115115

116+
test_expect_failure 'local packed unreachable obs that exist in alternate ODB are not loosened' '
117+
echo `pwd`/alt_objects > .git/objects/info/alternates &&
118+
echo "$csha1" | git pack-objects --non-empty --all --reflog pack &&
119+
rm -f .git/objects/pack/* &&
120+
mv pack-* .git/objects/pack/ &&
121+
# The pack-objects call on the next line is equivalent to
122+
# git repack -A -d without the call to prune-packed
123+
git pack-objects --honor-pack-keep --non-empty --all --reflog \
124+
--unpack-unreachable </dev/null pack &&
125+
rm -f .git/objects/pack/* &&
126+
mv pack-* .git/objects/pack/ &&
127+
test 0 = $(git verify-pack -v -- .git/objects/pack/*.idx |
128+
egrep "^$csha1 " | sort | uniq | wc -l) &&
129+
echo > .git/objects/info/alternates &&
130+
test_must_fail git show $csha1
131+
'
132+
116133
test_done
117134

0 commit comments

Comments
 (0)