transport: die if server options are unsupported
[gitweb.git] / t / t5322-pack-objects-sparse.sh
index 30aef6498af9e76abac668aad99e92f7105b26a6..7124b5581a0e3e31ae9b78b46aec9f059eeb7c1a 100755 (executable)
@@ -36,7 +36,7 @@ test_expect_success 'setup repo' '
 '
 
 test_expect_success 'non-sparse pack-objects' '
-       git pack-objects --stdout --revs <packinput.txt >nonsparse.pack &&
+       git pack-objects --stdout --revs --no-sparse <packinput.txt >nonsparse.pack &&
        git index-pack -o nonsparse.idx nonsparse.pack &&
        git show-index <nonsparse.idx | awk "{print \$2}" >nonsparse_objects.txt &&
        test_cmp expect_objects.txt nonsparse_objects.txt
@@ -64,7 +64,7 @@ test_expect_success 'duplicate a folder from f3 and commit to topic1' '
 '
 
 test_expect_success 'non-sparse pack-objects' '
-       git pack-objects --stdout --revs <packinput.txt >nonsparse.pack &&
+       git pack-objects --stdout --revs --no-sparse <packinput.txt >nonsparse.pack &&
        git index-pack -o nonsparse.idx nonsparse.pack &&
        git show-index <nonsparse.idx | awk "{print \$2}" >nonsparse_objects.txt &&
        comm -1 -2 required_objects.txt nonsparse_objects.txt >nonsparse_required_objects.txt &&
@@ -79,6 +79,9 @@ test_expect_success 'sparse pack-objects' '
        test_cmp required_objects.txt sparse_required_objects.txt
 '
 
+# Demonstrate that the algorithms differ when we copy a tree wholesale
+# from one folder to another.
+
 test_expect_success 'duplicate a folder from f1 into f3' '
        mkdir f3/f4 &&
        cp -r f1/f1/* f3/f4 &&
@@ -95,7 +98,7 @@ test_expect_success 'duplicate a folder from f1 into f3' '
 '
 
 test_expect_success 'non-sparse pack-objects' '
-       git pack-objects --stdout --revs <packinput.txt >nonsparse.pack &&
+       git pack-objects --stdout --revs --no-sparse <packinput.txt >nonsparse.pack &&
        git index-pack -o nonsparse.idx nonsparse.pack &&
        git show-index <nonsparse.idx | awk "{print \$2}" >nonsparse_objects.txt &&
        comm -1 -2 required_objects.txt nonsparse_objects.txt >nonsparse_required_objects.txt &&
@@ -103,11 +106,31 @@ test_expect_success 'non-sparse pack-objects' '
 '
 
 test_expect_success 'sparse pack-objects' '
+       git rev-parse                   \
+               topic1                  \
+               topic1^{tree}           \
+               topic1:f3               \
+               topic1:f3/f4            \
+               topic1:f3/f4/data.txt | sort >expect_sparse_objects.txt &&
        git pack-objects --stdout --revs --sparse <packinput.txt >sparse.pack &&
        git index-pack -o sparse.idx sparse.pack &&
        git show-index <sparse.idx | awk "{print \$2}" >sparse_objects.txt &&
-       comm -1 -2 required_objects.txt sparse_objects.txt >sparse_required_objects.txt &&
-       test_cmp required_objects.txt sparse_required_objects.txt
+       test_cmp expect_sparse_objects.txt sparse_objects.txt
+'
+
+test_expect_success 'pack.useSparse enables algorithm' '
+       git config pack.useSparse true &&
+       git pack-objects --stdout --revs <packinput.txt >sparse.pack &&
+       git index-pack -o sparse.idx sparse.pack &&
+       git show-index <sparse.idx | awk "{print \$2}" >sparse_objects.txt &&
+       test_cmp expect_sparse_objects.txt sparse_objects.txt
+'
+
+test_expect_success 'pack.useSparse overridden' '
+       git pack-objects --stdout --revs --no-sparse <packinput.txt >sparse.pack &&
+       git index-pack -o sparse.idx sparse.pack &&
+       git show-index <sparse.idx | awk "{print \$2}" >sparse_objects.txt &&
+       test_cmp required_objects.txt sparse_objects.txt
 '
 
 test_done