]> git.ipfire.org Git - thirdparty/git.git/commit - t/test-lib-functions.sh
t: teach test_cmp_rev to accept ! for not-equals
authorDenton Liu <liu.denton@gmail.com>
Tue, 12 Nov 2019 23:07:45 +0000 (15:07 -0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 21 Nov 2019 00:41:51 +0000 (09:41 +0900)
commit2c9e125b2727c33dccdba1b2a46f462b77e10bed
treeb9c9513330c4962c4e945c80457683c09892971c
parent8cb7980382855f9f696924fec70ed88ea6895030
t: teach test_cmp_rev to accept ! for not-equals

In the case where we are using test_cmp_rev() to report not-equals, we
write `! test_cmp_rev`. However, since test_cmp_rev() contains

r1=$(git rev-parse --verify "$1") &&
r2=$(git rev-parse --verify "$2") &&

`! test_cmp_rev` will succeed if any of the rev-parses fail. This
behavior is not desired. We want the rev-parses to _always_ be
successful.

Rewrite test_cmp_rev() to optionally accept "!" as the first argument to
do a not-equals comparison. Rewrite `! test_cmp_rev` to `test_cmp_rev !`
in all tests to take advantage of this new functionality.

Also, rewrite the rev-parse logic to end with a `|| return 1` instead of
&&-chaining into the rev-comparison logic. This makes it obvious to
future readers that we explicitly intend on returning early if either of
the rev-parses fail.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t2400-worktree-add.sh
t/t3400-rebase.sh
t/t3421-rebase-topology-linear.sh
t/t3430-rebase-merges.sh
t/t3432-rebase-fast-forward.sh
t/t3501-revert-cherry-pick.sh
t/t3508-cherry-pick-many-commits.sh
t/test-lib-functions.sh