t7501: always use test_cmp instead of diff
[gitweb.git] / t / t5300-pack-object.sh
index c955fe44f5b962ef305e49c21bc3fb0e5b58d462..3a0ef8759c9d7a55b95c56ca38cd3c37ac2432fa 100755 (executable)
@@ -3,7 +3,7 @@
 # Copyright (c) 2005 Junio C Hamano
 #
 
-test_description='git-pack-object
+test_description='git pack-object
 
 '
 . ./test-lib.sh
@@ -186,6 +186,12 @@ test_expect_success \
                        test-2-${packname_2}.idx \
                        test-3-${packname_3}.idx'
 
+test_expect_success \
+    'verify pack -v' \
+    'git verify-pack -v        test-1-${packname_1}.idx \
+                       test-2-${packname_2}.idx \
+                       test-3-${packname_3}.idx'
+
 test_expect_success \
     'verify-pack catches mismatched .idx and .pack files' \
     'cat test-1-${packname_1}.idx >test-3.idx &&
@@ -236,24 +242,24 @@ test_expect_success \
 test_expect_success \
     'build pack index for an existing pack' \
     'cat test-1-${packname_1}.pack >test-3.pack &&
-     git-index-pack -o tmp.idx test-3.pack &&
+     git index-pack -o tmp.idx test-3.pack &&
      cmp tmp.idx test-1-${packname_1}.idx &&
 
-     git-index-pack test-3.pack &&
+     git index-pack test-3.pack &&
      cmp test-3.idx test-1-${packname_1}.idx &&
 
      cat test-2-${packname_2}.pack >test-3.pack &&
-     git-index-pack -o tmp.idx test-2-${packname_2}.pack &&
+     git index-pack -o tmp.idx test-2-${packname_2}.pack &&
      cmp tmp.idx test-2-${packname_2}.idx &&
 
-     git-index-pack test-3.pack &&
+     git index-pack test-3.pack &&
      cmp test-3.idx test-2-${packname_2}.idx &&
 
      cat test-3-${packname_3}.pack >test-3.pack &&
-     git-index-pack -o tmp.idx test-3-${packname_3}.pack &&
+     git index-pack -o tmp.idx test-3-${packname_3}.pack &&
      cmp tmp.idx test-3-${packname_3}.idx &&
 
-     git-index-pack test-3.pack &&
+     git index-pack test-3.pack &&
      cmp test-3.idx test-3-${packname_3}.idx &&
 
      :'
@@ -266,7 +272,7 @@ test_expect_success \
 
 test_expect_success \
     'make sure index-pack detects the SHA1 collision' \
-    '! git-index-pack -o bad.idx test-3.pack'
+    'test_must_fail git index-pack -o bad.idx test-3.pack'
 
 test_expect_success \
     'honor pack.packSizeLimit' \
@@ -274,4 +280,99 @@ test_expect_success \
      packname_4=$(git pack-objects test-4 <obj-list) &&
      test 3 = $(ls test-4-*.pack | wc -l)'
 
+test_expect_success 'unpacking with --strict' '
+
+       git config --unset pack.packsizelimit &&
+       for j in a b c d e f g
+       do
+               for i in 0 1 2 3 4 5 6 7 8 9
+               do
+                       o=$(echo $j$i | git hash-object -w --stdin) &&
+                       echo "100644 $o 0 $j$i"
+               done
+       done >LIST &&
+       rm -f .git/index &&
+       git update-index --index-info <LIST &&
+       LIST=$(git write-tree) &&
+       rm -f .git/index &&
+       head -n 10 LIST | git update-index --index-info &&
+       LI=$(git write-tree) &&
+       rm -f .git/index &&
+       tail -n 10 LIST | git update-index --index-info &&
+       ST=$(git write-tree) &&
+       PACK5=$( git rev-list --objects "$LIST" "$LI" "$ST" | \
+               git pack-objects test-5 ) &&
+       PACK6=$( (
+                       echo "$LIST"
+                       echo "$LI"
+                       echo "$ST"
+                ) | git pack-objects test-6 ) &&
+       test_create_repo test-5 &&
+       (
+               cd test-5 &&
+               git unpack-objects --strict <../test-5-$PACK5.pack &&
+               git ls-tree -r $LIST &&
+               git ls-tree -r $LI &&
+               git ls-tree -r $ST
+       ) &&
+       test_create_repo test-6 &&
+       (
+               # tree-only into empty repo -- many unreachables
+               cd test-6 &&
+               test_must_fail git unpack-objects --strict <../test-6-$PACK6.pack
+       ) &&
+       (
+               # already populated -- no unreachables
+               cd test-5 &&
+               git unpack-objects --strict <../test-6-$PACK6.pack
+       )
+'
+
+test_expect_success 'index-pack with --strict' '
+
+       for j in a b c d e f g
+       do
+               for i in 0 1 2 3 4 5 6 7 8 9
+               do
+                       o=$(echo $j$i | git hash-object -w --stdin) &&
+                       echo "100644 $o 0 $j$i"
+               done
+       done >LIST &&
+       rm -f .git/index &&
+       git update-index --index-info <LIST &&
+       LIST=$(git write-tree) &&
+       rm -f .git/index &&
+       head -n 10 LIST | git update-index --index-info &&
+       LI=$(git write-tree) &&
+       rm -f .git/index &&
+       tail -n 10 LIST | git update-index --index-info &&
+       ST=$(git write-tree) &&
+       PACK5=$( git rev-list --objects "$LIST" "$LI" "$ST" | \
+               git pack-objects test-5 ) &&
+       PACK6=$( (
+                       echo "$LIST"
+                       echo "$LI"
+                       echo "$ST"
+                ) | git pack-objects test-6 ) &&
+       test_create_repo test-7 &&
+       (
+               cd test-7 &&
+               git index-pack --strict --stdin <../test-5-$PACK5.pack &&
+               git ls-tree -r $LIST &&
+               git ls-tree -r $LI &&
+               git ls-tree -r $ST
+       ) &&
+       test_create_repo test-8 &&
+       (
+               # tree-only into empty repo -- many unreachables
+               cd test-8 &&
+               test_must_fail git index-pack --strict --stdin <../test-6-$PACK6.pack
+       ) &&
+       (
+               # already populated -- no unreachables
+               cd test-7 &&
+               git index-pack --strict --stdin <../test-6-$PACK6.pack
+       )
+'
+
 test_done