@matheusbsbs / matheus-bagliano / commits / 92cd872202
Fork 0

t7700-repack: add two new tests demonstrating repacking flaws

1) The new --kept-pack-only mechansim of rev-list/pack-objects has replaced --unpacked=. This new mechansim does not operate solely on "local" packs now. The result is that objects residing in an alternate pack which has a .keep file will not be repacked with repack -a. This flaw is only apparent when a commit object is the one residing in an alternate kept pack. 2) The 'repack unpacked objects' and 'loosen unpacked objects' mechanisms of pack-objects, i.e. --keep-unreachable and --unpack-unreachable, now do not operate solely on local packs. The --keep-unreachable option no longer has any callers, but --unpack-unreachable is used when repack is called with '-A -d' and the local repo has existing packs. In this case, objects residing in alternate, not-kept packs will be loosened, and then immediately deleted by repack's call to prune-packed. The test must manually call pack-objects to avoid the call to prune-packed that is made by repack when -d is used. Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Brandon Casey committed Mar 19, 2009 at 22:47 UTC 92cd872202241a0b80e88dadac5a4db071c8d1fa
1 file changed +44
t/t7700-repack.sh
+44
@@ -69,5 +69,49 @@ test_expect_success 'packed obs in alt ODB are repacked even when local repo is
69 done
70 '
71
72 +test_expect_failure 'packed obs in alternate ODB kept pack are repacked' '
73 + # swap the .keep so the commit object is in the pack with .keep
74 + for p in alt_objects/pack/*.pack
75 + do
76 + base_name=$(basename $p .pack)
77 + if test -f alt_objects/pack/$base_name.keep
78 + then
79 + rm alt_objects/pack/$base_name.keep
80 + else
81 + touch alt_objects/pack/$base_name.keep
82 + fi
83 + done
84 + git repack -a -d &&
85 + myidx=$(ls -1 .git/objects/pack/*.idx) &&
86 + test -f "$myidx" &&
87 + for p in alt_objects/pack/*.idx; do
88 + git verify-pack -v $p | sed -n -e "/^[0-9a-f]\{40\}/p"
89 + done | while read sha1 rest; do
90 + if ! ( git verify-pack -v $myidx | grep "^$sha1" ); then
91 + echo "Missing object in local pack: $sha1"
92 + return 1
93 + fi
94 + done
95 +'
96 +
97 +test_expect_failure 'packed unreachable obs in alternate ODB are not loosened' '
98 + rm -f alt_objects/pack/*.keep &&
99 + mv .git/objects/pack/* alt_objects/pack/ &&
100 + csha1=$(git rev-parse HEAD^{commit}) &&
101 + git reset --hard HEAD^ &&
102 + sleep 1 &&
103 + git reflog expire --expire=now --expire-unreachable=now --all &&
104 + # The pack-objects call on the next line is equivalent to
105 + # git repack -A -d without the call to prune-packed
106 + git pack-objects --honor-pack-keep --non-empty --all --reflog \
107 + --unpack-unreachable </dev/null pack &&
108 + rm -f .git/objects/pack/* &&
109 + mv pack-* .git/objects/pack/ &&
110 + test 0 = $(git verify-pack -v -- .git/objects/pack/*.idx |
111 + egrep "^$csha1 " | sort | uniq | wc -l) &&
112 + echo > .git/objects/info/alternates &&
113 + test_must_fail git show $csha1
114 +'
115 +
116 test_done
117