All of lore.kernel.org
 help / color / mirror / Atom feed
From: Denton Liu <liu.denton@gmail.com>
To: Git Mailing List <git@vger.kernel.org>
Cc: "Eric Sunshine" <sunshine@sunshineco.com>,
	"Johannes Sixt" <j6t@kdbg.org>,
	"SZEDER Gábor" <szeder.dev@gmail.com>,
	"Junio C Hamano" <gitster@pobox.com>
Subject: [PATCH v4 09/14] t5520: use test_cmp_rev where possible
Date: Thu, 7 Nov 2019 10:51:39 -0800	[thread overview]
Message-ID: <fdde875363ed67c208d15cbc8bd96d5f9f476152.1573152599.git.liu.denton@gmail.com> (raw)
In-Reply-To: <cover.1573152598.git.liu.denton@gmail.com>

In case an invocation of `git rev-list` fails within the subshell, the
failure will be masked. Remove the subshell and use test_cmp_rev() so
that failures can be discovered.

This change was done with the following sed expressions:

	s/test "$(git rev-parse.* \([^)]*\))" = "$(git rev-parse \([^)]*\))"/test_cmp_rev \1 \2/
	s/test \([^ ]*\) = "$(git rev-parse.* \([^)]*\))"/test_cmp_rev \1 \2/
	s/test "$(git rev-parse.* \([^)]*\))" != "$(git rev-parse.* \([^)]*\))"/test_cmp_rev ! \1 \2/
	s/test \([^ ]*\) != "$(git rev-parse.* \([^)]*\))"/test_cmp_rev ! \1 \2/

Signed-off-by: Denton Liu <liu.denton@gmail.com>
---
 t/t5520-pull.sh | 50 ++++++++++++++++++++++++-------------------------
 1 file changed, 25 insertions(+), 25 deletions(-)

diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh
index 18225d8430..1af6ea06ee 100755
--- a/t/t5520-pull.sh
+++ b/t/t5520-pull.sh
@@ -230,7 +230,7 @@ test_expect_success 'fast-forwards working tree if branch head is updated' '
 	git pull . second:third 2>err &&
 	test_i18ngrep "fetch updated the current branch head" err &&
 	test "$(cat file)" = modified &&
-	test "$(git rev-parse third)" = "$(git rev-parse second)"
+	test_cmp_rev third second
 '
 
 test_expect_success 'fast-forward fails with conflicting work tree' '
@@ -241,7 +241,7 @@ test_expect_success 'fast-forward fails with conflicting work tree' '
 	test_must_fail git pull . second:third 2>err &&
 	test_i18ngrep "Cannot fast-forward your working tree" err &&
 	test "$(cat file)" = conflict &&
-	test "$(git rev-parse third)" = "$(git rev-parse second)"
+	test_cmp_rev third second
 '
 
 test_expect_success '--rebase' '
@@ -254,7 +254,7 @@ test_expect_success '--rebase' '
 	git commit -m "new file" &&
 	git tag before-rebase &&
 	git pull --rebase . copy &&
-	test "$(git rev-parse HEAD^)" = "$(git rev-parse copy)" &&
+	test_cmp_rev HEAD^ copy &&
 	test new = "$(git show HEAD:file2)"
 '
 
@@ -266,7 +266,7 @@ test_expect_success '--rebase fast forward' '
 
 	git checkout to-rebase &&
 	git pull --rebase . ff &&
-	test "$(git rev-parse HEAD)" = "$(git rev-parse ff)" &&
+	test_cmp_rev HEAD ff &&
 
 	# The above only validates the result.  Did we actually bypass rebase?
 	git reflog -1 >reflog.actual &&
@@ -290,7 +290,7 @@ test_expect_success '--rebase --autostash fast forward' '
 	git checkout behind &&
 	echo dirty >file &&
 	git pull --rebase --autostash . to-rebase-ff &&
-	test "$(git rev-parse HEAD)" = "$(git rev-parse to-rebase-ff)"
+	test_cmp_rev HEAD to-rebase-ff
 '
 
 test_expect_success '--rebase with conflicts shows advice' '
@@ -328,7 +328,7 @@ test_expect_success 'failed --rebase shows advice' '
 test_expect_success '--rebase fails with multiple branches' '
 	git reset --hard before-rebase &&
 	test_must_fail git pull --rebase . copy master 2>err &&
-	test "$(git rev-parse HEAD)" = "$(git rev-parse before-rebase)" &&
+	test_cmp_rev HEAD before-rebase &&
 	test_i18ngrep "Cannot rebase onto multiple branches" err &&
 	test modified = "$(git show HEAD:file)"
 '
@@ -380,7 +380,7 @@ test_expect_success 'pull.rebase' '
 	git reset --hard before-rebase &&
 	test_config pull.rebase true &&
 	git pull . copy &&
-	test "$(git rev-parse HEAD^)" = "$(git rev-parse copy)" &&
+	test_cmp_rev HEAD^ copy &&
 	test new = "$(git show HEAD:file2)"
 '
 
@@ -398,7 +398,7 @@ test_expect_success 'branch.to-rebase.rebase' '
 	git reset --hard before-rebase &&
 	test_config branch.to-rebase.rebase true &&
 	git pull . copy &&
-	test "$(git rev-parse HEAD^)" = "$(git rev-parse copy)" &&
+	test_cmp_rev HEAD^ copy &&
 	test new = "$(git show HEAD:file2)"
 '
 
@@ -407,14 +407,14 @@ test_expect_success 'branch.to-rebase.rebase should override pull.rebase' '
 	test_config pull.rebase true &&
 	test_config branch.to-rebase.rebase false &&
 	git pull . copy &&
-	test "$(git rev-parse HEAD^)" != "$(git rev-parse copy)" &&
+	test_cmp_rev ! HEAD^ copy &&
 	test new = "$(git show HEAD:file2)"
 '
 
 test_expect_success 'pull --rebase warns on --verify-signatures' '
 	git reset --hard before-rebase &&
 	git pull --rebase --verify-signatures . copy 2>err &&
-	test "$(git rev-parse HEAD^)" = "$(git rev-parse copy)" &&
+	test_cmp_rev HEAD^ copy &&
 	test new = "$(git show HEAD:file2)" &&
 	test_i18ngrep "ignoring --verify-signatures for rebase" err
 '
@@ -422,7 +422,7 @@ test_expect_success 'pull --rebase warns on --verify-signatures' '
 test_expect_success 'pull --rebase does not warn on --no-verify-signatures' '
 	git reset --hard before-rebase &&
 	git pull --rebase --no-verify-signatures . copy 2>err &&
-	test "$(git rev-parse HEAD^)" = "$(git rev-parse copy)" &&
+	test_cmp_rev HEAD^ copy &&
 	test new = "$(git show HEAD:file2)" &&
 	test_i18ngrep ! "verify-signatures" err
 '
@@ -443,8 +443,8 @@ test_expect_success 'pull.rebase=false create a new merge commit' '
 	git reset --hard before-preserve-rebase &&
 	test_config pull.rebase false &&
 	git pull . copy &&
-	test "$(git rev-parse HEAD^1)" = "$(git rev-parse before-preserve-rebase)" &&
-	test "$(git rev-parse HEAD^2)" = "$(git rev-parse copy)" &&
+	test_cmp_rev HEAD^1 before-preserve-rebase &&
+	test_cmp_rev HEAD^2 copy &&
 	test file3 = "$(git show HEAD:file3.t)"
 '
 
@@ -452,7 +452,7 @@ test_expect_success 'pull.rebase=true flattens keep-merge' '
 	git reset --hard before-preserve-rebase &&
 	test_config pull.rebase true &&
 	git pull . copy &&
-	test "$(git rev-parse HEAD^^)" = "$(git rev-parse copy)" &&
+	test_cmp_rev HEAD^^ copy &&
 	test file3 = "$(git show HEAD:file3.t)"
 '
 
@@ -460,7 +460,7 @@ test_expect_success 'pull.rebase=1 is treated as true and flattens keep-merge' '
 	git reset --hard before-preserve-rebase &&
 	test_config pull.rebase 1 &&
 	git pull . copy &&
-	test "$(git rev-parse HEAD^^)" = "$(git rev-parse copy)" &&
+	test_cmp_rev HEAD^^ copy &&
 	test file3 = "$(git show HEAD:file3.t)"
 '
 
@@ -469,8 +469,8 @@ test_expect_success REBASE_P \
 	git reset --hard before-preserve-rebase &&
 	test_config pull.rebase preserve &&
 	git pull . copy &&
-	test "$(git rev-parse HEAD^^)" = "$(git rev-parse copy)" &&
-	test "$(git rev-parse HEAD^2)" = "$(git rev-parse keep-merge)"
+	test_cmp_rev HEAD^^ copy &&
+	test_cmp_rev HEAD^2 keep-merge
 '
 
 test_expect_success 'pull.rebase=interactive' '
@@ -505,8 +505,8 @@ test_expect_success '--rebase=false create a new merge commit' '
 	git reset --hard before-preserve-rebase &&
 	test_config pull.rebase true &&
 	git pull --rebase=false . copy &&
-	test "$(git rev-parse HEAD^1)" = "$(git rev-parse before-preserve-rebase)" &&
-	test "$(git rev-parse HEAD^2)" = "$(git rev-parse copy)" &&
+	test_cmp_rev HEAD^1 before-preserve-rebase &&
+	test_cmp_rev HEAD^2 copy &&
 	test file3 = "$(git show HEAD:file3.t)"
 '
 
@@ -514,7 +514,7 @@ test_expect_success '--rebase=true rebases and flattens keep-merge' '
 	git reset --hard before-preserve-rebase &&
 	test_config pull.rebase preserve &&
 	git pull --rebase=true . copy &&
-	test "$(git rev-parse HEAD^^)" = "$(git rev-parse copy)" &&
+	test_cmp_rev HEAD^^ copy &&
 	test file3 = "$(git show HEAD:file3.t)"
 '
 
@@ -523,8 +523,8 @@ test_expect_success REBASE_P \
 	git reset --hard before-preserve-rebase &&
 	test_config pull.rebase true &&
 	git pull --rebase=preserve . copy &&
-	test "$(git rev-parse HEAD^^)" = "$(git rev-parse copy)" &&
-	test "$(git rev-parse HEAD^2)" = "$(git rev-parse keep-merge)"
+	test_cmp_rev HEAD^^ copy &&
+	test_cmp_rev HEAD^2 keep-merge
 '
 
 test_expect_success '--rebase=invalid fails' '
@@ -536,7 +536,7 @@ test_expect_success '--rebase overrides pull.rebase=preserve and flattens keep-m
 	git reset --hard before-preserve-rebase &&
 	test_config pull.rebase preserve &&
 	git pull --rebase . copy &&
-	test "$(git rev-parse HEAD^^)" = "$(git rev-parse copy)" &&
+	test_cmp_rev HEAD^^ copy &&
 	test file3 = "$(git show HEAD:file3.t)"
 '
 
@@ -597,10 +597,10 @@ test_expect_success 'pull --rebase dies early with dirty working directory' '
 	echo dirty >>file &&
 	git add file &&
 	test_must_fail git pull &&
-	test "$COPY" = "$(git rev-parse --verify me/copy)" &&
+	test_cmp_rev "$COPY" me/copy &&
 	git checkout HEAD -- file &&
 	git pull &&
-	test "$COPY" != "$(git rev-parse --verify me/copy)"
+	test_cmp_rev ! "$COPY" me/copy
 '
 
 test_expect_success 'pull --rebase works on branch yet to be born' '
-- 
2.24.0.rc2.262.g2d07a97ef5


  parent reply	other threads:[~2019-11-07 18:51 UTC|newest]

Thread overview: 116+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-17 23:16 [PATCH 00/12] t5520: various test cleanup Denton Liu
2019-10-17 23:16 ` [PATCH 01/12] t5520: improve test style Denton Liu
2019-10-17 23:16 ` [PATCH 02/12] t5520: use sq for test case names Denton Liu
2019-10-17 23:17 ` [PATCH 03/12] t5520: let sed open its own input Denton Liu
2019-10-17 23:17 ` [PATCH 04/12] t5520: replace test -f with test_path_is_file Denton Liu
2019-10-17 23:26   ` Eric Sunshine
2019-10-17 23:35   ` [PATCH 4.5/12] t5520: replace test -f with test-lib functions Denton Liu
2019-10-18  0:11     ` Eric Sunshine
2019-10-17 23:17 ` [PATCH 05/12] t5520: remove spaces after redirect operator Denton Liu
2019-10-17 23:17 ` [PATCH 06/12] t5520: use test_line_count where possible Denton Liu
2019-10-17 23:17 ` [PATCH 07/12] t5520: replace test -{n,z} with test-lib functions Denton Liu
2019-10-17 23:31   ` Eric Sunshine
2019-10-17 23:17 ` [PATCH 08/12] t5520: use test_cmp_rev where possible Denton Liu
2019-10-17 23:41   ` Eric Sunshine
2019-10-18 18:52     ` Denton Liu
2019-10-23 13:53       ` Eric Sunshine
2019-10-17 23:17 ` [PATCH 09/12] t5520: test single-line files by git with test_cmp Denton Liu
2019-10-17 23:49   ` Eric Sunshine
2019-10-17 23:17 ` [PATCH 10/12] t5520: don't put git in upstream of pipe Denton Liu
2019-10-17 23:17 ` [PATCH 11/12] t5520: replace subshell cat comparison with test_cmp Denton Liu
2019-10-17 23:17 ` [PATCH 12/12] t5520: replace `! git` with `test_must_fail git` Denton Liu
2019-10-18 22:10 ` [PATCH v2 00/15] t5520: various test cleanup Denton Liu
2019-10-18 22:04   ` [PATCH v2 01/15] t7408: replace `test_must_fail test_path_is_file` Denton Liu
2019-10-19 11:58     ` Johannes Sixt
2019-10-18 22:04   ` [PATCH v2 09/15] t5520: replace test -{n,z} with test-lib functions Denton Liu
2019-10-18 22:04   ` [PATCH v2 11/15] t5520: test single-line files by git with test_cmp Denton Liu
2019-10-18 22:10   ` [PATCH v2 02/15] t: teach test_cmp_rev to accept ! for not-equals Denton Liu
2019-10-18 22:45     ` SZEDER Gábor
2019-10-18 22:10   ` [PATCH v2 03/15] t5520: improve test style Denton Liu
2019-10-18 22:10   ` [PATCH v2 04/15] t5520: use sq for test case names Denton Liu
2019-10-18 22:10   ` [PATCH v2 05/15] t5520: let sed open its own input Denton Liu
2019-10-18 22:10   ` [PATCH v2 06/15] t5520: replace test -f with test-lib functions Denton Liu
2019-10-18 22:10   ` [PATCH v2 07/15] t5520: remove spaces after redirect operator Denton Liu
2019-10-18 22:10   ` [PATCH v2 08/15] t5520: use test_line_count where possible Denton Liu
2019-10-18 22:10   ` [PATCH v2 10/15] t5520: use test_cmp_rev " Denton Liu
2019-10-18 22:10   ` [PATCH v2 12/15] t5520: don't put git in upstream of pipe Denton Liu
2019-10-18 22:10   ` [PATCH v2 13/15] t5520: replace subshell cat comparison with test_cmp Denton Liu
2019-10-18 22:10   ` [PATCH v2 14/15] t5520: remove redundant lines in test cases Denton Liu
2019-10-18 22:10   ` [PATCH v2 15/15] t5520: replace `! git` with `test_must_fail git` Denton Liu
2019-10-18 22:14   ` [PATCH v2 00/15] t5520: various test cleanup Denton Liu
2019-10-22 10:19   ` [PATCH v3 00/14] " Denton Liu
2019-10-22 10:19     ` [PATCH v3 01/14] t: teach test_cmp_rev to accept ! for not-equals Denton Liu
2019-10-22 10:19     ` [PATCH v3 02/14] t5520: improve test style Denton Liu
2019-10-22 10:19     ` [PATCH v3 03/14] t5520: use sq for test case names Denton Liu
2019-10-22 10:20     ` [PATCH v3 04/14] t5520: let sed open its own input Denton Liu
2019-10-22 10:20     ` [PATCH v3 05/14] t5520: replace test -f with test-lib functions Denton Liu
2019-10-22 10:20     ` [PATCH v3 06/14] t5520: remove spaces after redirect operator Denton Liu
2019-10-22 10:20     ` [PATCH v3 07/14] t5520: use test_line_count where possible Denton Liu
2019-10-22 10:20     ` [PATCH v3 08/14] t5520: replace test -{n,z} with test-lib functions Denton Liu
2019-10-22 10:20     ` [PATCH v3 09/14] t5520: use test_cmp_rev where possible Denton Liu
2019-10-22 10:20     ` [PATCH v3 10/14] t5520: test single-line files by git with test_cmp Denton Liu
2019-10-22 10:20     ` [PATCH v3 11/14] t5520: don't put git in upstream of pipe Denton Liu
2019-10-22 10:20     ` [PATCH v3 12/14] t5520: replace subshell cat comparison with test_cmp Denton Liu
2019-10-22 10:20     ` [PATCH v3 13/14] t5520: remove redundant lines in test cases Denton Liu
2019-10-22 10:20     ` [PATCH v3 14/14] t5520: replace `! git` with `test_must_fail git` Denton Liu
2019-10-24 23:21     ` [PATCH v3 00/14] t5520: various test cleanup Denton Liu
2019-10-25  3:44       ` Junio C Hamano
2019-11-04 19:17         ` Denton Liu
2019-11-06  2:37           ` Junio C Hamano
2019-11-07 18:51     ` [PATCH v4 " Denton Liu
2019-11-07 18:51       ` [PATCH v4 01/14] t: teach test_cmp_rev to accept ! for not-equals Denton Liu
2019-11-08  3:24         ` Junio C Hamano
2019-11-08  8:23           ` Denton Liu
2019-11-08 12:49             ` Junio C Hamano
2019-11-08 21:19               ` Denton Liu
2019-11-10  6:58                 ` Junio C Hamano
2019-11-07 18:51       ` [PATCH v4 02/14] t5520: improve test style Denton Liu
2019-11-07 18:51       ` [PATCH v4 03/14] t5520: use sq for test case names Denton Liu
2019-11-07 18:51       ` [PATCH v4 04/14] t5520: let sed open its own input Denton Liu
2019-11-07 18:51       ` [PATCH v4 05/14] t5520: replace test -f with test-lib functions Denton Liu
2019-11-07 18:51       ` [PATCH v4 06/14] t5520: remove spaces after redirect operator Denton Liu
2019-11-07 18:51       ` [PATCH v4 07/14] t5520: use test_line_count where possible Denton Liu
2019-11-07 18:51       ` [PATCH v4 08/14] t5520: replace test -{n,z} with test-lib functions Denton Liu
2019-11-07 18:51       ` Denton Liu [this message]
2019-11-07 18:51       ` [PATCH v4 10/14] t5520: test single-line files by git with test_cmp Denton Liu
2019-11-07 18:51       ` [PATCH v4 11/14] t5520: don't put git in upstream of pipe Denton Liu
2019-11-07 18:51       ` [PATCH v4 12/14] t5520: replace subshell cat comparison with test_cmp Denton Liu
2019-11-07 18:51       ` [PATCH v4 13/14] t5520: remove redundant lines in test cases Denton Liu
2019-11-07 18:51       ` [PATCH v4 14/14] t5520: replace `! git` with `test_must_fail git` Denton Liu
2019-11-12  0:13       ` [PATCH v5 00/14] t5520: various test cleanup Denton Liu
2019-11-12  0:13         ` [PATCH v5 01/14] t: teach test_cmp_rev to accept ! for not-equals Denton Liu
2019-11-12  6:52           ` Junio C Hamano
2019-11-12 19:38             ` [PATCH] fixup! " Denton Liu
2019-11-12  0:13         ` [PATCH v5 02/14] t5520: improve test style Denton Liu
2019-11-12  0:13         ` [PATCH v5 03/14] t5520: use sq for test case names Denton Liu
2019-11-12  0:13         ` [PATCH v5 04/14] t5520: let sed open its own input Denton Liu
2019-11-12  0:13         ` [PATCH v5 05/14] t5520: replace test -f with test-lib functions Denton Liu
2019-11-12  0:13         ` [PATCH v5 06/14] t5520: remove spaces after redirect operator Denton Liu
2019-11-12  0:13         ` [PATCH v5 07/14] t5520: use test_line_count where possible Denton Liu
2019-11-12  0:13         ` [PATCH v5 08/14] t5520: replace test -{n,z} with test-lib functions Denton Liu
2019-11-12  0:14         ` [PATCH v5 09/14] t5520: use test_cmp_rev where possible Denton Liu
2019-11-12  0:14         ` [PATCH v5 10/14] t5520: test single-line files by git with test_cmp Denton Liu
2019-11-12  5:17           ` Junio C Hamano
2019-11-12 23:06             ` Denton Liu
2019-11-12  0:14         ` [PATCH v5 11/14] t5520: don't put git in upstream of pipe Denton Liu
2019-11-12  0:14         ` [PATCH v5 12/14] t5520: replace subshell cat comparison with test_cmp Denton Liu
2019-11-12  0:14         ` [PATCH v5 13/14] t5520: remove redundant lines in test cases Denton Liu
2019-11-12  0:14         ` [PATCH v5 14/14] t5520: replace `! git` with `test_must_fail git` Denton Liu
2019-11-12 23:07         ` [PATCH v6 00/14] t5520: various test cleanup Denton Liu
2019-11-12 23:07           ` [PATCH v6 01/14] t: teach test_cmp_rev to accept ! for not-equals Denton Liu
2019-11-13  1:57             ` Junio C Hamano
2019-11-14  0:52               ` Denton Liu
2019-11-12 23:07           ` [PATCH v6 02/14] t5520: improve test style Denton Liu
2019-11-12 23:07           ` [PATCH v6 03/14] t5520: use sq for test case names Denton Liu
2019-11-12 23:07           ` [PATCH v6 04/14] t5520: let sed open its own input Denton Liu
2019-11-12 23:07           ` [PATCH v6 05/14] t5520: replace test -f with test-lib functions Denton Liu
2019-11-12 23:07           ` [PATCH v6 06/14] t5520: remove spaces after redirect operator Denton Liu
2019-11-12 23:08           ` [PATCH v6 07/14] t5520: use test_line_count where possible Denton Liu
2019-11-12 23:08           ` [PATCH v6 08/14] t5520: replace test -{n,z} with test-lib functions Denton Liu
2019-11-12 23:08           ` [PATCH v6 09/14] t5520: use test_cmp_rev where possible Denton Liu
2019-11-12 23:08           ` [PATCH v6 10/14] t5520: test single-line files by git with test_cmp Denton Liu
2019-11-12 23:08           ` [PATCH v6 11/14] t5520: don't put git in upstream of pipe Denton Liu
2019-11-12 23:08           ` [PATCH v6 12/14] t5520: replace $(cat ...) comparison with test_cmp Denton Liu
2019-11-12 23:08           ` [PATCH v6 13/14] t5520: remove redundant lines in test cases Denton Liu
2019-11-12 23:08           ` [PATCH v6 14/14] t5520: replace `! git` with `test_must_fail git` Denton Liu
2019-11-13  1:59           ` [PATCH v6 00/14] t5520: various test cleanup Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fdde875363ed67c208d15cbc8bd96d5f9f476152.1573152599.git.liu.denton@gmail.com \
    --to=liu.denton@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=j6t@kdbg.org \
    --cc=sunshine@sunshineco.com \
    --cc=szeder.dev@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.