]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t7700: stop losing return codes of git commands
authorDenton Liu <liu.denton@gmail.com>
Wed, 4 Dec 2019 22:03:30 +0000 (14:03 -0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 4 Dec 2019 22:25:05 +0000 (14:25 -0800)
In a pipe, only the return code of the last command is used. Thus, all
other commands will have their return codes masked. Rewrite pipes so
that there are no git commands upstream so that we will know if a
command fails.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t7700-repack.sh

index 5229999d7776dd30e4bcc258cd0c827adfe5861f..25b235c06303850e17b90f5fc6c0f84bb962c4c8 100755 (executable)
@@ -48,14 +48,13 @@ test_expect_success 'objects in packs marked .keep are not repacked' '
        git commit -m initial_commit &&
        # Create two packs
        # The first pack will contain all of the objects except one
-       git rev-list --objects --all | grep -v file2 |
-               git pack-objects pack &&
+       git rev-list --objects --all >objs &&
+       grep -v file2 objs | git pack-objects pack &&
        # The second pack will contain the excluded object
-       packid=$(git rev-list --objects --all | grep file2 |
-               git pack-objects pack) &&
+       packid=$(grep file2 objs | git pack-objects pack) &&
        >pack-$packid.keep &&
-       oid=$(git verify-pack -v pack-$packid.idx | head -n 1 |
-               sed -e "s/^\($OID_REGEX\).*/\1/") &&
+       git verify-pack -v pack-$packid.idx >packlist &&
+       oid=$(head -n 1 packlist | sed -e "s/^\($OID_REGEX\).*/\1/") &&
        mv pack-* .git/objects/pack/ &&
        git repack -A -d -l &&
        git prune-packed &&
@@ -134,8 +133,8 @@ test_expect_success 'packed unreachable obs in alternate ODB are not loosened' '
            --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 |
-               grep "^$coid " | sort | uniq | wc -l) &&
+       git verify-pack -v -- .git/objects/pack/*.idx >packlist &&
+       ! grep "^$coid " packlist &&
        echo >.git/objects/info/alternates &&
        test_must_fail git show $coid
 '
@@ -151,8 +150,8 @@ test_expect_success 'local packed unreachable obs that exist in alternate ODB ar
            --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 |
-               grep "^$coid " | sort | uniq | wc -l) &&
+       git verify-pack -v -- .git/objects/pack/*.idx >packlist &&
+       ! grep "^$coid " &&
        echo >.git/objects/info/alternates &&
        test_must_fail git show $coid
 '