]> git.ipfire.org Git - thirdparty/git.git/blobdiff - t/t1050-large.sh
tests: apply modern idiom for exiting loop upon failure
[thirdparty/git.git] / t / t1050-large.sh
index f9eb143f43420b0e2f2b864b4f83f78de7886a7b..0e4267c72385654d6751c07ccb79ee3e98333575 100755 (executable)
@@ -5,12 +5,6 @@ test_description='adding and checking out large blobs'
 
 . ./test-lib.sh
 
-# This should be moved to test-lib.sh together with the
-# copy in t0021 after both topics have graduated to 'master'.
-file_size () {
-       perl -e 'print -s $ARGV[0]' "$1"
-}
-
 test_expect_success setup '
        # clone does not allow us to pass core.bigfilethreshold to
        # new repos, so set core.bigfilethreshold globally
@@ -23,13 +17,21 @@ test_expect_success setup '
        export GIT_ALLOC_LIMIT
 '
 
+test_expect_success 'enter "large" codepath, with small core.bigFileThreshold' '
+       test_when_finished "rm -rf repo" &&
+
+       git init --bare repo &&
+       echo large | git -C repo hash-object -w --stdin &&
+       git -C repo -c core.bigfilethreshold=4 fsck
+'
+
 # add a large file with different settings
 while read expect config
 do
        test_expect_success "add with $config" '
                test_when_finished "rm -f .git/objects/pack/pack-*.* .git/index" &&
                git $config add large1 &&
-               sz=$(file_size .git/objects/pack/pack-*.pack) &&
+               sz=$(test_file_size .git/objects/pack/pack-*.pack) &&
                case "$expect" in
                small) test "$sz" -le 100000 ;;
                large) test "$sz" -ge 100000 ;;
@@ -49,40 +51,32 @@ EOF
 test_expect_success 'add a large file or two' '
        git add large1 huge large2 &&
        # make sure we got a single packfile and no loose objects
-       bad= count=0 idx= &&
+       count=0 idx= &&
        for p in .git/objects/pack/pack-*.pack
        do
-               count=$(( $count + 1 ))
-               if test -f "$p" && idx=${p%.pack}.idx && test -f "$idx"
-               then
-                       continue
-               fi
-               bad=t
+               count=$(( $count + 1 )) &&
+               test_path_is_file "$p" &&
+               idx=${p%.pack}.idx &&
+               test_path_is_file "$idx" || return 1
        done &&
-       test -z "$bad" &&
        test $count = 1 &&
        cnt=$(git show-index <"$idx" | wc -l) &&
        test $cnt = 2 &&
-       for l in .git/objects/??/??????????????????????????????????????
+       for l in .git/objects/$OIDPATH_REGEX
        do
-               test -f "$l" || continue
-               bad=t
+               test_path_is_missing "$l" || return 1
        done &&
-       test -z "$bad" &&
 
        # attempt to add another copy of the same
        git add large3 &&
        bad= count=0 &&
        for p in .git/objects/pack/pack-*.pack
        do
-               count=$(( $count + 1 ))
-               if test -f "$p" && idx=${p%.pack}.idx && test -f "$idx"
-               then
-                       continue
-               fi
-               bad=t
+               count=$(( $count + 1 )) &&
+               test_path_is_file "$p" &&
+               idx=${p%.pack}.idx &&
+               test_path_is_file "$idx" || return 1
        done &&
-       test -z "$bad" &&
        test $count = 1
 '
 
@@ -108,16 +102,16 @@ test_expect_success 'packsize limit' '
                test-tool genrandom "c" $(( 128 * 1024 )) >mid3 &&
                git add mid1 mid2 mid3 &&
 
-               count=0
+               count=0 &&
                for pi in .git/objects/pack/pack-*.idx
                do
-                       test -f "$pi" && count=$(( $count + 1 ))
+                       test_path_is_file "$pi" && count=$(( $count + 1 ))
                done &&
                test $count = 2 &&
 
                (
-                       git hash-object --stdin <mid1
-                       git hash-object --stdin <mid2
+                       git hash-object --stdin <mid1 &&
+                       git hash-object --stdin <mid2 &&
                        git hash-object --stdin <mid3
                ) |
                sort >expect &&
@@ -175,7 +169,8 @@ test_expect_success 'git-show a large file' '
 
 test_expect_success 'index-pack' '
        git clone file://"$(pwd)"/.git foo &&
-       GIT_DIR=non-existent git index-pack --strict --verify foo/.git/objects/pack/*.pack
+       GIT_DIR=non-existent git index-pack --object-format=$(test_oid algo) \
+               --strict --verify foo/.git/objects/pack/*.pack
 '
 
 test_expect_success 'repack' '
@@ -194,15 +189,15 @@ test_expect_success 'pack-objects with large loose object' '
        test_cmp huge actual
 '
 
-test_expect_success 'tar achiving' '
+test_expect_success 'tar archiving' '
        git archive --format=tar HEAD >/dev/null
 '
 
-test_expect_success 'zip achiving, store only' '
+test_expect_success 'zip archiving, store only' '
        git archive --format=zip -0 HEAD >/dev/null
 '
 
-test_expect_success 'zip achiving, deflate' '
+test_expect_success 'zip archiving, deflate' '
        git archive --format=zip HEAD >/dev/null
 '