Skip to content

Commit ec8f87b

Browse files
Denton-Lgitster
authored andcommitted
t5801: teach compare_refs() to accept !
Before, testing if two refs weren't equal with compare_refs() was done with `test_must_fail compare_refs`. This was wrong for two reasons. First, test_must_fail should only be used on git commands. Second, negating the error code is a little heavy-handed since in the case where one of the git invocations within compare_refs() fails, we will report success, even though it failed at an unexpected point. Teach compare_refs() to accept `!` as the first argument which would _only_ negate the test_cmp()'s return code. Signed-off-by: Denton Liu <liu.denton@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 3d18097 commit ec8f87b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

t/t5801-remote-helpers.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,15 @@ test_description='Test remote-helper import and export commands'
1111
PATH="$TEST_DIRECTORY/t5801:$PATH"
1212

1313
compare_refs() {
14+
fail= &&
15+
if test "x$1" = 'x!'
16+
then
17+
fail='!' &&
18+
shift
19+
fi &&
1420
git --git-dir="$1/.git" rev-parse --verify $2 >expect &&
1521
git --git-dir="$3/.git" rev-parse --verify $4 >actual &&
16-
test_cmp expect actual
22+
eval $fail test_cmp expect actual
1723
}
1824

1925
test_expect_success 'setup repository' '
@@ -189,7 +195,7 @@ test_expect_success GPG 'push signed tag' '
189195
git push origin signed-tag
190196
) &&
191197
compare_refs local signed-tag^{} server signed-tag^{} &&
192-
test_must_fail compare_refs local signed-tag server signed-tag
198+
compare_refs ! local signed-tag server signed-tag
193199
'
194200

195201
test_expect_success GPG 'push signed tag with signed-tags capability' '

0 commit comments

Comments
 (0)