Skip to content

Commit c3a4456

Browse files
szedergitster
authored andcommitted
t1507-rev-parse-upstream: don't check the stderr of a shell function
Three tests in 't1507-rev-parse-upstream.sh' fail when the test script is run with '-x' tracing (and using a shell other than a Bash version supporting BASH_XTRACEFD). The reason for those failures is that the tests check the stderr of the function 'error_message', which includes the trace of commands executed in that function as well, throwing off the comparison with the expected output. Save stderr of 'git rev-parse' only instead of the whole function, so it remains free from tracing output. After this change t1507 passes with '-x', even when running with /bin/sh. Signed-off-by: SZEDER Gábor <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5fc98e7 commit c3a4456

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

t/t1507-rev-parse-upstream.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ commit_subject () {
4242

4343
error_message () {
4444
(cd clone &&
45-
test_must_fail git rev-parse --verify "$@")
45+
test_must_fail git rev-parse --verify "$@" 2>../error)
4646
}
4747

4848
test_expect_success '@{upstream} resolves to correct full name' '
@@ -159,8 +159,8 @@ test_expect_success 'branch@{u} error message when no upstream' '
159159
cat >expect <<-EOF &&
160160
fatal: no upstream configured for branch ${sq}non-tracking${sq}
161161
EOF
162-
error_message non-tracking@{u} 2>actual &&
163-
test_i18ncmp expect actual
162+
error_message non-tracking@{u} &&
163+
test_i18ncmp expect error
164164
'
165165

166166
test_expect_success '@{u} error message when no upstream' '
@@ -175,8 +175,8 @@ test_expect_success 'branch@{u} error message with misspelt branch' '
175175
cat >expect <<-EOF &&
176176
fatal: no such branch: ${sq}no-such-branch${sq}
177177
EOF
178-
error_message no-such-branch@{u} 2>actual &&
179-
test_i18ncmp expect actual
178+
error_message no-such-branch@{u} &&
179+
test_i18ncmp expect error
180180
'
181181

182182
test_expect_success '@{u} error message when not on a branch' '
@@ -192,8 +192,8 @@ test_expect_success 'branch@{u} error message if upstream branch not fetched' '
192192
cat >expect <<-EOF &&
193193
fatal: upstream branch ${sq}refs/heads/side${sq} not stored as a remote-tracking branch
194194
EOF
195-
error_message bad-upstream@{u} 2>actual &&
196-
test_i18ncmp expect actual
195+
error_message bad-upstream@{u} &&
196+
test_i18ncmp expect error
197197
'
198198

199199
test_expect_success 'pull works when tracking a local branch' '

0 commit comments

Comments
 (0)