From 2c9e125b2727c33dccdba1b2a46f462b77e10bed Mon Sep 17 00:00:00 2001 From: Denton Liu Date: Tue, 12 Nov 2019 15:07:45 -0800 Subject: 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 Signed-off-by: Junio C Hamano --- t/t3501-revert-cherry-pick.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/t3501-revert-cherry-pick.sh') diff --git a/t/t3501-revert-cherry-pick.sh b/t/t3501-revert-cherry-pick.sh index d1c68af8c5..1c51a9131d 100755 --- a/t/t3501-revert-cherry-pick.sh +++ b/t/t3501-revert-cherry-pick.sh @@ -106,7 +106,7 @@ test_expect_success 'cherry-pick on unborn branch' ' rm -rf * && git cherry-pick initial && git diff --quiet initial && - ! test_cmp_rev initial HEAD + test_cmp_rev ! initial HEAD ' test_expect_success 'cherry-pick "-" to pick from previous branch' ' -- cgit v1.2.3 From f670adb49bd6762ec497fe612e29a51dbe3fcbed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scharfe?= Date: Wed, 18 Dec 2019 19:12:00 +0100 Subject: t3501: don't create unused file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The file "out" became unused with fd53b7ffd1 (merge-recursive: improve add_cacheinfo error handling, 2018-04-19); get rid of it. Signed-off-by: René Scharfe Signed-off-by: Junio C Hamano --- t/t3501-revert-cherry-pick.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/t3501-revert-cherry-pick.sh') diff --git a/t/t3501-revert-cherry-pick.sh b/t/t3501-revert-cherry-pick.sh index d1c68af8c5..3470e45d5d 100755 --- a/t/t3501-revert-cherry-pick.sh +++ b/t/t3501-revert-cherry-pick.sh @@ -150,7 +150,7 @@ test_expect_success 'cherry-pick works with dirty renamed file' ' test_tick && git commit -m renamed && echo modified >renamed && - git cherry-pick refs/heads/unrelated >out && + git cherry-pick refs/heads/unrelated && test $(git rev-parse :0:renamed) = $(git rev-parse HEAD~2:to-rename.t) && grep -q "^modified$" renamed ' -- cgit v1.2.3