Merge branch 'jc/maint-1.6.0-keep-pack'
authorJunio C Hamano <gitster@pobox.com>
Thu, 2 Apr 2009 05:34:19 +0000 (22:34 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 2 Apr 2009 05:34:19 +0000 (22:34 -0700)
* jc/maint-1.6.0-keep-pack:
  pack-objects: don't loosen objects available in alternate or kept packs
  t7700: demonstrate repack flaw which may loosen objects unnecessarily
  Remove --kept-pack-only option and associated infrastructure
  pack-objects: only repack or loosen objects residing in "local" packs
  git-repack.sh: don't use --kept-pack-only option to pack-objects
  t7700-repack: add two new tests demonstrating repacking flaws

Conflicts:
t/t7700-repack.sh

1  2 
builtin-pack-objects.c
cache.h
git-repack.sh
revision.c
revision.h
sha1_file.c
t/t7700-repack.sh

Simple merge
diff --cc cache.h
Simple merge
diff --cc git-repack.sh
Simple merge
diff --cc revision.c
Simple merge
diff --cc revision.h
Simple merge
diff --cc sha1_file.c
Simple merge
index f5682d66db2832311774fb68b7264002dfeb091f,9ce546e3b225563279c54eb6ceafd87398a3e5cc..6b29bff782f5a46bb6970d70598fd3be82c679fa
@@@ -69,24 -69,66 +69,85 @@@ test_expect_success 'packed obs in alt 
        done
  '
  
 +test_expect_failure 'packed obs in alt ODB are repacked when local repo has packs' '
 +      rm -f .git/objects/pack/* &&
 +      echo new_content >> file1 &&
 +      git add file1 &&
 +      git commit -m more_content &&
 +      git repack &&
 +      git repack -a -d &&
 +      myidx=$(ls -1 .git/objects/pack/*.idx) &&
 +      test -f "$myidx" &&
 +      for p in alt_objects/pack/*.idx; do
 +              git verify-pack -v $p | sed -n -e "/^[0-9a-f]\{40\}/p"
 +      done | while read sha1 rest; do
 +              if ! ( git verify-pack -v $myidx | grep "^$sha1" ); then
 +                      echo "Missing object in local pack: $sha1"
 +                      return 1
 +              fi
 +      done
 +'
 +
+ test_expect_success 'packed obs in alternate ODB kept pack are repacked' '
+       # swap the .keep so the commit object is in the pack with .keep
+       for p in alt_objects/pack/*.pack
+       do
+               base_name=$(basename $p .pack)
+               if test -f alt_objects/pack/$base_name.keep
+               then
+                       rm alt_objects/pack/$base_name.keep
+               else
+                       touch alt_objects/pack/$base_name.keep
+               fi
+       done
+       git repack -a -d &&
+       myidx=$(ls -1 .git/objects/pack/*.idx) &&
+       test -f "$myidx" &&
+       for p in alt_objects/pack/*.idx; do
+               git verify-pack -v $p | sed -n -e "/^[0-9a-f]\{40\}/p"
+       done | while read sha1 rest; do
+               if ! ( git verify-pack -v $myidx | grep "^$sha1" ); then
+                       echo "Missing object in local pack: $sha1"
+                       return 1
+               fi
+       done
+ '
+ test_expect_success 'packed unreachable obs in alternate ODB are not loosened' '
+       rm -f alt_objects/pack/*.keep &&
+       mv .git/objects/pack/* alt_objects/pack/ &&
+       csha1=$(git rev-parse HEAD^{commit}) &&
+       git reset --hard HEAD^ &&
+       sleep 1 &&
+       git reflog expire --expire=now --expire-unreachable=now --all &&
+       # The pack-objects call on the next line is equivalent to
+       # git repack -A -d without the call to prune-packed
+       git pack-objects --honor-pack-keep --non-empty --all --reflog \
+           --unpack-unreachable </dev/null pack &&
+       rm -f .git/objects/pack/* &&
+       mv pack-* .git/objects/pack/ &&
+       test 0 = $(git verify-pack -v -- .git/objects/pack/*.idx |
+               egrep "^$csha1 " | sort | uniq | wc -l) &&
+       echo > .git/objects/info/alternates &&
+       test_must_fail git show $csha1
+ '
+ test_expect_success 'local packed unreachable obs that exist in alternate ODB are not loosened' '
+       echo `pwd`/alt_objects > .git/objects/info/alternates &&
+       echo "$csha1" | git pack-objects --non-empty --all --reflog pack &&
+       rm -f .git/objects/pack/* &&
+       mv pack-* .git/objects/pack/ &&
+       # The pack-objects call on the next line is equivalent to
+       # git repack -A -d without the call to prune-packed
+       git pack-objects --honor-pack-keep --non-empty --all --reflog \
+           --unpack-unreachable </dev/null pack &&
+       rm -f .git/objects/pack/* &&
+       mv pack-* .git/objects/pack/ &&
+       test 0 = $(git verify-pack -v -- .git/objects/pack/*.idx |
+               egrep "^$csha1 " | sort | uniq | wc -l) &&
+       echo > .git/objects/info/alternates &&
+       test_must_fail git show $csha1
+ '
  test_done