]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'ab/avoid-losing-exit-codes-in-tests'
authorJunio C Hamano <gitster@pobox.com>
Sun, 19 Mar 2023 22:03:10 +0000 (15:03 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sun, 19 Mar 2023 22:03:10 +0000 (15:03 -0700)
Test clean-up.

* ab/avoid-losing-exit-codes-in-tests:
  tests: don't lose misc "git" exit codes
  tests: don't lose exit status with "test <op> $(git ...)"
  tests: don't lose "git" exit codes in "! ( git ... | grep )"
  tests: don't lose exit status with "(cd ...; test <op> $(git ...))"
  t/lib-patch-mode.sh: fix ignored exit codes
  auto-crlf tests: don't lose exit code in loops and outside tests

21 files changed:
t/lib-httpd.sh
t/lib-patch-mode.sh
t/lib-submodule-update.sh
t/t0001-init.sh
t/t0002-gitfile.sh
t/t0027-auto-crlf.sh
t/t0055-beyond-symlinks.sh
t/t0060-path-utils.sh
t/t0100-previous.sh
t/t1401-symbolic-ref.sh
t/t1504-ceiling-dirs.sh
t/t2005-checkout-index-symlinks.sh
t/t3200-branch.sh
t/t3700-add.sh
t/t3701-add-interactive.sh
t/t5522-pull-symlink.sh
t/t5605-clone-local.sh
t/t7402-submodule-rebase.sh
t/t7504-commit-msg-hook.sh
t/t7516-commit-races.sh
t/t7810-grep.sh

index 3e876536ebfcacace2dda8b984855a0790b28e30..6805229dcb9528e75399aefc46735e8cd14f4b4c 100644 (file)
@@ -228,8 +228,12 @@ test_http_push_nonff () {
                git commit -a -m path2 --amend &&
 
                test_must_fail git push -v origin >output 2>&1 &&
-               (cd "$REMOTE_REPO" &&
-                test $HEAD = $(git rev-parse --verify HEAD))
+               (
+                       cd "$REMOTE_REPO" &&
+                       echo "$HEAD" >expect &&
+                       git rev-parse --verify HEAD >actual &&
+                       test_cmp expect actual
+               )
        '
 
        test_expect_success 'non-fast-forward push show ref status' '
index cfd76bf987bd902503cfcacd3e8ac1b9c4deb09c..89ca1f7805547eec1f4ee8e90c1afefc30b35da6 100644 (file)
@@ -29,8 +29,12 @@ set_and_save_state () {
 
 # verify_state <path> <expected-worktree-content> <expected-index-content>
 verify_state () {
-       test "$(cat "$1")" = "$2" &&
-       test "$(git show :"$1")" = "$3"
+       echo "$2" >expect &&
+       test_cmp expect "$1" &&
+
+       echo "$3" >expect &&
+       git show :"$1" >actual &&
+       test_cmp expect actual
 }
 
 # verify_saved_state <path>
@@ -46,5 +50,6 @@ save_head () {
 }
 
 verify_saved_head () {
-       test "$(cat _head)" = "$(git rev-parse HEAD)"
+       git rev-parse HEAD >actual &&
+       test_cmp _head actual
 }
index 2d31fcfda1f338973cfc868b7f01ae925b39d326..dee14992c52d5d24075c9b048dfe1e47c620b29e 100644 (file)
@@ -168,20 +168,16 @@ replace_gitfile_with_git_dir () {
 # Note that this only supports submodules at the root level of the
 # superproject, with the default name, i.e. same as its path.
 test_git_directory_is_unchanged () {
-       (
-               cd ".git/modules/$1" &&
-               # does core.worktree point at the right place?
-               test "$(git config core.worktree)" = "../../../$1" &&
-               # remove it temporarily before comparing, as
-               # "$1/.git/config" lacks it...
-               git config --unset core.worktree
-       ) &&
+       # does core.worktree point at the right place?
+       echo "../../../$1" >expect &&
+       git -C ".git/modules/$1" config core.worktree >actual &&
+       test_cmp expect actual &&
+       # remove it temporarily before comparing, as
+       # "$1/.git/config" lacks it...
+       git -C ".git/modules/$1" config --unset core.worktree &&
        diff -r ".git/modules/$1" "$1/.git" &&
-       (
-               # ... and then restore.
-               cd ".git/modules/$1" &&
-               git config core.worktree "../../../$1"
-       )
+       # ... and then restore.
+       git -C ".git/modules/$1" config core.worktree "../../../$1"
 }
 
 test_git_directory_exists () {
@@ -189,7 +185,9 @@ test_git_directory_exists () {
        if test -f sub1/.git
        then
                # does core.worktree point at the right place?
-               test "$(git -C .git/modules/$1 config core.worktree)" = "../../../$1"
+               echo "../../../$1" >expect &&
+               git -C ".git/modules/$1" config core.worktree >actual &&
+               test_cmp expect actual
        fi
 }
 
index d479303efa03df6f818496f1cdcafe390bee0126..30a6edca1d29fcef63cfc155685600c63553f636 100755 (executable)
@@ -598,9 +598,14 @@ test_expect_success 'invalid default branch name' '
 test_expect_success 'branch -m with the initial branch' '
        git init rename-initial &&
        git -C rename-initial branch -m renamed &&
-       test renamed = $(git -C rename-initial symbolic-ref --short HEAD) &&
+       echo renamed >expect &&
+       git -C rename-initial symbolic-ref --short HEAD >actual &&
+       test_cmp expect actual &&
+
        git -C rename-initial branch -m renamed again &&
-       test again = $(git -C rename-initial symbolic-ref --short HEAD)
+       echo again >expect &&
+       git -C rename-initial symbolic-ref --short HEAD >actual &&
+       test_cmp expect actual
 '
 
 test_done
index 26eaca095a26a6a654364bdd8acf208af30b2d00..e013d38f485cc8b06c1afb51579ed6a4d322dfaa 100755 (executable)
@@ -33,7 +33,9 @@ test_expect_success 'bad setup: invalid .git file path' '
 
 test_expect_success 'final setup + check rev-parse --git-dir' '
        echo "gitdir: $REAL" >.git &&
-       test "$REAL" = "$(git rev-parse --git-dir)"
+       echo "$REAL" >expect &&
+       git rev-parse --git-dir >actual &&
+       test_cmp expect actual
 '
 
 test_expect_success 'check hash-object' '
index a94ac1eae377c023ae3e02eaae393db6e8d232d3..2f57c8669cb5af3dd6fc79bfca4b486f50fa4d19 100755 (executable)
@@ -70,7 +70,8 @@ create_NNO_MIX_files () {
                                cp CRLF        ${pfx}_CRLF.txt &&
                                cp CRLF_mix_LF ${pfx}_CRLF_mix_LF.txt &&
                                cp LF_mix_CR   ${pfx}_LF_mix_CR.txt &&
-                               cp CRLF_nul    ${pfx}_CRLF_nul.txt
+                               cp CRLF_nul    ${pfx}_CRLF_nul.txt ||
+                               return 1
                        done
                done
        done
@@ -101,7 +102,8 @@ commit_check_warn () {
        do
                fname=${pfx}_$f.txt &&
                cp $f $fname &&
-               git -c core.autocrlf=$crlf add $fname 2>"${pfx}_$f.err"
+               git -c core.autocrlf=$crlf add $fname 2>"${pfx}_$f.err" ||
+               return 1
        done &&
        git commit -m "core.autocrlf $crlf" &&
        check_warning "$lfname" ${pfx}_LF.err &&
@@ -121,15 +123,19 @@ commit_chk_wrnNNO () {
        lfmixcr=$1 ; shift
        crlfnul=$1 ; shift
        pfx=NNO_attr_${attr}_aeol_${aeol}_${crlf}
-       #Commit files on top of existing file
-       create_gitattributes "$attr" $aeol &&
-       for f in LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul
-       do
-               fname=${pfx}_$f.txt &&
-               cp $f $fname &&
-               printf Z >>"$fname" &&
-               git -c core.autocrlf=$crlf add $fname 2>"${pfx}_$f.err"
-       done
+
+       test_expect_success 'setup commit NNO files' '
+               #Commit files on top of existing file
+               create_gitattributes "$attr" $aeol &&
+               for f in LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul
+               do
+                       fname=${pfx}_$f.txt &&
+                       cp $f $fname &&
+                       printf Z >>"$fname" &&
+                       git -c core.autocrlf=$crlf add $fname 2>"${pfx}_$f.err" ||
+                       return 1
+               done
+       '
 
        test_expect_success "commit NNO files crlf=$crlf attr=$attr LF" '
                check_warning "$lfwarn" ${pfx}_LF.err
@@ -163,15 +169,19 @@ commit_MIX_chkwrn () {
        lfmixcr=$1 ; shift
        crlfnul=$1 ; shift
        pfx=MIX_attr_${attr}_aeol_${aeol}_${crlf}
-       #Commit file with CLRF_mix_LF on top of existing file
-       create_gitattributes "$attr" $aeol &&
-       for f in LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul
-       do
-               fname=${pfx}_$f.txt &&
-               cp CRLF_mix_LF $fname &&
-               printf Z >>"$fname" &&
-               git -c core.autocrlf=$crlf add $fname 2>"${pfx}_$f.err"
-       done
+
+       test_expect_success 'setup commit file with mixed EOL' '
+               #Commit file with CLRF_mix_LF on top of existing file
+               create_gitattributes "$attr" $aeol &&
+               for f in LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul
+               do
+                       fname=${pfx}_$f.txt &&
+                       cp CRLF_mix_LF $fname &&
+                       printf Z >>"$fname" &&
+                       git -c core.autocrlf=$crlf add $fname 2>"${pfx}_$f.err" ||
+                       return 1
+               done
+       '
 
        test_expect_success "commit file with mixed EOL onto LF crlf=$crlf attr=$attr" '
                check_warning "$lfwarn" ${pfx}_LF.err
@@ -289,17 +299,17 @@ checkout_files () {
        lfmixcrlf=$1 ; shift
        lfmixcr=$1 ; shift
        crlfnul=$1 ; shift
-       create_gitattributes "$attr" $ident $aeol &&
-       git config core.autocrlf $crlf &&
+       test_expect_success "setup config for checkout attr=$attr ident=$ident aeol=$aeol core.autocrlf=$crlf" '
+               create_gitattributes "$attr" $ident $aeol &&
+               git config core.autocrlf $crlf
+       '
        pfx=eol_${ceol}_crlf_${crlf}_attr_${attr}_ &&
        for f in LF CRLF LF_mix_CR CRLF_mix_LF LF_nul
        do
-               rm crlf_false_attr__$f.txt &&
-               if test -z "$ceol"; then
-                       git checkout -- crlf_false_attr__$f.txt
-               else
-                       git -c core.eol=$ceol checkout -- crlf_false_attr__$f.txt
-               fi
+               test_expect_success "setup $f checkout ${ceol:+ with -c core.eol=$ceol}"  '
+                       rm -f crlf_false_attr__$f.txt &&
+                       git ${ceol:+-c core.eol=$ceol} checkout -- crlf_false_attr__$f.txt
+               '
        done
 
        test_expect_success "ls-files --eol attr=$attr $ident aeol=$aeol core.autocrlf=$crlf core.eol=$ceol" '
index 6bada3702257649551558884237f71bea3fdadc2..c3eb1158ef9ae2eb10f3f7a6d5c882e41f3c576a 100755 (executable)
@@ -15,12 +15,22 @@ test_expect_success SYMLINKS setup '
 
 test_expect_success SYMLINKS 'update-index --add beyond symlinks' '
        test_must_fail git update-index --add c/d &&
-       ! ( git ls-files | grep c/d )
+       cat >expect <<-\EOF &&
+       a
+       b/d
+       EOF
+       git ls-files >actual &&
+       test_cmp expect actual
 '
 
 test_expect_success SYMLINKS 'add beyond symlinks' '
        test_must_fail git add c/d &&
-       ! ( git ls-files | grep c/d )
+       cat >expect <<-\EOF &&
+       a
+       b/d
+       EOF
+       git ls-files >actual &&
+       test_cmp expect actual
 '
 
 test_done
index 68e29c904a62c9ef51d6a1bfc3449795d50ac10f..0afa3d0d312ca6d1788b76d3b0dfcba04f8397e7 100755 (executable)
@@ -10,20 +10,27 @@ TEST_PASSES_SANITIZE_LEAK=true
 
 norm_path() {
        expected=$(test-tool path-utils print_path "$2")
-       test_expect_success $3 "normalize path: $1 => $2" \
-       "test \"\$(test-tool path-utils normalize_path_copy '$1')\" = '$expected'"
+       test_expect_success $3 "normalize path: $1 => $2" "
+               echo '$expected' >expect &&
+               test-tool path-utils normalize_path_copy '$1' >actual &&
+               test_cmp expect actual
+       "
 }
 
 relative_path() {
        expected=$(test-tool path-utils print_path "$3")
-       test_expect_success $4 "relative path: $1 $2 => $3" \
-       "test \"\$(test-tool path-utils relative_path '$1' '$2')\" = '$expected'"
+       test_expect_success $4 "relative path: $1 $2 => $3" "
+               echo '$expected' >expect &&
+               test-tool path-utils relative_path '$1' '$2' >actual &&
+               test_cmp expect actual
+       "
 }
 
 test_submodule_relative_url() {
        test_expect_success "test_submodule_relative_url: $1 $2 $3 => $4" "
-               actual=\$(test-tool submodule resolve-relative-url '$1' '$2' '$3') &&
-               test \"\$actual\" = '$4'
+               echo '$4' >expect &&
+               test-tool submodule resolve-relative-url '$1' '$2' '$3' >actual &&
+               test_cmp expect actual
        "
 }
 
@@ -64,9 +71,11 @@ ancestor() {
                expected=$(($expected-$rootslash+$rootoff))
                ;;
        esac
-       test_expect_success $4 "longest ancestor: $1 $2 => $expected" \
-       "actual=\$(test-tool path-utils longest_ancestor_length '$1' '$2') &&
-        test \"\$actual\" = '$expected'"
+       test_expect_success $4 "longest ancestor: $1 $2 => $expected" "
+               echo '$expected' >expect &&
+               test-tool path-utils longest_ancestor_length '$1' '$2' >actual &&
+               test_cmp expect actual
+       "
 }
 
 # Some absolute path tests should be skipped on Windows due to path mangling
@@ -166,8 +175,10 @@ ancestor D:/Users/me C:/ -1 MINGW
 ancestor //server/share/my-directory //server/share/ 14 MINGW
 
 test_expect_success 'strip_path_suffix' '
-       test c:/msysgit = $(test-tool path-utils strip_path_suffix \
-               c:/msysgit/libexec//git-core libexec/git-core)
+       echo c:/msysgit >expect &&
+       test-tool path-utils strip_path_suffix \
+               c:/msysgit/libexec//git-core libexec/git-core >actual &&
+       test_cmp expect actual
 '
 
 test_expect_success 'absolute path rejects the empty string' '
@@ -188,35 +199,61 @@ test_expect_success 'real path rejects the empty string' '
 '
 
 test_expect_success POSIX 'real path works on absolute paths 1' '
+       echo / >expect &&
+       test-tool path-utils real_path "/" >actual &&
+       test_cmp expect actual &&
+
        nopath="hopefully-absent-path" &&
-       test "/" = "$(test-tool path-utils real_path "/")" &&
-       test "/$nopath" = "$(test-tool path-utils real_path "/$nopath")"
+       echo "/$nopath" >expect &&
+       test-tool path-utils real_path "/$nopath" >actual &&
+       test_cmp expect actual
 '
 
 test_expect_success 'real path works on absolute paths 2' '
-       nopath="hopefully-absent-path" &&
        # Find an existing top-level directory for the remaining tests:
        d=$(pwd -P | sed -e "s|^\([^/]*/[^/]*\)/.*|\1|") &&
-       test "$d" = "$(test-tool path-utils real_path "$d")" &&
-       test "$d/$nopath" = "$(test-tool path-utils real_path "$d/$nopath")"
+       echo "$d" >expect &&
+       test-tool path-utils real_path "$d" >actual &&
+       test_cmp expect actual &&
+
+       nopath="hopefully-absent-path" &&
+       echo "$d/$nopath" >expect &&
+       test-tool path-utils real_path "$d/$nopath" >actual &&
+       test_cmp expect actual
 '
 
 test_expect_success POSIX 'real path removes extra leading slashes' '
+       echo "/" >expect &&
+       test-tool path-utils real_path "///" >actual &&
+       test_cmp expect actual &&
+
        nopath="hopefully-absent-path" &&
-       test "/" = "$(test-tool path-utils real_path "///")" &&
-       test "/$nopath" = "$(test-tool path-utils real_path "///$nopath")" &&
+       echo "/$nopath" >expect &&
+       test-tool path-utils real_path "///$nopath" >actual &&
+       test_cmp expect actual &&
+
        # Find an existing top-level directory for the remaining tests:
        d=$(pwd -P | sed -e "s|^\([^/]*/[^/]*\)/.*|\1|") &&
-       test "$d" = "$(test-tool path-utils real_path "//$d")" &&
-       test "$d/$nopath" = "$(test-tool path-utils real_path "//$d/$nopath")"
+       echo "$d" >expect &&
+       test-tool path-utils real_path "//$d" >actual &&
+       test_cmp expect actual &&
+
+       echo "$d/$nopath" >expect &&
+       test-tool path-utils real_path "//$d/$nopath" >actual &&
+       test_cmp expect actual
 '
 
 test_expect_success 'real path removes other extra slashes' '
-       nopath="hopefully-absent-path" &&
        # Find an existing top-level directory for the remaining tests:
        d=$(pwd -P | sed -e "s|^\([^/]*/[^/]*\)/.*|\1|") &&
-       test "$d" = "$(test-tool path-utils real_path "$d///")" &&
-       test "$d/$nopath" = "$(test-tool path-utils real_path "$d///$nopath")"
+       echo "$d" >expect &&
+       test-tool path-utils real_path "$d///" >actual &&
+       test_cmp expect actual &&
+
+       nopath="hopefully-absent-path" &&
+       echo "$d/$nopath" >expect &&
+       test-tool path-utils real_path "$d///$nopath" >actual &&
+       test_cmp expect actual
 '
 
 test_expect_success SYMLINKS 'real path works on symlinks' '
@@ -227,19 +264,29 @@ test_expect_success SYMLINKS 'real path works on symlinks' '
        mkdir third &&
        dir="$(cd .git && pwd -P)" &&
        dir2=third/../second/other/.git &&
-       test "$dir" = "$(test-tool path-utils real_path $dir2)" &&
+       echo "$dir" >expect &&
+       test-tool path-utils real_path $dir2 >actual &&
+       test_cmp expect actual &&
        file="$dir"/index &&
-       test "$file" = "$(test-tool path-utils real_path $dir2/index)" &&
+       echo "$file" >expect &&
+       test-tool path-utils real_path $dir2/index >actual &&
+       test_cmp expect actual &&
        basename=blub &&
-       test "$dir/$basename" = "$(cd .git && test-tool path-utils real_path "$basename")" &&
+       echo "$dir/$basename" >expect &&
+       test-tool -C .git path-utils real_path "$basename" >actual &&
+       test_cmp expect actual &&
        ln -s ../first/file .git/syml &&
        sym="$(cd first && pwd -P)"/file &&
-       test "$sym" = "$(test-tool path-utils real_path "$dir2/syml")"
+       echo "$sym" >expect &&
+       test-tool path-utils real_path "$dir2/syml" >actual &&
+       test_cmp expect actual
 '
 
 test_expect_success SYMLINKS 'prefix_path works with absolute paths to work tree symlinks' '
        ln -s target symlink &&
-       test "$(test-tool path-utils prefix_path prefix "$(pwd)/symlink")" = "symlink"
+       echo "symlink" >expect &&
+       test-tool path-utils prefix_path prefix "$(pwd)/symlink" >actual &&
+       test_cmp expect actual
 '
 
 test_expect_success 'prefix_path works with only absolute path to work tree' '
@@ -255,7 +302,10 @@ test_expect_success 'prefix_path rejects absolute path to dir with same beginnin
 test_expect_success SYMLINKS 'prefix_path works with absolute path to a symlink to work tree having  same beginning as work tree' '
        git init repo &&
        ln -s repo repolink &&
-       test "a" = "$(cd repo && test-tool path-utils prefix_path prefix "$(pwd)/../repolink/a")"
+       echo "a" >expect &&
+       repo_path="$(cd repo && pwd)" &&
+       test-tool -C repo path-utils prefix_path prefix "$repo_path/../repolink/a" >actual &&
+       test_cmp expect actual
 '
 
 relative_path /foo/a/b/c/      /foo/a/b/       c/
index a16cc3d298357be89e58514db83c1d3f04b3ad4d..70a3223f2199b06833166863e58489ba0f632e59 100755 (executable)
@@ -12,7 +12,9 @@ test_expect_success 'branch -d @{-1}' '
        test_commit A &&
        git checkout -b junk &&
        git checkout - &&
-       test "$(git symbolic-ref HEAD)" = refs/heads/main &&
+       echo refs/heads/main >expect &&
+       git symbolic-ref HEAD >actual &&
+       test_cmp expect actual &&
        git branch -d @{-1} &&
        test_must_fail git rev-parse --verify refs/heads/junk
 '
@@ -21,7 +23,9 @@ test_expect_success 'branch -d @{-12} when there is not enough switches yet' '
        git reflog expire --expire=now &&
        git checkout -b junk2 &&
        git checkout - &&
-       test "$(git symbolic-ref HEAD)" = refs/heads/main &&
+       echo refs/heads/main >expect &&
+       git symbolic-ref HEAD >actual &&
+       test_cmp expect actual &&
        test_must_fail git branch -d @{-12} &&
        git rev-parse --verify refs/heads/main
 '
index be23be30c768304d35d79cf6905d576293125801..c7745e1bf69e910c2d66a61bb8bef36b45473a56 100755 (executable)
@@ -33,7 +33,8 @@ test_expect_success 'symbolic-ref refuses non-ref for HEAD' '
 reset_to_sane
 
 test_expect_success 'symbolic-ref refuses bare sha1' '
-       test_must_fail git symbolic-ref HEAD $(git rev-parse HEAD)
+       rev=$(git rev-parse HEAD) &&
+       test_must_fail git symbolic-ref HEAD "$rev"
 '
 
 reset_to_sane
index 0fafcf9dde385f2c2bac7fbd846098908a72f09b..c1679e31d8afca409323484d588bf63b264f45f2 100755 (executable)
@@ -6,8 +6,12 @@ TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
 test_prefix() {
-       test_expect_success "$1" \
-       "test '$2' = \"\$(git rev-parse --show-prefix)\""
+       local expect="$2" &&
+       test_expect_success "$1: git rev-parse --show-prefix is '$2'" '
+               echo "$expect" >expect &&
+               git rev-parse --show-prefix >actual &&
+               test_cmp expect actual
+       '
 }
 
 test_fail() {
index 112682a45a1df3d5c19eab03ec79c1202d2cab71..67d18cfa104b867bfdd2004df0bc8c9e305cfdc9 100755 (executable)
@@ -22,8 +22,10 @@ test_expect_success \
 git checkout-index symlink &&
 test -f symlink'
 
-test_expect_success \
-'the file must be the blob we added during the setup' '
-test "$(git hash-object -t blob symlink)" = $l'
+test_expect_success 'the file must be the blob we added during the setup' '
+       echo "$l" >expect &&
+       git hash-object -t blob symlink >actual &&
+       test_cmp expect actual
+'
 
 test_done
index 5a169b68d6af4d3db62e88dcdc4fb765ee5232a6..5a8a48287c18bfb3518a90677c02a13bb1ac23f3 100755 (executable)
@@ -245,9 +245,13 @@ test_expect_success 'git branch -M baz bam should succeed within a worktree in w
        (
                cd bazdir &&
                git branch -M baz bam &&
-               test $(git rev-parse --abbrev-ref HEAD) = bam
+               echo bam >expect &&
+               git rev-parse --abbrev-ref HEAD >actual &&
+               test_cmp expect actual
        ) &&
-       test $(git rev-parse --abbrev-ref HEAD) = bam &&
+       echo bam >expect &&
+       git rev-parse --abbrev-ref HEAD >actual &&
+       test_cmp expect actual &&
        rm -r bazdir &&
        git worktree prune
 '
index 51afbd7b24a10c247520ba2f9be702da57f83afd..82dd768944fa5d566f32d7076ad2e36bd0f53cf7 100755 (executable)
@@ -106,24 +106,32 @@ test_expect_success '.gitignore test setup' '
 
 test_expect_success '.gitignore is honored' '
        git add . &&
-       ! (git ls-files | grep "\\.ig")
+       git ls-files >files &&
+       sed -n "/\\.ig/p" <files >actual &&
+       test_must_be_empty actual
 '
 
 test_expect_success 'error out when attempting to add ignored ones without -f' '
        test_must_fail git add a.?? &&
-       ! (git ls-files | grep "\\.ig")
+       git ls-files >files &&
+       sed -n "/\\.ig/p" <files >actual &&
+       test_must_be_empty actual
 '
 
 test_expect_success 'error out when attempting to add ignored ones without -f' '
        test_must_fail git add d.?? &&
-       ! (git ls-files | grep "\\.ig")
+       git ls-files >files &&
+       sed -n "/\\.ig/p" <files >actual &&
+       test_must_be_empty actual
 '
 
 test_expect_success 'error out when attempting to add ignored ones but add others' '
        touch a.if &&
        test_must_fail git add a.?? &&
-       ! (git ls-files | grep "\\.ig") &&
-       (git ls-files | grep a.if)
+       git ls-files >files &&
+       sed -n "/\\.ig/p" <files >actual &&
+       test_must_be_empty actual &&
+       grep a.if files
 '
 
 test_expect_success 'add ignored ones with -f' '
index 3a99837d9b15f78f2f8e034d4fdea9a0b88441ed..032b61ce212758802d58db34512d00ff65d5bda2 100755 (executable)
@@ -311,9 +311,11 @@ test_expect_success FILEMODE 'stage mode and hunk' '
        echo content >>file &&
        chmod +x file &&
        printf "y\\ny\\n" | git add -p &&
-       git diff --cached file | grep "new mode" &&
-       git diff --cached file | grep "+content" &&
-       test -z "$(git diff file)"
+       git diff --cached file >out &&
+       grep "new mode" out &&
+       grep "+content" out &&
+       git diff file >out &&
+       test_must_be_empty out
 '
 
 # end of tests disabled when filemode is not usable
index 394bc60cb8eea153e534b9fc887ae37b0e2abf36..cc5496e28fd0bcbf32badb583272c464ec88fae8 100755 (executable)
@@ -79,7 +79,9 @@ test_expect_success SYMLINKS 'pushing from symlinked subdir' '
                git commit -m push ./file &&
                git push
        ) &&
-       test push = $(git show HEAD:subdir/file)
+       echo push >expect &&
+       git show HEAD:subdir/file >actual &&
+       test_cmp expect actual
 '
 
 test_done
index 38b850c10ef8cddeb790ed276209bb5019439eae..1d7b1abda1a4870971efb8408c11a4dde2e7564e 100755 (executable)
@@ -15,8 +15,12 @@ test_expect_success 'preparing origin repository' '
        : >file && git add . && git commit -m1 &&
        git clone --bare . a.git &&
        git clone --bare . x &&
-       test "$(cd a.git && git config --bool core.bare)" = true &&
-       test "$(cd x && git config --bool core.bare)" = true &&
+       echo true >expect &&
+       git -C a.git config --bool core.bare >actual &&
+       test_cmp expect actual &&
+       echo true >expect &&
+       git -C x config --bool core.bare >actual &&
+       test_cmp expect actual &&
        git bundle create b1.bundle --all &&
        git bundle create b2.bundle main &&
        mkdir dir &&
@@ -29,7 +33,9 @@ test_expect_success 'preparing origin repository' '
 test_expect_success 'local clone without .git suffix' '
        git clone -l -s a b &&
        (cd b &&
-       test "$(git config --bool core.bare)" = false &&
+       echo false >expect &&
+       git config --bool core.bare >actual &&
+       test_cmp expect actual &&
        git fetch)
 '
 
index b19792b326901bbb8c00c20f07dbb38b322a9e74..2b3c363078bc06219c8b5c16b02f331b447f5102 100755 (executable)
@@ -56,12 +56,15 @@ chmod a+x fake-editor.sh
 
 test_expect_success 'interactive rebase with a dirty submodule' '
 
-       test submodule = $(git diff --name-only) &&
+       echo submodule >expect &&
+       git diff --name-only >actual &&
+       test_cmp expect actual &&
        HEAD=$(git rev-parse HEAD) &&
        GIT_EDITOR="\"$(pwd)/fake-editor.sh\"" EDITOR_TEXT="pick $HEAD" \
                git rebase -i HEAD^ &&
-       test submodule = $(git diff --name-only)
-
+       echo submodule >expect &&
+       git diff --name-only >actual &&
+       test_cmp expect actual
 '
 
 test_expect_success 'rebase with dirty file and submodule fails' '
@@ -83,11 +86,19 @@ test_expect_success 'stash with a dirty submodule' '
        CURRENT=$(cd submodule && git rev-parse HEAD) &&
        git stash &&
        test new != $(cat file) &&
-       test submodule = $(git diff --name-only) &&
-       test $CURRENT = $(cd submodule && git rev-parse HEAD) &&
+       echo submodule >expect &&
+       git diff --name-only >actual &&
+       test_cmp expect actual &&
+
+       echo "$CURRENT" >expect &&
+       git -C submodule rev-parse HEAD >actual &&
+       test_cmp expect actual &&
+
        git stash apply &&
        test new = $(cat file) &&
-       test $CURRENT = $(cd submodule && git rev-parse HEAD)
+       echo "$CURRENT" >expect &&
+       git -C submodule rev-parse HEAD >actual &&
+       test_cmp expect actual
 
 '
 
index 07ca46fb0d539c62c7dcbe066b8c95e550d0b3a3..d1255228d5ffaa2b7b7333000e3e39468ee94bb1 100755 (executable)
@@ -102,7 +102,9 @@ test_expect_success 'setup: commit-msg hook that always fails' '
 '
 
 commit_msg_is () {
-       test "$(git log --pretty=format:%s%b -1)" = "$1"
+       printf "%s" "$1" >expect &&
+       git log --pretty=format:%s%b -1 >actual &&
+       test_cmp expect actual
 }
 
 test_expect_success 'with failing hook' '
index f2ce14e9071c0a3b071f53186c2d311103883443..2d38a16480e82c0441075e0e54ffe8454b413cb2 100755 (executable)
@@ -10,7 +10,8 @@ test_expect_success 'race to create orphan commit' '
        test_must_fail env EDITOR=./hare-editor git commit --allow-empty -m tortoise -e &&
        git show -s --pretty=format:%s >subject &&
        grep hare subject &&
-       test -z "$(git show -s --pretty=format:%P)"
+       git show -s --pretty=format:%P >out &&
+       test_must_be_empty out
 '
 
 test_expect_success 'race to create non-orphan commit' '
index 8eded6ab274fafe636151b7903bae3351a27df5c..39d6d713ecbe05e9638f8f6ee3f79ff49628b2cf 100755 (executable)
@@ -1001,7 +1001,9 @@ test_expect_success 'log --committer does not search in timestamp' '
 test_expect_success 'grep with CE_VALID file' '
        git update-index --assume-unchanged t/t &&
        rm t/t &&
-       test "$(git grep test)" = "t/t:test" &&
+       echo "t/t:test" >expect &&
+       git grep test >actual &&
+       test_cmp expect actual &&
        git update-index --no-assume-unchanged t/t &&
        git checkout t/t
 '