Instead of 'test_must_fail git cmd... 2>output.err', which redirects
the standard error of the 'test_must_fail' helper function as well,
causing various issues as discussed in the previous patch.

With this patch t1404 succeeds when run with '-x', even with shells
not supporting $BASH_XTRACEFD.

Signed-off-by: SZEDER Gábor <szeder....@gmail.com>
---
 t/t1404-update-ref-errors.sh | 46 ++++++++++++++++++++++----------------------
 1 file changed, 23 insertions(+), 23 deletions(-)

diff --git a/t/t1404-update-ref-errors.sh b/t/t1404-update-ref-errors.sh
index 3a887b5113..91250bc6a0 100755
--- a/t/t1404-update-ref-errors.sh
+++ b/t/t1404-update-ref-errors.sh
@@ -26,7 +26,7 @@ test_update_rejected () {
                git pack-refs --all
        fi &&
        printf "create $prefix/%s $C\n" $create >input &&
-       test_must_fail git update-ref --stdin <input 2>output.err &&
+       test_must_fail stderr=output.err git update-ref --stdin <input &&
        grep -F "$error" output.err &&
        git for-each-ref $prefix >actual &&
        test_cmp unchanged actual
@@ -102,7 +102,7 @@ df_test() {
        else
                printf "%s\n" "delete $delname" "create $addname $D"
        fi >commands &&
-       test_must_fail git update-ref --stdin <commands 2>output.err &&
+       test_must_fail stderr=output.err git update-ref --stdin <commands &&
        test_cmp expected-err output.err &&
        printf "%s\n" "$C $delref" >expected-refs &&
        git for-each-ref --format="%(objectname) %(refname)" $prefix/r 
>actual-refs &&
@@ -337,7 +337,7 @@ test_expect_success 'missing old value blocks update' '
        fatal: cannot lock ref $Q$prefix/foo$Q: unable to resolve reference 
$Q$prefix/foo$Q
        EOF
        printf "%s\n" "update $prefix/foo $E $D" |
-       test_must_fail git update-ref --stdin 2>output.err &&
+       test_must_fail stderr=output.err git update-ref --stdin &&
        test_cmp expected output.err
 '
 
@@ -348,7 +348,7 @@ test_expect_success 'incorrect old value blocks update' '
        fatal: cannot lock ref $Q$prefix/foo$Q: is at $C but expected $D
        EOF
        printf "%s\n" "update $prefix/foo $E $D" |
-       test_must_fail git update-ref --stdin 2>output.err &&
+       test_must_fail stderr=output.err git update-ref --stdin &&
        test_cmp expected output.err
 '
 
@@ -359,7 +359,7 @@ test_expect_success 'existing old value blocks create' '
        fatal: cannot lock ref $Q$prefix/foo$Q: reference already exists
        EOF
        printf "%s\n" "create $prefix/foo $E" |
-       test_must_fail git update-ref --stdin 2>output.err &&
+       test_must_fail stderr=output.err git update-ref --stdin &&
        test_cmp expected output.err
 '
 
@@ -370,7 +370,7 @@ test_expect_success 'incorrect old value blocks delete' '
        fatal: cannot lock ref $Q$prefix/foo$Q: is at $C but expected $D
        EOF
        printf "%s\n" "delete $prefix/foo $D" |
-       test_must_fail git update-ref --stdin 2>output.err &&
+       test_must_fail stderr=output.err git update-ref --stdin &&
        test_cmp expected output.err
 '
 
@@ -381,7 +381,7 @@ test_expect_success 'missing old value blocks indirect 
update' '
        fatal: cannot lock ref $Q$prefix/symref$Q: unable to resolve reference 
$Q$prefix/foo$Q
        EOF
        printf "%s\n" "update $prefix/symref $E $D" |
-       test_must_fail git update-ref --stdin 2>output.err &&
+       test_must_fail stderr=output.err git update-ref --stdin &&
        test_cmp expected output.err
 '
 
@@ -393,7 +393,7 @@ test_expect_success 'incorrect old value blocks indirect 
update' '
        fatal: cannot lock ref $Q$prefix/symref$Q: is at $C but expected $D
        EOF
        printf "%s\n" "update $prefix/symref $E $D" |
-       test_must_fail git update-ref --stdin 2>output.err &&
+       test_must_fail stderr=output.err git update-ref --stdin &&
        test_cmp expected output.err
 '
 
@@ -405,7 +405,7 @@ test_expect_success 'existing old value blocks indirect 
create' '
        fatal: cannot lock ref $Q$prefix/symref$Q: reference already exists
        EOF
        printf "%s\n" "create $prefix/symref $E" |
-       test_must_fail git update-ref --stdin 2>output.err &&
+       test_must_fail stderr=output.err git update-ref --stdin &&
        test_cmp expected output.err
 '
 
@@ -417,7 +417,7 @@ test_expect_success 'incorrect old value blocks indirect 
delete' '
        fatal: cannot lock ref $Q$prefix/symref$Q: is at $C but expected $D
        EOF
        printf "%s\n" "delete $prefix/symref $D" |
-       test_must_fail git update-ref --stdin 2>output.err &&
+       test_must_fail stderr=output.err git update-ref --stdin &&
        test_cmp expected output.err
 '
 
@@ -428,7 +428,7 @@ test_expect_success 'missing old value blocks indirect 
no-deref update' '
        fatal: cannot lock ref $Q$prefix/symref$Q: reference is missing but 
expected $D
        EOF
        printf "%s\n" "option no-deref" "update $prefix/symref $E $D" |
-       test_must_fail git update-ref --stdin 2>output.err &&
+       test_must_fail stderr=output.err git update-ref --stdin &&
        test_cmp expected output.err
 '
 
@@ -440,7 +440,7 @@ test_expect_success 'incorrect old value blocks indirect 
no-deref update' '
        fatal: cannot lock ref $Q$prefix/symref$Q: is at $C but expected $D
        EOF
        printf "%s\n" "option no-deref" "update $prefix/symref $E $D" |
-       test_must_fail git update-ref --stdin 2>output.err &&
+       test_must_fail stderr=output.err git update-ref --stdin &&
        test_cmp expected output.err
 '
 
@@ -452,7 +452,7 @@ test_expect_success 'existing old value blocks indirect 
no-deref create' '
        fatal: cannot lock ref $Q$prefix/symref$Q: reference already exists
        EOF
        printf "%s\n" "option no-deref" "create $prefix/symref $E" |
-       test_must_fail git update-ref --stdin 2>output.err &&
+       test_must_fail stderr=output.err git update-ref --stdin &&
        test_cmp expected output.err
 '
 
@@ -464,7 +464,7 @@ test_expect_success 'incorrect old value blocks indirect 
no-deref delete' '
        fatal: cannot lock ref $Q$prefix/symref$Q: is at $C but expected $D
        EOF
        printf "%s\n" "option no-deref" "delete $prefix/symref $D" |
-       test_must_fail git update-ref --stdin 2>output.err &&
+       test_must_fail stderr=output.err git update-ref --stdin &&
        test_cmp expected output.err
 '
 
@@ -477,13 +477,13 @@ test_expect_success 'non-empty directory blocks create' '
        fatal: cannot lock ref $Q$prefix/foo$Q: there is a non-empty directory 
$Q.git/$prefix/foo$Q blocking reference $Q$prefix/foo$Q
        EOF
        printf "%s\n" "update $prefix/foo $C" |
-       test_must_fail git update-ref --stdin 2>output.err &&
+       test_must_fail stderr=output.err git update-ref --stdin &&
        test_cmp expected output.err &&
        cat >expected <<-EOF &&
        fatal: cannot lock ref $Q$prefix/foo$Q: unable to resolve reference 
$Q$prefix/foo$Q
        EOF
        printf "%s\n" "update $prefix/foo $D $C" |
-       test_must_fail git update-ref --stdin 2>output.err &&
+       test_must_fail stderr=output.err git update-ref --stdin &&
        test_cmp expected output.err
 '
 
@@ -496,13 +496,13 @@ test_expect_success 'broken reference blocks create' '
        fatal: cannot lock ref $Q$prefix/foo$Q: unable to resolve reference 
$Q$prefix/foo$Q: reference broken
        EOF
        printf "%s\n" "update $prefix/foo $C" |
-       test_must_fail git update-ref --stdin 2>output.err &&
+       test_must_fail stderr=output.err git update-ref --stdin &&
        test_cmp expected output.err &&
        cat >expected <<-EOF &&
        fatal: cannot lock ref $Q$prefix/foo$Q: unable to resolve reference 
$Q$prefix/foo$Q: reference broken
        EOF
        printf "%s\n" "update $prefix/foo $D $C" |
-       test_must_fail git update-ref --stdin 2>output.err &&
+       test_must_fail stderr=output.err git update-ref --stdin &&
        test_cmp expected output.err
 '
 
@@ -516,13 +516,13 @@ test_expect_success 'non-empty directory blocks indirect 
create' '
        fatal: cannot lock ref $Q$prefix/symref$Q: there is a non-empty 
directory $Q.git/$prefix/foo$Q blocking reference $Q$prefix/foo$Q
        EOF
        printf "%s\n" "update $prefix/symref $C" |
-       test_must_fail git update-ref --stdin 2>output.err &&
+       test_must_fail stderr=output.err git update-ref --stdin &&
        test_cmp expected output.err &&
        cat >expected <<-EOF &&
        fatal: cannot lock ref $Q$prefix/symref$Q: unable to resolve reference 
$Q$prefix/foo$Q
        EOF
        printf "%s\n" "update $prefix/symref $D $C" |
-       test_must_fail git update-ref --stdin 2>output.err &&
+       test_must_fail stderr=output.err git update-ref --stdin &&
        test_cmp expected output.err
 '
 
@@ -535,13 +535,13 @@ test_expect_success 'broken reference blocks indirect 
create' '
        fatal: cannot lock ref $Q$prefix/symref$Q: unable to resolve reference 
$Q$prefix/foo$Q: reference broken
        EOF
        printf "%s\n" "update $prefix/symref $C" |
-       test_must_fail git update-ref --stdin 2>output.err &&
+       test_must_fail stderr=output.err git update-ref --stdin &&
        test_cmp expected output.err &&
        cat >expected <<-EOF &&
        fatal: cannot lock ref $Q$prefix/symref$Q: unable to resolve reference 
$Q$prefix/foo$Q: reference broken
        EOF
        printf "%s\n" "update $prefix/symref $D $C" |
-       test_must_fail git update-ref --stdin 2>output.err &&
+       test_must_fail stderr=output.err git update-ref --stdin &&
        test_cmp expected output.err
 '
 
@@ -612,7 +612,7 @@ test_expect_success 'delete fails cleanly if packed-refs 
file is locked' '
        # Now try to delete it while the `packed-refs` lock is held:
        : >.git/packed-refs.lock &&
        test_when_finished "rm -f .git/packed-refs.lock" &&
-       test_must_fail git update-ref -d $prefix/foo >out 2>err &&
+       test_must_fail stderr=err git update-ref -d $prefix/foo >out &&
        git for-each-ref $prefix >actual &&
        test_i18ngrep "Unable to create $Q.*packed-refs.lock$Q: File exists" 
err &&
        test_cmp unchanged actual
-- 
2.16.1.180.g07550b0b1b

Reply via email to