git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH v1 0/2] Cleanup tests for test_cmp argument ordering and "|" placement
@ 2018-09-15  0:02 Matthew DeVore
  2018-09-15  0:02 ` [PATCH v1 1/2] t/*: fix pipe placement and remove \'s Matthew DeVore
                   ` (7 more replies)
  0 siblings, 8 replies; 66+ messages in thread
From: Matthew DeVore @ 2018-09-15  0:02 UTC (permalink / raw)
  To: git; +Cc: Matthew DeVore, peff, jonathantanmy, gitster, bmwill

As requested in:
 https://public-inbox.org/git/xmqqmuskas3a.fsf@gitster-ct.c.googlers.com/
this patchset corrects ordering of test_cmp arguments and | placement.

The request didn't explicitly state whether all the tests should be cleaned up,
but I did clean up as much as I reasonably could.

The linked mail above also requested cleaning up flag/positional arg ordering so
that flags appear first. The amount of wrong ordering I could find was small, so
I put that cleanup in the other patchset.

Matthew DeVore (2):
  t/*: fix pipe placement and remove \'s
  t/*: fix ordering of expected/observed arguments

 t/lib-gpg.sh                           |   4 +-
 t/t0000-basic.sh                       |   2 +-
 t/t0021-conversion.sh                  |   4 +-
 t/t1006-cat-file.sh                    |   8 +-
 t/t1300-config.sh                      |   9 +-
 t/t1303-wacky-config.sh                |   4 +-
 t/t2101-update-index-reupdate.sh       |   2 +-
 t/t3200-branch.sh                      |   2 +-
 t/t3320-notes-merge-worktrees.sh       |   4 +-
 t/t3400-rebase.sh                      |   8 +-
 t/t3417-rebase-whitespace-fix.sh       |   6 +-
 t/t3702-add-edit.sh                    |   4 +-
 t/t3903-stash.sh                       |   8 +-
 t/t3905-stash-include-untracked.sh     |   2 +-
 t/t4025-hunk-header.sh                 |   2 +-
 t/t4117-apply-reject.sh                |   6 +-
 t/t4124-apply-ws-rule.sh               |  30 +-
 t/t4138-apply-ws-expansion.sh          |   2 +-
 t/t5317-pack-objects-filter-objects.sh | 364 ++++++++++++++-----------
 t/t5318-commit-graph.sh                |   2 +-
 t/t5500-fetch-pack.sh                  |   5 +-
 t/t5616-partial-clone.sh               |  30 +-
 t/t5701-git-serve.sh                   |  14 +-
 t/t5702-protocol-v2.sh                 |  10 +-
 t/t6023-merge-file.sh                  |  12 +-
 t/t6027-merge-binary.sh                |   4 +-
 t/t6031-merge-filemode.sh              |   2 +-
 t/t6112-rev-list-filters-objects.sh    | 227 ++++++++-------
 t/t7201-co.sh                          |   4 +-
 t/t7406-submodule-update.sh            |   8 +-
 t/t7508-status.sh                      |   2 +-
 t/t7800-difftool.sh                    |   2 +-
 t/t9100-git-svn-basic.sh               |   2 +-
 t/t9101-git-svn-props.sh               |   4 +-
 t/t9133-git-svn-nested-git-repo.sh     |   6 +-
 t/t9600-cvsimport.sh                   |   2 +-
 t/t9603-cvsimport-patchsets.sh         |   4 +-
 t/t9604-cvsimport-timestamps.sh        |   4 +-
 38 files changed, 452 insertions(+), 363 deletions(-)

-- 
2.19.0.397.gdd90340f6a-goog


^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v1 1/2] t/*: fix pipe placement and remove \'s
  2018-09-15  0:02 [PATCH v1 0/2] Cleanup tests for test_cmp argument ordering and "|" placement Matthew DeVore
@ 2018-09-15  0:02 ` Matthew DeVore
  2018-09-17 16:31   ` Jonathan Nieder
  2018-09-15  0:02 ` [PATCH v1 2/2] t/*: fix ordering of expected/observed arguments Matthew DeVore
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 66+ messages in thread
From: Matthew DeVore @ 2018-09-15  0:02 UTC (permalink / raw)
  To: git; +Cc: Matthew DeVore, peff, jonathantanmy, gitster, bmwill

Where ever there was code in the tests like this:

	foo \
		| bar

such as:

	git rev-list HEAD \
		| grep $COMMIT

replace it with this:

	foo |
	bar

And add a blank line before and after the pipe where it aids readability
(it usually does).

Signed-off-by: Matthew DeVore <matvore@google.com>
---
 t/lib-gpg.sh                           |   4 +-
 t/t1006-cat-file.sh                    |   8 +-
 t/t1300-config.sh                      |   5 +-
 t/t5317-pack-objects-filter-objects.sh | 330 ++++++++++++++-----------
 t/t5500-fetch-pack.sh                  |   5 +-
 t/t5616-partial-clone.sh               |  30 ++-
 t/t6112-rev-list-filters-objects.sh    | 203 ++++++++-------
 t/t9101-git-svn-props.sh               |   4 +-
 8 files changed, 339 insertions(+), 250 deletions(-)

diff --git a/t/lib-gpg.sh b/t/lib-gpg.sh
index 3fe02876c..2b8b81ac9 100755
--- a/t/lib-gpg.sh
+++ b/t/lib-gpg.sh
@@ -57,8 +57,8 @@ then
 		echo | gpgsm --homedir "${GNUPGHOME}" 2>/dev/null \
 			--passphrase-fd 0 --pinentry-mode loopback \
 			--import "$TEST_DIRECTORY"/lib-gpg/gpgsm_cert.p12 &&
-		gpgsm --homedir "${GNUPGHOME}" 2>/dev/null -K \
-			| grep fingerprint: | cut -d" " -f4 | tr -d '\n' > \
+		gpgsm --homedir "${GNUPGHOME}" 2>/dev/null -K |
+		grep fingerprint: | cut -d" " -f4 | tr -d '\n' > \
 			${GNUPGHOME}/trustlist.txt &&
 		echo " S relax" >> ${GNUPGHOME}/trustlist.txt &&
 		(gpgconf --kill gpg-agent >/dev/null 2>&1 || : ) &&
diff --git a/t/t1006-cat-file.sh b/t/t1006-cat-file.sh
index 7f19d591f..a0fa926d3 100755
--- a/t/t1006-cat-file.sh
+++ b/t/t1006-cat-file.sh
@@ -218,8 +218,8 @@ test_expect_success "--batch-check for a non-existent hash" '
     test "0000000000000000000000000000000000000042 missing
 0000000000000000000000000000000000000084 missing" = \
     "$( ( echo 0000000000000000000000000000000000000042;
-         echo_without_newline 0000000000000000000000000000000000000084; ) \
-       | git cat-file --batch-check)"
+         echo_without_newline 0000000000000000000000000000000000000084; ) |
+       git cat-file --batch-check)"
 '
 
 test_expect_success "--batch for an existent and a non-existent hash" '
@@ -227,8 +227,8 @@ test_expect_success "--batch for an existent and a non-existent hash" '
 $tag_content
 0000000000000000000000000000000000000000 missing" = \
     "$( ( echo $tag_sha1;
-         echo_without_newline 0000000000000000000000000000000000000000; ) \
-       | git cat-file --batch)"
+         echo_without_newline 0000000000000000000000000000000000000000; ) |
+       git cat-file --batch)"
 '
 
 test_expect_success "--batch-check for an empty line" '
diff --git a/t/t1300-config.sh b/t/t1300-config.sh
index cdf1fed5d..5869d6cb6 100755
--- a/t/t1300-config.sh
+++ b/t/t1300-config.sh
@@ -1770,8 +1770,9 @@ test_expect_success '--show-origin stdin with file include' '
 	cat >expect <<-EOF &&
 		file:$INCLUDE_DIR/stdin.include	include
 	EOF
-	echo "[include]path=\"$INCLUDE_DIR\"/stdin.include" \
-		| git config --show-origin --includes --file - user.stdin >output &&
+	echo "[include]path=\"$INCLUDE_DIR\"/stdin.include" |
+	git config --show-origin --includes --file - user.stdin >output &&
+
 	test_cmp expect output
 '
 
diff --git a/t/t5317-pack-objects-filter-objects.sh b/t/t5317-pack-objects-filter-objects.sh
index 6710c8bc8..ce69148ec 100755
--- a/t/t5317-pack-objects-filter-objects.sh
+++ b/t/t5317-pack-objects-filter-objects.sh
@@ -20,17 +20,20 @@ test_expect_success 'setup r1' '
 '
 
 test_expect_success 'verify blob count in normal packfile' '
-	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	git -C r1 pack-objects --rev --stdout >all.pack <<-EOF &&
 	HEAD
 	EOF
 	git -C r1 index-pack ../all.pack &&
-	git -C r1 verify-pack -v ../all.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r1 verify-pack -v ../all.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
@@ -39,23 +42,27 @@ test_expect_success 'verify blob:none packfile has no blobs' '
 	HEAD
 	EOF
 	git -C r1 index-pack ../filter.pack &&
-	git -C r1 verify-pack -v ../filter.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r1 verify-pack -v ../filter.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	nr=$(wc -l <observed) &&
 	test 0 -eq $nr
 '
 
 test_expect_success 'verify normal and blob:none packfiles have same commits/trees' '
-	git -C r1 verify-pack -v ../all.pack \
-		| grep -E "commit|tree" \
-		| awk -f print_1.awk \
-		| sort >expected &&
-	git -C r1 verify-pack -v ../filter.pack \
-		| grep -E "commit|tree" \
-		| awk -f print_1.awk \
-		| sort >observed &&
+	git -C r1 verify-pack -v ../all.pack |
+	grep -E "commit|tree" |
+	awk -f print_1.awk |
+	sort >expected &&
+
+	git -C r1 verify-pack -v ../filter.pack |
+	grep -E "commit|tree" |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
@@ -75,17 +82,20 @@ test_expect_success 'setup r2' '
 '
 
 test_expect_success 'verify blob count in normal packfile' '
-	git -C r2 ls-files -s large.1000 large.10000 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r2 ls-files -s large.1000 large.10000 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	git -C r2 pack-objects --rev --stdout >all.pack <<-EOF &&
 	HEAD
 	EOF
 	git -C r2 index-pack ../all.pack &&
-	git -C r2 verify-pack -v ../all.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r2 verify-pack -v ../all.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
@@ -94,10 +104,12 @@ test_expect_success 'verify blob:limit=500 omits all blobs' '
 	HEAD
 	EOF
 	git -C r2 index-pack ../filter.pack &&
-	git -C r2 verify-pack -v ../filter.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r2 verify-pack -v ../filter.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	nr=$(wc -l <observed) &&
 	test 0 -eq $nr
 '
@@ -107,99 +119,118 @@ test_expect_success 'verify blob:limit=1000' '
 	HEAD
 	EOF
 	git -C r2 index-pack ../filter.pack &&
-	git -C r2 verify-pack -v ../filter.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r2 verify-pack -v ../filter.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	nr=$(wc -l <observed) &&
 	test 0 -eq $nr
 '
 
 test_expect_success 'verify blob:limit=1001' '
-	git -C r2 ls-files -s large.1000 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r2 ls-files -s large.1000 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	git -C r2 pack-objects --rev --stdout --filter=blob:limit=1001 >filter.pack <<-EOF &&
 	HEAD
 	EOF
 	git -C r2 index-pack ../filter.pack &&
-	git -C r2 verify-pack -v ../filter.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r2 verify-pack -v ../filter.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify blob:limit=10001' '
-	git -C r2 ls-files -s large.1000 large.10000 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r2 ls-files -s large.1000 large.10000 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	git -C r2 pack-objects --rev --stdout --filter=blob:limit=10001 >filter.pack <<-EOF &&
 	HEAD
 	EOF
 	git -C r2 index-pack ../filter.pack &&
-	git -C r2 verify-pack -v ../filter.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r2 verify-pack -v ../filter.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify blob:limit=1k' '
-	git -C r2 ls-files -s large.1000 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r2 ls-files -s large.1000 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	git -C r2 pack-objects --rev --stdout --filter=blob:limit=1k >filter.pack <<-EOF &&
 	HEAD
 	EOF
 	git -C r2 index-pack ../filter.pack &&
-	git -C r2 verify-pack -v ../filter.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r2 verify-pack -v ../filter.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify explicitly specifying oversized blob in input' '
-	git -C r2 ls-files -s large.1000 large.10000 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r2 ls-files -s large.1000 large.10000 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	git -C r2 pack-objects --rev --stdout --filter=blob:limit=1k >filter.pack <<-EOF &&
 	HEAD
 	$(git -C r2 rev-parse HEAD:large.10000)
 	EOF
 	git -C r2 index-pack ../filter.pack &&
-	git -C r2 verify-pack -v ../filter.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r2 verify-pack -v ../filter.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify blob:limit=1m' '
-	git -C r2 ls-files -s large.1000 large.10000 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r2 ls-files -s large.1000 large.10000 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	git -C r2 pack-objects --rev --stdout --filter=blob:limit=1m >filter.pack <<-EOF &&
 	HEAD
 	EOF
 	git -C r2 index-pack ../filter.pack &&
-	git -C r2 verify-pack -v ../filter.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r2 verify-pack -v ../filter.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify normal and blob:limit packfiles have same commits/trees' '
-	git -C r2 verify-pack -v ../all.pack \
-		| grep -E "commit|tree" \
-		| awk -f print_1.awk \
-		| sort >expected &&
-	git -C r2 verify-pack -v ../filter.pack \
-		| grep -E "commit|tree" \
-		| awk -f print_1.awk \
-		| sort >observed &&
+	git -C r2 verify-pack -v ../all.pack |
+	grep -E "commit|tree" |
+	awk -f print_1.awk |
+	sort >expected &&
+
+	git -C r2 verify-pack -v ../filter.pack |
+	grep -E "commit|tree" |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
@@ -224,71 +255,84 @@ test_expect_success 'setup r3' '
 '
 
 test_expect_success 'verify blob count in normal packfile' '
-	git -C r3 ls-files -s sparse1 sparse2 dir1/sparse1 dir1/sparse2 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r3 ls-files -s sparse1 sparse2 dir1/sparse1 dir1/sparse2 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	git -C r3 pack-objects --rev --stdout >all.pack <<-EOF &&
 	HEAD
 	EOF
 	git -C r3 index-pack ../all.pack &&
-	git -C r3 verify-pack -v ../all.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r3 verify-pack -v ../all.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify sparse:path=pattern1' '
-	git -C r3 ls-files -s dir1/sparse1 dir1/sparse2 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r3 ls-files -s dir1/sparse1 dir1/sparse2 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	git -C r3 pack-objects --rev --stdout --filter=sparse:path=../pattern1 >filter.pack <<-EOF &&
 	HEAD
 	EOF
 	git -C r3 index-pack ../filter.pack &&
-	git -C r3 verify-pack -v ../filter.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r3 verify-pack -v ../filter.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify normal and sparse:path=pattern1 packfiles have same commits/trees' '
-	git -C r3 verify-pack -v ../all.pack \
-		| grep -E "commit|tree" \
-		| awk -f print_1.awk \
-		| sort >expected &&
-	git -C r3 verify-pack -v ../filter.pack \
-		| grep -E "commit|tree" \
-		| awk -f print_1.awk \
-		| sort >observed &&
+	git -C r3 verify-pack -v ../all.pack |
+	grep -E "commit|tree" |
+	awk -f print_1.awk |
+	sort >expected &&
+
+	git -C r3 verify-pack -v ../filter.pack |
+	grep -E "commit|tree" |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify sparse:path=pattern2' '
-	git -C r3 ls-files -s sparse1 dir1/sparse1 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r3 ls-files -s sparse1 dir1/sparse1 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	git -C r3 pack-objects --rev --stdout --filter=sparse:path=../pattern2 >filter.pack <<-EOF &&
 	HEAD
 	EOF
 	git -C r3 index-pack ../filter.pack &&
-	git -C r3 verify-pack -v ../filter.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r3 verify-pack -v ../filter.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify normal and sparse:path=pattern2 packfiles have same commits/trees' '
-	git -C r3 verify-pack -v ../all.pack \
-		| grep -E "commit|tree" \
-		| awk -f print_1.awk \
-		| sort >expected &&
-	git -C r3 verify-pack -v ../filter.pack \
-		| grep -E "commit|tree" \
-		| awk -f print_1.awk \
-		| sort >observed &&
+	git -C r3 verify-pack -v ../all.pack |
+	grep -E "commit|tree" |
+	awk -f print_1.awk |
+	sort >expected &&
+
+	git -C r3 verify-pack -v ../filter.pack |
+	grep -E "commit|tree" |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
@@ -312,48 +356,57 @@ test_expect_success 'setup r4' '
 '
 
 test_expect_success 'verify blob count in normal packfile' '
-	git -C r4 ls-files -s pattern sparse1 sparse2 dir1/sparse1 dir1/sparse2 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r4 ls-files -s pattern sparse1 sparse2 dir1/sparse1 dir1/sparse2 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	git -C r4 pack-objects --rev --stdout >all.pack <<-EOF &&
 	HEAD
 	EOF
 	git -C r4 index-pack ../all.pack &&
-	git -C r4 verify-pack -v ../all.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r4 verify-pack -v ../all.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify sparse:oid=OID' '
-	git -C r4 ls-files -s dir1/sparse1 dir1/sparse2 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r4 ls-files -s dir1/sparse1 dir1/sparse2 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	oid=$(git -C r4 ls-files -s pattern | awk -f print_2.awk) &&
 	git -C r4 pack-objects --rev --stdout --filter=sparse:oid=$oid >filter.pack <<-EOF &&
 	HEAD
 	EOF
 	git -C r4 index-pack ../filter.pack &&
-	git -C r4 verify-pack -v ../filter.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r4 verify-pack -v ../filter.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify sparse:oid=oid-ish' '
-	git -C r4 ls-files -s dir1/sparse1 dir1/sparse2 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r4 ls-files -s dir1/sparse1 dir1/sparse2 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	git -C r4 pack-objects --rev --stdout --filter=sparse:oid=master:pattern >filter.pack <<-EOF &&
 	HEAD
 	EOF
 	git -C r4 index-pack ../filter.pack &&
-	git -C r4 verify-pack -v ../filter.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r4 verify-pack -v ../filter.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
@@ -361,9 +414,10 @@ test_expect_success 'verify sparse:oid=oid-ish' '
 # This models previously omitted objects that we did not receive.
 
 test_expect_success 'setup r1 - delete loose blobs' '
-	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	for id in `cat expected | sed "s|..|&/|"`
 	do
 		rm r1/.git/objects/$id
diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh
index 1b5a4a6d3..5ac6f286d 100755
--- a/t/t5500-fetch-pack.sh
+++ b/t/t5500-fetch-pack.sh
@@ -50,8 +50,9 @@ pull_to_client () {
 			case "$heads" in *B*)
 			    git update-ref refs/heads/B "$BTIP";;
 			esac &&
-			git symbolic-ref HEAD refs/heads/$(echo $heads \
-				| sed -e "s/^\(.\).*$/\1/") &&
+
+			git symbolic-ref HEAD refs/heads/$(echo $heads |
+			sed -e "s/^\(.\).*$/\1/") &&
 
 			git fsck --full &&
 
diff --git a/t/t5616-partial-clone.sh b/t/t5616-partial-clone.sh
index bbbe7537d..ec19cbceb 100755
--- a/t/t5616-partial-clone.sh
+++ b/t/t5616-partial-clone.sh
@@ -34,10 +34,12 @@ test_expect_success 'setup bare clone for server' '
 # confirm partial clone was registered in the local config.
 test_expect_success 'do partial clone 1' '
 	git clone --no-checkout --filter=blob:none "file://$(pwd)/srv.bare" pc1 &&
-	git -C pc1 rev-list HEAD --quiet --objects --missing=print \
-		| awk -f print_1.awk \
-		| sed "s/?//" \
-		| sort >observed.oids &&
+
+	git -C pc1 rev-list HEAD --quiet --objects --missing=print |
+	awk -f print_1.awk |
+	sed "s/?//" |
+	sort >observed.oids &&
+
 	test_cmp expect_1.oids observed.oids &&
 	test "$(git -C pc1 config --local core.repositoryformatversion)" = "1" &&
 	test "$(git -C pc1 config --local extensions.partialclone)" = "origin" &&
@@ -130,16 +132,20 @@ test_expect_success 'push new commits to server for file.3.txt' '
 # perhaps combined with a command in dry-run mode.
 test_expect_success 'manual prefetch of missing objects' '
 	git -C pc1 fetch --filter=blob:none origin &&
-	git -C pc1 rev-list master..origin/master --quiet --objects --missing=print \
-		| awk -f print_1.awk \
-		| sed "s/?//" \
-		| sort >observed.oids &&
+
+	git -C pc1 rev-list master..origin/master --quiet --objects --missing=print |
+	awk -f print_1.awk |
+	sed "s/?//" |
+	sort >observed.oids &&
+
 	test_line_count = 6 observed.oids &&
 	git -C pc1 fetch-pack --stdin "file://$(pwd)/srv.bare" <observed.oids &&
-	git -C pc1 rev-list master..origin/master --quiet --objects --missing=print \
-		| awk -f print_1.awk \
-		| sed "s/?//" \
-		| sort >observed.oids &&
+
+	git -C pc1 rev-list master..origin/master --quiet --objects --missing=print |
+	awk -f print_1.awk |
+	sed "s/?//" |
+	sort >observed.oids &&
+
 	test_line_count = 0 observed.oids
 '
 
diff --git a/t/t6112-rev-list-filters-objects.sh b/t/t6112-rev-list-filters-objects.sh
index d4ff0b3be..0f6b569e1 100755
--- a/t/t6112-rev-list-filters-objects.sh
+++ b/t/t6112-rev-list-filters-objects.sh
@@ -20,24 +20,28 @@ test_expect_success 'setup r1' '
 '
 
 test_expect_success 'verify blob:none omits all 5 blobs' '
-	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 \
-		| awk -f print_2.awk \
-		| sort >expected &&
-	git -C r1 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:none \
-		| awk -f print_1.awk \
-		| sed "s/~//" \
-		| sort >observed &&
+	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 |
+	awk -f print_2.awk |
+	sort >expected &&
+
+	git -C r1 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:none |
+	awk -f print_1.awk |
+	sed "s/~//" |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify emitted+omitted == all' '
-	git -C r1 rev-list HEAD --objects \
-		| awk -f print_1.awk \
-		| sort >expected &&
-	git -C r1 rev-list HEAD --objects --filter-print-omitted --filter=blob:none \
-		| awk -f print_1.awk \
-		| sed "s/~//" \
-		| sort >observed &&
+	git -C r1 rev-list HEAD --objects |
+	awk -f print_1.awk |
+	sort >expected &&
+
+	git -C r1 rev-list HEAD --objects --filter-print-omitted --filter=blob:none |
+	awk -f print_1.awk |
+	sed "s/~//" |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
@@ -58,65 +62,76 @@ test_expect_success 'setup r2' '
 '
 
 test_expect_success 'verify blob:limit=500 omits all blobs' '
-	git -C r2 ls-files -s large.1000 large.10000 \
-		| awk -f print_2.awk \
-		| sort >expected &&
-	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=500 \
-		| awk -f print_1.awk \
-		| sed "s/~//" \
-		| sort >observed &&
+	git -C r2 ls-files -s large.1000 large.10000 |
+	awk -f print_2.awk |
+	sort >expected &&
+
+	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=500 |
+	awk -f print_1.awk |
+	sed "s/~//" |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify emitted+omitted == all' '
-	git -C r2 rev-list HEAD --objects \
-		| awk -f print_1.awk \
-		| sort >expected &&
-	git -C r2 rev-list HEAD --objects --filter-print-omitted --filter=blob:limit=500 \
-		| awk -f print_1.awk \
-		| sed "s/~//" \
-		| sort >observed &&
+	git -C r2 rev-list HEAD --objects |
+	awk -f print_1.awk |
+	sort >expected &&
+
+	git -C r2 rev-list HEAD --objects --filter-print-omitted --filter=blob:limit=500 |
+	awk -f print_1.awk |
+	sed "s/~//" |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify blob:limit=1000' '
-	git -C r2 ls-files -s large.1000 large.10000 \
-		| awk -f print_2.awk \
-		| sort >expected &&
-	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1000 \
-		| awk -f print_1.awk \
-		| sed "s/~//" \
-		| sort >observed &&
+	git -C r2 ls-files -s large.1000 large.10000 |
+	awk -f print_2.awk |
+	sort >expected &&
+
+	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1000 |
+	awk -f print_1.awk |
+	sed "s/~//" |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify blob:limit=1001' '
-	git -C r2 ls-files -s large.10000 \
-		| awk -f print_2.awk \
-		| sort >expected &&
-	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1001 \
-		| awk -f print_1.awk \
-		| sed "s/~//" \
-		| sort >observed &&
+	git -C r2 ls-files -s large.10000 |
+	awk -f print_2.awk |
+	sort >expected &&
+
+	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1001 |
+	awk -f print_1.awk |
+	sed "s/~//" |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify blob:limit=1k' '
-	git -C r2 ls-files -s large.10000 \
-		| awk -f print_2.awk \
-		| sort >expected &&
-	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1k \
-		| awk -f print_1.awk \
-		| sed "s/~//" \
-		| sort >observed &&
+	git -C r2 ls-files -s large.10000 |
+	awk -f print_2.awk |
+	sort >expected &&
+
+	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1k |
+	awk -f print_1.awk |
+	sed "s/~//" |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify blob:limit=1m' '
-	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1m \
-		| awk -f print_1.awk \
-		| sed "s/~//" \
-		| sort >observed &&
+	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1m |
+	awk -f print_1.awk |
+	sed "s/~//" |
+	sort >observed &&
+
 	test_must_be_empty observed
 '
 
@@ -141,24 +156,28 @@ test_expect_success 'setup r3' '
 '
 
 test_expect_success 'verify sparse:path=pattern1 omits top-level files' '
-	git -C r3 ls-files -s sparse1 sparse2 \
-		| awk -f print_2.awk \
-		| sort >expected &&
-	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:path=../pattern1 \
-		| awk -f print_1.awk \
-		| sed "s/~//" \
-		| sort >observed &&
+	git -C r3 ls-files -s sparse1 sparse2 |
+	awk -f print_2.awk |
+	sort >expected &&
+
+	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:path=../pattern1 |
+	awk -f print_1.awk |
+	sed "s/~//" |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify sparse:path=pattern2 omits both sparse2 files' '
-	git -C r3 ls-files -s sparse2 dir1/sparse2 \
-		| awk -f print_2.awk \
-		| sort >expected &&
-	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:path=../pattern2 \
-		| awk -f print_1.awk \
-		| sed "s/~//" \
-		| sort >observed &&
+	git -C r3 ls-files -s sparse2 dir1/sparse2 |
+	awk -f print_2.awk |
+	sort >expected &&
+
+	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:path=../pattern2 |
+	awk -f print_1.awk |
+	sed "s/~//" |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
@@ -173,25 +192,30 @@ test_expect_success 'setup r3 part 2' '
 '
 
 test_expect_success 'verify sparse:oid=OID omits top-level files' '
-	git -C r3 ls-files -s pattern sparse1 sparse2 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r3 ls-files -s pattern sparse1 sparse2 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	oid=$(git -C r3 ls-files -s pattern | awk -f print_2.awk) &&
-	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:oid=$oid \
-		| awk -f print_1.awk \
-		| sed "s/~//" \
-		| sort >observed &&
+
+	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:oid=$oid |
+	awk -f print_1.awk |
+	sed "s/~//" |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify sparse:oid=oid-ish omits top-level files' '
-	git -C r3 ls-files -s pattern sparse1 sparse2 \
-		| awk -f print_2.awk \
-		| sort >expected &&
-	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:oid=master:pattern \
-		| awk -f print_1.awk \
-		| sed "s/~//" \
-		| sort >observed &&
+	git -C r3 ls-files -s pattern sparse1 sparse2 |
+	awk -f print_2.awk |
+	sort >expected &&
+
+	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:oid=master:pattern |
+	awk -f print_1.awk |
+	sed "s/~//" |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
@@ -199,17 +223,20 @@ test_expect_success 'verify sparse:oid=oid-ish omits top-level files' '
 # This models previously omitted objects that we did not receive.
 
 test_expect_success 'rev-list W/ --missing=print' '
-	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	for id in `cat expected | sed "s|..|&/|"`
 	do
 		rm r1/.git/objects/$id
 	done &&
-	git -C r1 rev-list --quiet HEAD --missing=print --objects \
-		| awk -f print_1.awk \
-		| sed "s/?//" \
-		| sort >observed &&
+
+	git -C r1 rev-list --quiet HEAD --missing=print --objects |
+	awk -f print_1.awk |
+	sed "s/?//" |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
diff --git a/t/t9101-git-svn-props.sh b/t/t9101-git-svn-props.sh
index 8a5c8dc1a..efe79fe55 100755
--- a/t/t9101-git-svn-props.sh
+++ b/t/t9101-git-svn-props.sh
@@ -193,8 +193,8 @@ test_expect_success 'test propget' "
 	git svn propget svn:ignore . | cmp - prop.expect &&
 	cd deeply &&
 	git svn propget svn:ignore . | cmp - ../prop.expect &&
-	git svn propget svn:entry:committed-rev nested/directory/.keep \
-	  | cmp - ../prop2.expect &&
+	git svn propget svn:entry:committed-rev nested/directory/.keep |
+	cmp - ../prop2.expect &&
 	git svn propget svn:ignore .. | cmp - ../prop.expect &&
 	git svn propget svn:ignore nested/ | cmp - ../prop.expect &&
 	git svn propget svn:ignore ./nested | cmp - ../prop.expect &&
-- 
2.19.0.397.gdd90340f6a-goog


^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [PATCH v1 2/2] t/*: fix ordering of expected/observed arguments
  2018-09-15  0:02 [PATCH v1 0/2] Cleanup tests for test_cmp argument ordering and "|" placement Matthew DeVore
  2018-09-15  0:02 ` [PATCH v1 1/2] t/*: fix pipe placement and remove \'s Matthew DeVore
@ 2018-09-15  0:02 ` Matthew DeVore
  2018-09-17 12:56   ` Matthew DeVore
  2018-09-15 15:55 ` [PATCH v1 0/2] Cleanup tests for test_cmp argument ordering and "|" placement Junio C Hamano
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 66+ messages in thread
From: Matthew DeVore @ 2018-09-15  0:02 UTC (permalink / raw)
  To: git; +Cc: Matthew DeVore, peff, jonathantanmy, gitster, bmwill

This fixes various places where the ordering was obviously wrong and it
was either related to other patches in this patchset or was easy
find with grep.

Signed-off-by: Matthew DeVore <matvore@google.com>
---
 t/t0000-basic.sh                       |  2 +-
 t/t0021-conversion.sh                  |  4 +--
 t/t1300-config.sh                      |  4 +--
 t/t1303-wacky-config.sh                |  4 +--
 t/t2101-update-index-reupdate.sh       |  2 +-
 t/t3200-branch.sh                      |  2 +-
 t/t3320-notes-merge-worktrees.sh       |  4 +--
 t/t3400-rebase.sh                      |  8 +++---
 t/t3417-rebase-whitespace-fix.sh       |  6 ++---
 t/t3702-add-edit.sh                    |  4 +--
 t/t3903-stash.sh                       |  8 +++---
 t/t3905-stash-include-untracked.sh     |  2 +-
 t/t4025-hunk-header.sh                 |  2 +-
 t/t4117-apply-reject.sh                |  6 ++---
 t/t4124-apply-ws-rule.sh               | 30 +++++++++++------------
 t/t4138-apply-ws-expansion.sh          |  2 +-
 t/t5317-pack-objects-filter-objects.sh | 34 +++++++++++++-------------
 t/t5318-commit-graph.sh                |  2 +-
 t/t5701-git-serve.sh                   | 14 +++++------
 t/t5702-protocol-v2.sh                 | 10 ++++----
 t/t6023-merge-file.sh                  | 12 ++++-----
 t/t6027-merge-binary.sh                |  4 +--
 t/t6031-merge-filemode.sh              |  2 +-
 t/t6112-rev-list-filters-objects.sh    | 24 +++++++++---------
 t/t7201-co.sh                          |  4 +--
 t/t7406-submodule-update.sh            |  8 +++---
 t/t7508-status.sh                      |  2 +-
 t/t7800-difftool.sh                    |  2 +-
 t/t9100-git-svn-basic.sh               |  2 +-
 t/t9133-git-svn-nested-git-repo.sh     |  6 ++---
 t/t9600-cvsimport.sh                   |  2 +-
 t/t9603-cvsimport-patchsets.sh         |  4 +--
 t/t9604-cvsimport-timestamps.sh        |  4 +--
 33 files changed, 113 insertions(+), 113 deletions(-)

diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh
index 850f651e4..224c098a8 100755
--- a/t/t0000-basic.sh
+++ b/t/t0000-basic.sh
@@ -1018,7 +1018,7 @@ test_expect_success SHA1 'validate git diff-files output for a know cache/work t
 :120000 120000 6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c 0000000000000000000000000000000000000000 M	path3/subp3/file3sym
 EOF
 	git diff-files >current &&
-	test_cmp current expected
+	test_cmp expected current
 '
 
 test_expect_success 'git update-index --refresh should succeed' '
diff --git a/t/t0021-conversion.sh b/t/t0021-conversion.sh
index 308cd28f3..fd5f1ac64 100755
--- a/t/t0021-conversion.sh
+++ b/t/t0021-conversion.sh
@@ -166,10 +166,10 @@ test_expect_success expanded_in_repo '
 	rm -f expanded-keywords expanded-keywords-crlf &&
 
 	git checkout -- expanded-keywords &&
-	test_cmp expanded-keywords expected-output &&
+	test_cmp expected-output expanded-keywords &&
 
 	git checkout -- expanded-keywords-crlf &&
-	test_cmp expanded-keywords-crlf expected-output-crlf
+	test_cmp expected-output-crlf expanded-keywords-crlf
 '
 
 # The use of %f in a filter definition is expanded to the path to
diff --git a/t/t1300-config.sh b/t/t1300-config.sh
index 5869d6cb6..e2cd50ecf 100755
--- a/t/t1300-config.sh
+++ b/t/t1300-config.sh
@@ -1001,7 +1001,7 @@ EOF
 
 test_expect_success 'value continued on next line' '
 	git config --list > result &&
-	test_cmp result expect
+	test_cmp expect result
 '
 
 cat > .git/config <<\EOF
@@ -1882,7 +1882,7 @@ test_expect_success '--replace-all does not invent newlines' '
 	Qkey = b
 	EOF
 	git config --replace-all abc.key b &&
-	test_cmp .git/config expect
+	test_cmp expect .git/config
 '
 
 test_done
diff --git a/t/t1303-wacky-config.sh b/t/t1303-wacky-config.sh
index 3b92083e1..0000e664e 100755
--- a/t/t1303-wacky-config.sh
+++ b/t/t1303-wacky-config.sh
@@ -14,7 +14,7 @@ setup() {
 check() {
 	echo "$2" >expected
 	git config --get "$1" >actual 2>&1
-	test_cmp actual expected
+	test_cmp expected actual
 }
 
 # 'check section.key regex value' verifies that the entry for
@@ -22,7 +22,7 @@ check() {
 check_regex() {
 	echo "$3" >expected
 	git config --get "$1" "$2" >actual 2>&1
-	test_cmp actual expected
+	test_cmp expected actual
 }
 
 test_expect_success 'modify same key' '
diff --git a/t/t2101-update-index-reupdate.sh b/t/t2101-update-index-reupdate.sh
index 685ec4563..6c32d42c8 100755
--- a/t/t2101-update-index-reupdate.sh
+++ b/t/t2101-update-index-reupdate.sh
@@ -73,7 +73,7 @@ test_expect_success 'update-index --update from subdir' '
 	100644 $(git hash-object dir1/file3) 0	dir1/file3
 	100644 $file2 0	file2
 	EOF
-	test_cmp current expected
+	test_cmp expected current
 '
 
 test_expect_success 'update-index --update with pathspec' '
diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index 93f21ab07..478b82cf9 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -1221,7 +1221,7 @@ test_expect_success 'use --edit-description' '
 	EOF
 	EDITOR=./editor git branch --edit-description &&
 	echo "New contents" >expect &&
-	test_cmp EDITOR_OUTPUT expect
+	test_cmp expect EDITOR_OUTPUT
 '
 
 test_expect_success 'detect typo in branch name when using --edit-description' '
diff --git a/t/t3320-notes-merge-worktrees.sh b/t/t3320-notes-merge-worktrees.sh
index 10bfc8b94..823fdbda1 100755
--- a/t/t3320-notes-merge-worktrees.sh
+++ b/t/t3320-notes-merge-worktrees.sh
@@ -44,7 +44,7 @@ test_expect_success 'merge z into y fails and sets NOTES_MERGE_REF' '
 	git config core.notesRef refs/notes/y &&
 	test_must_fail git notes merge z &&
 	echo "ref: refs/notes/y" >expect &&
-	test_cmp .git/NOTES_MERGE_REF expect
+	test_cmp expect .git/NOTES_MERGE_REF
 '
 
 test_expect_success 'merge z into y while mid-merge in another workdir fails' '
@@ -66,7 +66,7 @@ test_expect_success 'merge z into x while mid-merge on y succeeds' '
 		grep -v "A notes merge into refs/notes/x is already in-progress in" out
 	) &&
 	echo "ref: refs/notes/x" >expect &&
-	test_cmp .git/worktrees/worktree2/NOTES_MERGE_REF expect
+	test_cmp expect .git/worktrees/worktree2/NOTES_MERGE_REF
 '
 
 test_done
diff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh
index 3996ee013..3e73f7584 100755
--- a/t/t3400-rebase.sh
+++ b/t/t3400-rebase.sh
@@ -183,13 +183,13 @@ test_expect_success 'cherry-picked commits and fork-point work together' '
 	test_commit final_B B "Final B" &&
 	git rebase &&
 	echo Amended >expect &&
-	test_cmp A expect &&
+	test_cmp expect A &&
 	echo "Final B" >expect &&
-	test_cmp B expect &&
+	test_cmp expect B &&
 	echo C >expect &&
-	test_cmp C expect &&
+	test_cmp expect C &&
 	echo D >expect &&
-	test_cmp D expect
+	test_cmp expect D
 '
 
 test_expect_success 'rebase -q is quiet' '
diff --git a/t/t3417-rebase-whitespace-fix.sh b/t/t3417-rebase-whitespace-fix.sh
index 1fb3e499b..e85cdc703 100755
--- a/t/t3417-rebase-whitespace-fix.sh
+++ b/t/t3417-rebase-whitespace-fix.sh
@@ -55,7 +55,7 @@ test_expect_success 'blank line at end of file; extend at end of file' '
 	git add file &&	git commit -m second &&
 	git rebase --whitespace=fix HEAD^^ &&
 	git diff --exit-code HEAD^:file expect-first &&
-	test_cmp file expect-second
+	test_cmp expect-second file
 '
 
 # prepare third revision of "file"
@@ -82,7 +82,7 @@ test_expect_success 'two blanks line at end of file; extend at end of file' '
 	cp third file && git add file && git commit -m third &&
 	git rebase --whitespace=fix HEAD^^ &&
 	git diff --exit-code HEAD^:file expect-second &&
-	test_cmp file expect-third
+	test_cmp expect-third file
 '
 
 test_expect_success 'same, but do not remove trailing spaces' '
@@ -120,7 +120,7 @@ test_expect_success 'at beginning of file' '
 	done >> file &&
 	git commit -m more file	&&
 	git rebase --whitespace=fix HEAD^^ &&
-	test_cmp file expect-beginning
+	test_cmp expect-beginning file
 '
 
 test_done
diff --git a/t/t3702-add-edit.sh b/t/t3702-add-edit.sh
index c6af7f82b..6c676645d 100755
--- a/t/t3702-add-edit.sh
+++ b/t/t3702-add-edit.sh
@@ -110,10 +110,10 @@ test_expect_success 'add -e' '
 	cp second-part file &&
 	git add -e &&
 	test_cmp second-part file &&
-	test_cmp orig-patch expected-patch &&
+	test_cmp expected-patch orig-patch &&
 	git diff --cached >actual &&
 	grep -v index actual >out &&
-	test_cmp out expected
+	test_cmp expected out
 
 '
 
diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh
index 6450bc669..cd216655b 100755
--- a/t/t3903-stash.sh
+++ b/t/t3903-stash.sh
@@ -36,7 +36,7 @@ EOF
 test_expect_success 'parents of stash' '
 	test $(git rev-parse stash^) = $(git rev-parse HEAD) &&
 	git diff stash^2..stash > output &&
-	test_cmp output expect
+	test_cmp expect output
 '
 
 test_expect_success 'applying bogus stash does nothing' '
@@ -210,9 +210,9 @@ test_expect_success 'stash branch' '
 	test refs/heads/stashbranch = $(git symbolic-ref HEAD) &&
 	test $(git rev-parse HEAD) = $(git rev-parse master^) &&
 	git diff --cached > output &&
-	test_cmp output expect &&
+	test_cmp expect output &&
 	git diff > output &&
-	test_cmp output expect1 &&
+	test_cmp expect1 output &&
 	git add file &&
 	git commit -m alternate\ second &&
 	git diff master..stashbranch > output &&
@@ -710,7 +710,7 @@ test_expect_success 'stash where working directory contains "HEAD" file' '
 	git diff-index --cached --quiet HEAD &&
 	test "$(git rev-parse stash^)" = "$(git rev-parse HEAD)" &&
 	git diff stash^..stash > output &&
-	test_cmp output expect
+	test_cmp expect output
 '
 
 test_expect_success 'store called with invalid commit' '
diff --git a/t/t3905-stash-include-untracked.sh b/t/t3905-stash-include-untracked.sh
index 597b0637d..cc1c8a7bb 100755
--- a/t/t3905-stash-include-untracked.sh
+++ b/t/t3905-stash-include-untracked.sh
@@ -142,7 +142,7 @@ test_expect_success 'stash save --include-untracked removed files' '
 	rm -f file &&
 	git stash save --include-untracked &&
 	echo 1 > expect &&
-	test_cmp file expect
+	test_cmp expect file
 '
 
 rm -f expect
diff --git a/t/t4025-hunk-header.sh b/t/t4025-hunk-header.sh
index fa44e7886..35578f2bb 100755
--- a/t/t4025-hunk-header.sh
+++ b/t/t4025-hunk-header.sh
@@ -37,7 +37,7 @@ test_expect_success 'hunk header truncation with an overly long line' '
 		echo " A $N$N$N$N$N$N$N$N$N2" &&
 		echo " L  $N$N$N$N$N$N$N$N$N1"
 	) >expected &&
-	test_cmp actual expected
+	test_cmp expected actual
 
 '
 
diff --git a/t/t4117-apply-reject.sh b/t/t4117-apply-reject.sh
index d80187de9..f7de6f077 100755
--- a/t/t4117-apply-reject.sh
+++ b/t/t4117-apply-reject.sh
@@ -72,7 +72,7 @@ test_expect_success 'apply with --reject should fail but update the file' '
 	rm -f file1.rej file2.rej &&
 
 	test_must_fail git apply --reject patch.1 &&
-	test_cmp file1 expected &&
+	test_cmp expected file1 &&
 
 	cat file1.rej &&
 	test_path_is_missing file2.rej
@@ -85,7 +85,7 @@ test_expect_success 'apply with --reject should fail but update the file' '
 
 	test_must_fail git apply --reject patch.2 >rejects &&
 	test_path_is_missing file1 &&
-	test_cmp file2 expected &&
+	test_cmp expected file2 &&
 
 	cat file2.rej &&
 	test_path_is_missing file1.rej
@@ -99,7 +99,7 @@ test_expect_success 'the same test with --verbose' '
 
 	test_must_fail git apply --reject --verbose patch.2 >rejects &&
 	test_path_is_missing file1 &&
-	test_cmp file2 expected &&
+	test_cmp expected file2 &&
 
 	cat file2.rej &&
 	test_path_is_missing file1.rej
diff --git a/t/t4124-apply-ws-rule.sh b/t/t4124-apply-ws-rule.sh
index 7e32237a2..ff51e9e78 100755
--- a/t/t4124-apply-ws-rule.sh
+++ b/t/t4124-apply-ws-rule.sh
@@ -313,9 +313,9 @@ test_expect_success 'applying beyond EOF requires one non-blank context line' '
 	{ echo a; echo; } >one &&
 	cp one expect &&
 	test_must_fail git apply --whitespace=fix patch &&
-	test_cmp one expect &&
+	test_cmp expect one &&
 	test_must_fail git apply --ignore-space-change --whitespace=fix patch &&
-	test_cmp one expect
+	test_cmp expect one
 '
 
 test_expect_success 'tons of blanks at EOF should not apply' '
@@ -342,10 +342,10 @@ test_expect_success 'missing blank line at end with --whitespace=fix' '
 	cp one saved-one &&
 	test_must_fail git apply patch &&
 	git apply --whitespace=fix patch &&
-	test_cmp one expect &&
+	test_cmp expect one &&
 	mv saved-one one &&
 	git apply --ignore-space-change --whitespace=fix patch &&
-	test_cmp one expect
+	test_cmp expect one
 '
 
 test_expect_success 'two missing blank lines at end with --whitespace=fix' '
@@ -360,11 +360,11 @@ test_expect_success 'two missing blank lines at end with --whitespace=fix' '
 	cp no-blank-lines one &&
 	test_must_fail git apply patch &&
 	git apply --whitespace=fix patch &&
-	test_cmp one expect &&
+	test_cmp expect one &&
 	mv no-blank-lines one &&
 	test_must_fail git apply patch &&
 	git apply --ignore-space-change --whitespace=fix patch &&
-	test_cmp one expect
+	test_cmp expect one
 '
 
 test_expect_success 'missing blank line at end, insert before end, --whitespace=fix' '
@@ -376,7 +376,7 @@ test_expect_success 'missing blank line at end, insert before end, --whitespace=
 	echo a >one &&
 	test_must_fail git apply patch &&
 	git apply --whitespace=fix patch &&
-	test_cmp one expect
+	test_cmp expect one
 '
 
 test_expect_success 'shrink file with tons of missing blanks at end of file' '
@@ -392,10 +392,10 @@ test_expect_success 'shrink file with tons of missing blanks at end of file' '
 	cp no-blank-lines one &&
 	test_must_fail git apply patch &&
 	git apply --whitespace=fix patch &&
-	test_cmp one expect &&
+	test_cmp expect one &&
 	mv no-blank-lines one &&
 	git apply --ignore-space-change --whitespace=fix patch &&
-	test_cmp one expect
+	test_cmp expect one
 '
 
 test_expect_success 'missing blanks at EOF must only match blank lines' '
@@ -427,7 +427,7 @@ test_expect_success 'missing blank line should match context line with spaces' '
 	git add one &&
 
 	git apply --whitespace=fix patch &&
-	test_cmp one expect
+	test_cmp expect one
 '
 
 sed -e's/Z//' >one <<EOF
@@ -447,7 +447,7 @@ test_expect_success 'same, but with the --ignore-space-option' '
 
 	git checkout-index -f one &&
 	git apply --ignore-space-change --whitespace=fix patch &&
-	test_cmp one expect
+	test_cmp expect one
 '
 
 test_expect_success 'same, but with CR-LF line endings && cr-at-eol set' '
@@ -464,7 +464,7 @@ test_expect_success 'same, but with CR-LF line endings && cr-at-eol set' '
 	mv save-one one &&
 
 	git apply --ignore-space-change --whitespace=fix patch &&
-	test_cmp one expect
+	test_cmp expect one
 '
 
 test_expect_success 'CR-LF line endings && add line && text=auto' '
@@ -478,7 +478,7 @@ test_expect_success 'CR-LF line endings && add line && text=auto' '
 	mv save-one one &&
 	echo "one text=auto" >.gitattributes &&
 	git apply patch &&
-	test_cmp one expect
+	test_cmp expect one
 '
 
 test_expect_success 'CR-LF line endings && change line && text=auto' '
@@ -491,7 +491,7 @@ test_expect_success 'CR-LF line endings && change line && text=auto' '
 	mv save-one one &&
 	echo "one text=auto" >.gitattributes &&
 	git apply patch &&
-	test_cmp one expect
+	test_cmp expect one
 '
 
 test_expect_success 'LF in repo, CRLF in worktree && change line && text=auto' '
@@ -503,7 +503,7 @@ test_expect_success 'LF in repo, CRLF in worktree && change line && text=auto' '
 	echo "one text=auto" >.gitattributes &&
 	git -c core.eol=CRLF apply patch &&
 	printf "b\r\n" >expect &&
-	test_cmp one expect
+	test_cmp expect one
 '
 
 test_expect_success 'whitespace=fix to expand' '
diff --git a/t/t4138-apply-ws-expansion.sh b/t/t4138-apply-ws-expansion.sh
index 0ffe33fbe..3b636a63a 100755
--- a/t/t4138-apply-ws-expansion.sh
+++ b/t/t4138-apply-ws-expansion.sh
@@ -114,7 +114,7 @@ for t in 1 2 3 4
 do
 	test_expect_success 'apply with ws expansion (t=$t)' '
 		git apply patch$t.patch &&
-		test_cmp test-$t expect-$t
+		test_cmp expect-$t test-$t
 	'
 done
 
diff --git a/t/t5317-pack-objects-filter-objects.sh b/t/t5317-pack-objects-filter-objects.sh
index ce69148ec..c093eb891 100755
--- a/t/t5317-pack-objects-filter-objects.sh
+++ b/t/t5317-pack-objects-filter-objects.sh
@@ -34,7 +34,7 @@ test_expect_success 'verify blob count in normal packfile' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify blob:none packfile has no blobs' '
@@ -63,7 +63,7 @@ test_expect_success 'verify normal and blob:none packfiles have same commits/tre
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 # Test blob:limit=<n>[kmg] filter.
@@ -96,7 +96,7 @@ test_expect_success 'verify blob count in normal packfile' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify blob:limit=500 omits all blobs' '
@@ -144,7 +144,7 @@ test_expect_success 'verify blob:limit=1001' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify blob:limit=10001' '
@@ -162,7 +162,7 @@ test_expect_success 'verify blob:limit=10001' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify blob:limit=1k' '
@@ -180,7 +180,7 @@ test_expect_success 'verify blob:limit=1k' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify explicitly specifying oversized blob in input' '
@@ -199,7 +199,7 @@ test_expect_success 'verify explicitly specifying oversized blob in input' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify blob:limit=1m' '
@@ -217,7 +217,7 @@ test_expect_success 'verify blob:limit=1m' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify normal and blob:limit packfiles have same commits/trees' '
@@ -231,7 +231,7 @@ test_expect_success 'verify normal and blob:limit packfiles have same commits/tr
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 # Test sparse:path=<path> filter.
@@ -269,7 +269,7 @@ test_expect_success 'verify blob count in normal packfile' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify sparse:path=pattern1' '
@@ -287,7 +287,7 @@ test_expect_success 'verify sparse:path=pattern1' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify normal and sparse:path=pattern1 packfiles have same commits/trees' '
@@ -301,7 +301,7 @@ test_expect_success 'verify normal and sparse:path=pattern1 packfiles have same
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify sparse:path=pattern2' '
@@ -319,7 +319,7 @@ test_expect_success 'verify sparse:path=pattern2' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify normal and sparse:path=pattern2 packfiles have same commits/trees' '
@@ -333,7 +333,7 @@ test_expect_success 'verify normal and sparse:path=pattern2 packfiles have same
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 # Test sparse:oid=<oid-ish> filter.
@@ -370,7 +370,7 @@ test_expect_success 'verify blob count in normal packfile' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify sparse:oid=OID' '
@@ -389,7 +389,7 @@ test_expect_success 'verify sparse:oid=OID' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify sparse:oid=oid-ish' '
@@ -407,7 +407,7 @@ test_expect_success 'verify sparse:oid=oid-ish' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 # Delete some loose objects and use pack-objects, but WITHOUT any filtering.
diff --git a/t/t5318-commit-graph.sh b/t/t5318-commit-graph.sh
index 0c500f7ca..d6da3ce4e 100755
--- a/t/t5318-commit-graph.sh
+++ b/t/t5318-commit-graph.sh
@@ -35,7 +35,7 @@ test_expect_success 'create commits and repack' '
 graph_git_two_modes() {
 	git -c core.commitGraph=true $1 >output
 	git -c core.commitGraph=false $1 >expect
-	test_cmp output expect
+	test_cmp expect output
 }
 
 graph_git_behavior() {
diff --git a/t/t5701-git-serve.sh b/t/t5701-git-serve.sh
index 75ec79e6c..bf139e245 100755
--- a/t/t5701-git-serve.sh
+++ b/t/t5701-git-serve.sh
@@ -16,7 +16,7 @@ test_expect_success 'test capability advertisement' '
 
 	git serve --advertise-capabilities >out &&
 	test-pkt-line unpack <out >actual &&
-	test_cmp actual expect
+	test_cmp expect actual
 '
 
 test_expect_success 'stateless-rpc flag does not list capabilities' '
@@ -89,7 +89,7 @@ test_expect_success 'basics of ls-refs' '
 
 	git serve --stateless-rpc <in >out &&
 	test-pkt-line unpack <out >actual &&
-	test_cmp actual expect
+	test_cmp expect actual
 '
 
 test_expect_success 'basic ref-prefixes' '
@@ -109,7 +109,7 @@ test_expect_success 'basic ref-prefixes' '
 
 	git serve --stateless-rpc <in >out &&
 	test-pkt-line unpack <out >actual &&
-	test_cmp actual expect
+	test_cmp expect actual
 '
 
 test_expect_success 'refs/heads prefix' '
@@ -129,7 +129,7 @@ test_expect_success 'refs/heads prefix' '
 
 	git serve --stateless-rpc <in >out &&
 	test-pkt-line unpack <out >actual &&
-	test_cmp actual expect
+	test_cmp expect actual
 '
 
 test_expect_success 'peel parameter' '
@@ -150,7 +150,7 @@ test_expect_success 'peel parameter' '
 
 	git serve --stateless-rpc <in >out &&
 	test-pkt-line unpack <out >actual &&
-	test_cmp actual expect
+	test_cmp expect actual
 '
 
 test_expect_success 'symrefs parameter' '
@@ -171,7 +171,7 @@ test_expect_success 'symrefs parameter' '
 
 	git serve --stateless-rpc <in >out &&
 	test-pkt-line unpack <out >actual &&
-	test_cmp actual expect
+	test_cmp expect actual
 '
 
 test_expect_success 'sending server-options' '
@@ -191,7 +191,7 @@ test_expect_success 'sending server-options' '
 
 	git serve --stateless-rpc <in >out &&
 	test-pkt-line unpack <out >actual &&
-	test_cmp actual expect
+	test_cmp expect actual
 '
 
 test_expect_success 'unexpected lines are not allowed in fetch request' '
diff --git a/t/t5702-protocol-v2.sh b/t/t5702-protocol-v2.sh
index 3beeed454..54727450b 100755
--- a/t/t5702-protocol-v2.sh
+++ b/t/t5702-protocol-v2.sh
@@ -29,7 +29,7 @@ test_expect_success 'list refs with git:// using protocol v2' '
 	grep "git< version 2" log &&
 
 	git ls-remote --symref "$GIT_DAEMON_URL/parent" >expect &&
-	test_cmp actual expect
+	test_cmp expect actual
 '
 
 test_expect_success 'ref advertisment is filtered with ls-remote using protocol v2' '
@@ -42,7 +42,7 @@ test_expect_success 'ref advertisment is filtered with ls-remote using protocol
 	$(git -C "$daemon_parent" rev-parse refs/heads/master)$(printf "\t")refs/heads/master
 	EOF
 
-	test_cmp actual expect
+	test_cmp expect actual
 '
 
 test_expect_success 'clone with git:// using protocol v2' '
@@ -138,7 +138,7 @@ test_expect_success 'list refs with file:// using protocol v2' '
 	grep "git< version 2" log &&
 
 	git ls-remote --symref "file://$(pwd)/file_parent" >expect &&
-	test_cmp actual expect
+	test_cmp expect actual
 '
 
 test_expect_success 'ref advertisment is filtered with ls-remote using protocol v2' '
@@ -151,7 +151,7 @@ test_expect_success 'ref advertisment is filtered with ls-remote using protocol
 	$(git -C file_parent rev-parse refs/heads/master)$(printf "\t")refs/heads/master
 	EOF
 
-	test_cmp actual expect
+	test_cmp expect actual
 '
 
 test_expect_success 'server-options are sent when using ls-remote' '
@@ -164,7 +164,7 @@ test_expect_success 'server-options are sent when using ls-remote' '
 	$(git -C file_parent rev-parse refs/heads/master)$(printf "\t")refs/heads/master
 	EOF
 
-	test_cmp actual expect &&
+	test_cmp expect actual &&
 	grep "server-option=hello" log &&
 	grep "server-option=world" log
 '
diff --git a/t/t6023-merge-file.sh b/t/t6023-merge-file.sh
index 20aee43f9..51ee887a7 100755
--- a/t/t6023-merge-file.sh
+++ b/t/t6023-merge-file.sh
@@ -99,7 +99,7 @@ EOF
 printf "propter nomen suum." >> expect.txt
 
 test_expect_success "merge does not add LF away of change" \
-	"test_cmp test3.txt expect.txt"
+	"test_cmp expect.txt test3.txt"
 
 cp test.txt backup.txt
 test_expect_success "merge with conflicts" \
@@ -122,7 +122,7 @@ non timebo mala, quoniam tu mecum es:
 virga tua et baculus tuus ipsa me consolata sunt.
 EOF
 
-test_expect_success "expected conflict markers" "test_cmp test.txt expect.txt"
+test_expect_success "expected conflict markers" "test_cmp expect.txt test.txt"
 
 cp backup.txt test.txt
 
@@ -138,7 +138,7 @@ non timebo mala, quoniam tu mecum es:
 virga tua et baculus tuus ipsa me consolata sunt.
 EOF
 test_expect_success "merge conflicting with --ours" \
-	"git merge-file --ours test.txt orig.txt new3.txt && test_cmp test.txt expect.txt"
+	"git merge-file --ours test.txt orig.txt new3.txt && test_cmp expect.txt test.txt"
 cp backup.txt test.txt
 
 cat > expect.txt << EOF
@@ -154,7 +154,7 @@ non timebo mala, quoniam tu mecum es:
 virga tua et baculus tuus ipsa me consolata sunt.
 EOF
 test_expect_success "merge conflicting with --theirs" \
-	"git merge-file --theirs test.txt orig.txt new3.txt && test_cmp test.txt expect.txt"
+	"git merge-file --theirs test.txt orig.txt new3.txt && test_cmp expect.txt test.txt"
 cp backup.txt test.txt
 
 cat > expect.txt << EOF
@@ -171,7 +171,7 @@ non timebo mala, quoniam tu mecum es:
 virga tua et baculus tuus ipsa me consolata sunt.
 EOF
 test_expect_success "merge conflicting with --union" \
-	"git merge-file --union test.txt orig.txt new3.txt && test_cmp test.txt expect.txt"
+	"git merge-file --union test.txt orig.txt new3.txt && test_cmp expect.txt test.txt"
 cp backup.txt test.txt
 
 test_expect_success "merge with conflicts, using -L" \
@@ -195,7 +195,7 @@ virga tua et baculus tuus ipsa me consolata sunt.
 EOF
 
 test_expect_success "expected conflict markers, with -L" \
-	"test_cmp test.txt expect.txt"
+	"test_cmp expect.txt test.txt"
 
 sed "s/ tu / TU /" < new1.txt > new5.txt
 test_expect_success "conflict in removed tail" \
diff --git a/t/t6027-merge-binary.sh b/t/t6027-merge-binary.sh
index 07735410b..4e6c7cb77 100755
--- a/t/t6027-merge-binary.sh
+++ b/t/t6027-merge-binary.sh
@@ -45,7 +45,7 @@ test_expect_success resolve '
 		false
 	else
 		git ls-files -s >current
-		test_cmp current expect
+		test_cmp expect current
 	fi
 '
 
@@ -60,7 +60,7 @@ test_expect_success recursive '
 		false
 	else
 		git ls-files -s >current
-		test_cmp current expect
+		test_cmp expect current
 	fi
 '
 
diff --git a/t/t6031-merge-filemode.sh b/t/t6031-merge-filemode.sh
index 7d06461f1..87741efad 100755
--- a/t/t6031-merge-filemode.sh
+++ b/t/t6031-merge-filemode.sh
@@ -61,7 +61,7 @@ do_both_modes () {
 		git checkout -f a2 &&
 		test_must_fail git merge -s $strategy b2 &&
 		git ls-files -u >actual &&
-		test_cmp actual expect &&
+		test_cmp expect actual &&
 		git ls-files -s file2 | grep ^100755
 	'
 
diff --git a/t/t6112-rev-list-filters-objects.sh b/t/t6112-rev-list-filters-objects.sh
index 0f6b569e1..ae4402226 100755
--- a/t/t6112-rev-list-filters-objects.sh
+++ b/t/t6112-rev-list-filters-objects.sh
@@ -29,7 +29,7 @@ test_expect_success 'verify blob:none omits all 5 blobs' '
 	sed "s/~//" |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify emitted+omitted == all' '
@@ -42,7 +42,7 @@ test_expect_success 'verify emitted+omitted == all' '
 	sed "s/~//" |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 
@@ -71,7 +71,7 @@ test_expect_success 'verify blob:limit=500 omits all blobs' '
 	sed "s/~//" |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify emitted+omitted == all' '
@@ -84,7 +84,7 @@ test_expect_success 'verify emitted+omitted == all' '
 	sed "s/~//" |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify blob:limit=1000' '
@@ -97,7 +97,7 @@ test_expect_success 'verify blob:limit=1000' '
 	sed "s/~//" |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify blob:limit=1001' '
@@ -110,7 +110,7 @@ test_expect_success 'verify blob:limit=1001' '
 	sed "s/~//" |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify blob:limit=1k' '
@@ -123,7 +123,7 @@ test_expect_success 'verify blob:limit=1k' '
 	sed "s/~//" |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify blob:limit=1m' '
@@ -165,7 +165,7 @@ test_expect_success 'verify sparse:path=pattern1 omits top-level files' '
 	sed "s/~//" |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify sparse:path=pattern2 omits both sparse2 files' '
@@ -178,7 +178,7 @@ test_expect_success 'verify sparse:path=pattern2 omits both sparse2 files' '
 	sed "s/~//" |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 # Test sparse:oid=<oid-ish> filter.
@@ -203,7 +203,7 @@ test_expect_success 'verify sparse:oid=OID omits top-level files' '
 	sed "s/~//" |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify sparse:oid=oid-ish omits top-level files' '
@@ -216,7 +216,7 @@ test_expect_success 'verify sparse:oid=oid-ish omits top-level files' '
 	sed "s/~//" |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 # Delete some loose objects and use rev-list, but WITHOUT any filtering.
@@ -237,7 +237,7 @@ test_expect_success 'rev-list W/ --missing=print' '
 	sed "s/?//" |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'rev-list W/O --missing fails' '
diff --git a/t/t7201-co.sh b/t/t7201-co.sh
index 324933acf..826987ca8 100755
--- a/t/t7201-co.sh
+++ b/t/t7201-co.sh
@@ -160,7 +160,7 @@ test_expect_success 'checkout -m with merge conflict' '
 	git diff master:one :3:uno |
 	sed -e "1,/^@@/d" -e "/^ /d" -e "s/^-/d/" -e "s/^+/a/" >current &&
 	fill d2 aT d7 aS >expect &&
-	test_cmp current expect &&
+	test_cmp expect current &&
 	git diff --cached two >current &&
 	test_must_be_empty current
 '
@@ -174,7 +174,7 @@ test_expect_success 'format of merge conflict from checkout -m' '
 
 	git ls-files >current &&
 	fill same two two two >expect &&
-	test_cmp current expect &&
+	test_cmp expect current &&
 
 	cat <<-EOF >expect &&
 	<<<<<<< simple
diff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh
index 10dc91620..e87164aa8 100755
--- a/t/t7406-submodule-update.sh
+++ b/t/t7406-submodule-update.sh
@@ -789,7 +789,7 @@ test_expect_success 'submodule add places git-dir in superprojects git-dir' '
 	 (cd .git/modules/deeper/submodule &&
 	  git log > ../../../../actual
 	 ) &&
-	 test_cmp actual expected
+	 test_cmp expected actual
 	)
 '
 
@@ -807,7 +807,7 @@ test_expect_success 'submodule update places git-dir in superprojects git-dir' '
 	 (cd .git/modules/deeper/submodule &&
 	  git log > ../../../../actual
 	 ) &&
-	 test_cmp actual expected
+	 test_cmp expected actual
 	)
 '
 
@@ -827,7 +827,7 @@ test_expect_success 'submodule add places git-dir in superprojects git-dir recur
 	 git add deeper/submodule &&
 	 git commit -m "update submodule" &&
 	 git push origin : &&
-	 test_cmp actual expected
+	 test_cmp expected actual
 	)
 '
 
@@ -874,7 +874,7 @@ test_expect_success 'submodule update places git-dir in superprojects git-dir re
 	 (cd .git/modules/submodule/modules/subsubmodule &&
 	  git log > ../../../../../actual
 	 ) &&
-	 test_cmp actual expected
+	 test_cmp expected actual
 	)
 '
 
diff --git a/t/t7508-status.sh b/t/t7508-status.sh
index e1f11293e..799af225b 100755
--- a/t/t7508-status.sh
+++ b/t/t7508-status.sh
@@ -1620,7 +1620,7 @@ test_expect_success 'show stash info with "--show-stash"' '
 
 test_expect_success 'no stash info with "--show-stash --no-show-stash"' '
 	git status --show-stash --no-show-stash >expected_without_stash &&
-	test_cmp expected_default expected_without_stash
+	test_cmp expected_without_stash expected_default
 '
 
 test_expect_success '"status.showStash=false" weaker than "--show-stash"' '
diff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh
index 668bbee73..562bd215a 100755
--- a/t/t7800-difftool.sh
+++ b/t/t7800-difftool.sh
@@ -557,7 +557,7 @@ test_expect_success SYMLINKS 'difftool --dir-diff --symlink without unstaged cha
 	EOF
 	git difftool --dir-diff --symlink \
 		--extcmd "./.git/CHECK_SYMLINKS" branch HEAD &&
-	test_cmp actual expect
+	test_cmp expect actual
 '
 
 write_script modify-right-file <<\EOF
diff --git a/t/t9100-git-svn-basic.sh b/t/t9100-git-svn-basic.sh
index 9af607884..2c309a57d 100755
--- a/t/t9100-git-svn-basic.sh
+++ b/t/t9100-git-svn-basic.sh
@@ -221,7 +221,7 @@ tree d667270a1f7b109f5eb3aaea21ede14b56bfdd6e
 tree 8f51f74cf0163afc9ad68a4b1537288c4558b5a4
 EOF
 
-test_expect_success POSIXPERM,SYMLINKS "$name" "test_cmp a expected"
+test_expect_success POSIXPERM,SYMLINKS "$name" "test_cmp expected a"
 
 test_expect_success 'exit if remote refs are ambigious' '
         git config --add svn-remote.svn.fetch \
diff --git a/t/t9133-git-svn-nested-git-repo.sh b/t/t9133-git-svn-nested-git-repo.sh
index f3c30e63b..f89486086 100755
--- a/t/t9133-git-svn-nested-git-repo.sh
+++ b/t/t9133-git-svn-nested-git-repo.sh
@@ -45,7 +45,7 @@ test_expect_success 'update git svn-cloned repo' '
 		git svn rebase &&
 		echo a > expect &&
 		echo b >> expect &&
-		test_cmp a expect &&
+		test_cmp expect a &&
 		rm expect
 	)
 '
@@ -69,7 +69,7 @@ test_expect_success 'update git svn-cloned repo' '
 		git svn rebase &&
 		echo a > expect &&
 		echo b >> expect &&
-		test_cmp a expect &&
+		test_cmp expect a &&
 		rm expect
 	)
 '
@@ -93,7 +93,7 @@ test_expect_success 'update git svn-cloned repo again' '
 		echo a > expect &&
 		echo b >> expect &&
 		echo c >> expect &&
-		test_cmp a expect &&
+		test_cmp expect a &&
 		rm expect
 	)
 '
diff --git a/t/t9600-cvsimport.sh b/t/t9600-cvsimport.sh
index 5dfee07d9..251fdd66c 100755
--- a/t/t9600-cvsimport.sh
+++ b/t/t9600-cvsimport.sh
@@ -148,7 +148,7 @@ test_expect_success PERL 'import from a CVS working tree' '
 		git cvsimport -a -z0 &&
 		echo 1 >expect &&
 		git log -1 --pretty=format:%s%n >actual &&
-		test_cmp actual expect
+		test_cmp expect actual
 	)
 
 '
diff --git a/t/t9603-cvsimport-patchsets.sh b/t/t9603-cvsimport-patchsets.sh
index c4c3c4954..3e64b11ea 100755
--- a/t/t9603-cvsimport-patchsets.sh
+++ b/t/t9603-cvsimport-patchsets.sh
@@ -29,11 +29,11 @@ test_expect_failure PERL 'import with criss cross times on revisions' '
 Rev 3
 Rev 2
 Rev 1" > expect-master &&
-    test_cmp actual-master expect-master &&
+    test_cmp expect-master actual-master &&
 
     echo "Rev 5 Branch A Wed Mar 11 19:09:10 2009 +0000
 Rev 4 Branch A Wed Mar 11 19:03:52 2009 +0000" > expect-A &&
-    test_cmp actual-A expect-A
+    test_cmp expect-A actual-A
 '
 
 test_done
diff --git a/t/t9604-cvsimport-timestamps.sh b/t/t9604-cvsimport-timestamps.sh
index a4b3db24b..2ff4aa932 100755
--- a/t/t9604-cvsimport-timestamps.sh
+++ b/t/t9604-cvsimport-timestamps.sh
@@ -31,7 +31,7 @@ test_expect_success PERL 'check timestamps are UTC (TZ=CST6CDT)' '
 	Rev  2 2005-02-01 00:00:00 +0000
 	Rev  1 2005-01-01 00:00:00 +0000
 	EOF
-	test_cmp actual-1 expect-1
+	test_cmp expect-1 actual-1
 '
 
 test_expect_success PERL 'check timestamps with author-specific timezones' '
@@ -65,7 +65,7 @@ test_expect_success PERL 'check timestamps with author-specific timezones' '
 	Rev  2 2005-01-31 18:00:00 -0600 User Two
 	Rev  1 2005-01-01 00:00:00 +0000 User One
 	EOF
-	test_cmp actual-2 expect-2
+	test_cmp expect-2 actual-2
 '
 
 test_done
-- 
2.19.0.397.gdd90340f6a-goog


^ permalink raw reply related	[flat|nested] 66+ messages in thread

* Re: [PATCH v1 0/2] Cleanup tests for test_cmp argument ordering and "|" placement
  2018-09-15  0:02 [PATCH v1 0/2] Cleanup tests for test_cmp argument ordering and "|" placement Matthew DeVore
  2018-09-15  0:02 ` [PATCH v1 1/2] t/*: fix pipe placement and remove \'s Matthew DeVore
  2018-09-15  0:02 ` [PATCH v1 2/2] t/*: fix ordering of expected/observed arguments Matthew DeVore
@ 2018-09-15 15:55 ` Junio C Hamano
  2018-09-17 22:24 ` [PATCH v2 0/6] Clean up tests for test_cmp arg ordering and pipe placement Matthew DeVore
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 66+ messages in thread
From: Junio C Hamano @ 2018-09-15 15:55 UTC (permalink / raw)
  To: Matthew DeVore; +Cc: git, peff, jonathantanmy

Matthew DeVore <matvore@google.com> writes:

> As requested in:
>  https://public-inbox.org/git/xmqqmuskas3a.fsf@gitster-ct.c.googlers.com/
> this patchset corrects ordering of test_cmp arguments and | placement.
>
> The request didn't explicitly state whether all the tests should be cleaned up,
> but I did clean up as much as I reasonably could.

I was only suggesting a clean-up of the test scripts you are going
to touch anyway in your series, and not the ones outside that
original scope.  Your going above and beyond what is necessary to
make sure your primary changes will be protected against future
breakage is surely appreciated but it would of course require more
review resources ;-).


^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v1 2/2] t/*: fix ordering of expected/observed arguments
  2018-09-15  0:02 ` [PATCH v1 2/2] t/*: fix ordering of expected/observed arguments Matthew DeVore
@ 2018-09-17 12:56   ` Matthew DeVore
  0 siblings, 0 replies; 66+ messages in thread
From: Matthew DeVore @ 2018-09-17 12:56 UTC (permalink / raw)
  To: git; +Cc: Jeff King, Jonathan Tan, Junio C Hamano, bmwill

On Fri, Sep 14, 2018 at 5:03 PM Matthew DeVore <matvore@google.com> wrote:
>
> This fixes various places where the ordering was obviously wrong and it
> was either related to other patches in this patchset or was easy
> find with grep.
>
> Signed-off-by: Matthew DeVore <matvore@google.com>
> ---
The clause about "related to other patches in this patchset is wrong,
so I've reworded the commit message body:

    Fix various places where the ordering was obviously wrong, meaning it
    was easy to find with grep.

> --- a/t/t7508-status.sh
> +++ b/t/t7508-status.sh
> @@ -1620,7 +1620,7 @@ test_expect_success 'show stash info with "--show-stash"' '
>
>  test_expect_success 'no stash info with "--show-stash --no-show-stash"' '
>         git status --show-stash --no-show-stash >expected_without_stash &&
> -       test_cmp expected_default expected_without_stash
> +       test_cmp expected_without_stash expected_default
>  '
This line should not have been changed, so I've reverted it.

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v1 1/2] t/*: fix pipe placement and remove \'s
  2018-09-15  0:02 ` [PATCH v1 1/2] t/*: fix pipe placement and remove \'s Matthew DeVore
@ 2018-09-17 16:31   ` Jonathan Nieder
  2018-09-17 21:47     ` Matthew DeVore
  0 siblings, 1 reply; 66+ messages in thread
From: Jonathan Nieder @ 2018-09-17 16:31 UTC (permalink / raw)
  To: Matthew DeVore; +Cc: git, peff, jonathantanmy, gitster, bmwill

Matthew DeVore wrote:

> Subject: t/*: fix pipe placement and remove \'s
>
> Where ever there was code in the tests like this:
>
> 	foo \
> 		| bar

Language nits:
- s/Where ever/Wherever/
- Git's commit messages use the present tense to describe the existing
  previous state of the codebase, as though reporting a bug.

Maybe something like

	tests: standardize pipe placement

	Instead of using a line-continuation and pipe on the second
	line, take advantage of the shell's implicit line continuation
	after a pipe character.  So for example, instead of

		some long line \
			| next line

	use

		some long line |
		next line

At this point, it would be useful to say something about rationale ---
for example,

	This better matches the coding style documented in
	Documentation/CodingGuidelines and used in shell scripts
	elsewhere in Git.

Except: is this documented in Documentation/CodingGuidelines?  Or,
better, is there a linter that we can run in the test-lint target of
t/Makefile to ensure we keep sticking to this style?

[...]
> --- a/t/lib-gpg.sh
> +++ b/t/lib-gpg.sh
> @@ -57,8 +57,8 @@ then
>  		echo | gpgsm --homedir "${GNUPGHOME}" 2>/dev/null \
>  			--passphrase-fd 0 --pinentry-mode loopback \
>  			--import "$TEST_DIRECTORY"/lib-gpg/gpgsm_cert.p12 &&
> -		gpgsm --homedir "${GNUPGHOME}" 2>/dev/null -K \
> -			| grep fingerprint: | cut -d" " -f4 | tr -d '\n' > \
> +		gpgsm --homedir "${GNUPGHOME}" 2>/dev/null -K |
> +		grep fingerprint: | cut -d" " -f4 | tr -d '\n' > \
>  			${GNUPGHOME}/trustlist.txt &&

I think this would be more readable with one item from the pipeline
per line:

		gpgsm --homedir ... |
		grep ... |
		cut ... |
		tr ... >... &&

[...]
> --- a/t/t1006-cat-file.sh
> +++ b/t/t1006-cat-file.sh
> @@ -218,8 +218,8 @@ test_expect_success "--batch-check for a non-existent hash" '
>      test "0000000000000000000000000000000000000042 missing
>  0000000000000000000000000000000000000084 missing" = \
>      "$( ( echo 0000000000000000000000000000000000000042;
> -         echo_without_newline 0000000000000000000000000000000000000084; ) \
> -       | git cat-file --batch-check)"
> +         echo_without_newline 0000000000000000000000000000000000000084; ) |
> +       git cat-file --batch-check)"

This test is problematic in a lot of ways.  Most importantly, it ignores
the exist status from git cat-file.

So it should say something like:

	cat >expect <<-\EOF &&
		foobar42 missing
		foobar84 missing
	EOF
	printf "foobar42\nfoobar84" |
	git cat-file --batch-check >actual &&
	test_cmp expect actual

If we want to restrict to the pipeline style fixes, we could do

	test "..." = "$(
		{	# Couldn't resist changing the ( to {!
			echo ... &&	# Couldn't resist changing the ; to &&!
			echo_without_newline ...
		} |
		git cat-file --batch-check
	)"

but unless there's a linter that we're helping support, it's probably
better to skip this file and use a dedicated patch to modernize its
style more generally.

[...]
> --- a/t/t1300-config.sh
> +++ b/t/t1300-config.sh
> @@ -1770,8 +1770,9 @@ test_expect_success '--show-origin stdin with file include' '
>  	cat >expect <<-EOF &&
>  		file:$INCLUDE_DIR/stdin.include	include
>  	EOF
> -	echo "[include]path=\"$INCLUDE_DIR\"/stdin.include" \
> -		| git config --show-origin --includes --file - user.stdin >output &&
> +	echo "[include]path=\"$INCLUDE_DIR\"/stdin.include" |
> +	git config --show-origin --includes --file - user.stdin >output &&

Okay.

[...]
> --- a/t/t5317-pack-objects-filter-objects.sh
> +++ b/t/t5317-pack-objects-filter-objects.sh
> @@ -20,17 +20,20 @@ test_expect_success 'setup r1' '
>  '
>  
>  test_expect_success 'verify blob count in normal packfile' '
> -	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 \
> -		| awk -f print_2.awk \
> -		| sort >expected &&
> +	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 |
> +	awk -f print_2.awk |
> +	sort >expected &&

This loses the exit status from git, so we should make it write to a
temporary file instead (as a separate patch).

[...]
> -	git -C r1 verify-pack -v ../all.pack \
> -		| grep blob \
> -		| awk -f print_1.awk \
> -		| sort >observed &&
> +
> +	git -C r1 verify-pack -v ../all.pack |

Likewise (and likewise for the rest in this file).

[...]
> --- a/t/t5500-fetch-pack.sh
> +++ b/t/t5500-fetch-pack.sh
> @@ -50,8 +50,9 @@ pull_to_client () {
>  			case "$heads" in *B*)
>  			    git update-ref refs/heads/B "$BTIP";;
>  			esac &&
> -			git symbolic-ref HEAD refs/heads/$(echo $heads \
> -				| sed -e "s/^\(.\).*$/\1/") &&
> +
> +			git symbolic-ref HEAD refs/heads/$(echo $heads |
> +			sed -e "s/^\(.\).*$/\1/") &&

It would be better to use a temporary variable.  If we're just
changing line wrapping, then this would be

			git symbolic-ref HAD refs/heads/$(
				echo $heads |
				sed ...
			) &&

[...]
> --- a/t/t5616-partial-clone.sh
> +++ b/t/t5616-partial-clone.sh
> @@ -34,10 +34,12 @@ test_expect_success 'setup bare clone for server' '
>  # confirm partial clone was registered in the local config.
>  test_expect_success 'do partial clone 1' '
>  	git clone --no-checkout --filter=blob:none "file://$(pwd)/srv.bare" pc1 &&
> -	git -C pc1 rev-list HEAD --quiet --objects --missing=print \
> -		| awk -f print_1.awk \
> -		| sed "s/?//" \
> -		| sort >observed.oids &&
> +
> +	git -C pc1 rev-list HEAD --quiet --objects --missing=print |

Also needs to write to a temporary to avoid losing the exist status
(and likewise for the rest of this file).

[...]
> --- a/t/t6112-rev-list-filters-objects.sh
> +++ b/t/t6112-rev-list-filters-objects.sh
> @@ -20,24 +20,28 @@ test_expect_success 'setup r1' '
>  '
>  
>  test_expect_success 'verify blob:none omits all 5 blobs' '
> -	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 \
> -		| awk -f print_2.awk \
> -		| sort >expected &&
> -	git -C r1 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:none \
> -		| awk -f print_1.awk \
> -		| sed "s/~//" \
> -		| sort >observed &&
> +	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 |
> +	awk -f print_2.awk |
> +	sort >expected &&

Likewise.

[...]
> --- a/t/t9101-git-svn-props.sh
> +++ b/t/t9101-git-svn-props.sh
> @@ -193,8 +193,8 @@ test_expect_success 'test propget' "
>  	git svn propget svn:ignore . | cmp - prop.expect &&
>  	cd deeply &&
>  	git svn propget svn:ignore . | cmp - ../prop.expect &&
> -	git svn propget svn:entry:committed-rev nested/directory/.keep \
> -	  | cmp - ../prop2.expect &&
> +	git svn propget svn:entry:committed-rev nested/directory/.keep |
> +	cmp - ../prop2.expect &&

Likewise.

Thanks and hope that helps,
Jonathan

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v1 1/2] t/*: fix pipe placement and remove \'s
  2018-09-17 16:31   ` Jonathan Nieder
@ 2018-09-17 21:47     ` Matthew DeVore
  0 siblings, 0 replies; 66+ messages in thread
From: Matthew DeVore @ 2018-09-17 21:47 UTC (permalink / raw)
  To: jrnieder; +Cc: git, Jeff King, Jonathan Tan, Junio C Hamano, bmwill

On Mon, Sep 17, 2018 at 9:31 AM Jonathan Nieder <jrnieder@gmail.com> wrote:
>
> Matthew DeVore wrote:
>
> > Subject: t/*: fix pipe placement and remove \'s
> >
> > Where ever there was code in the tests like this:
> >
> >       foo \
> >               | bar
>
> Language nits:
> - s/Where ever/Wherever/
> - Git's commit messages use the present tense to describe the existing
>   previous state of the codebase, as though reporting a bug.
>
> Maybe something like
>
>         tests: standardize pipe placement
>
>         Instead of using a line-continuation and pipe on the second
>         line, take advantage of the shell's implicit line continuation
>         after a pipe character.  So for example, instead of
>
>                 some long line \
>                         | next line
>
>         use
>
>                 some long line |
>                 next line
>
> At this point, it would be useful to say something about rationale ---
> for example,
>
>         This better matches the coding style documented in
>         Documentation/CodingGuidelines and used in shell scripts
>         elsewhere in Git.
>
Done.

> Except: is this documented in Documentation/CodingGuidelines?  Or,
> better, is there a linter that we can run in the test-lint target of
> t/Makefile to ensure we keep sticking to this style?
It's not documented there, so I've created a new commit at the start
of this patchset which addresses that. I also added a commit which
adds a lint test, but it uses a questionable heuristic in order to
avoid false positives (it's hard to distinguish graphs generated with
git log --oneline since they often have "\ [newline] [tab or spaces]
|"  ). Let me know if you think it looks promising. I'd be happy to
just drop it.

>
> [...]
> > --- a/t/lib-gpg.sh
> > +++ b/t/lib-gpg.sh
> > @@ -57,8 +57,8 @@ then
> >               echo | gpgsm --homedir "${GNUPGHOME}" 2>/dev/null \
> >                       --passphrase-fd 0 --pinentry-mode loopback \
> >                       --import "$TEST_DIRECTORY"/lib-gpg/gpgsm_cert.p12 &&
> > -             gpgsm --homedir "${GNUPGHOME}" 2>/dev/null -K \
> > -                     | grep fingerprint: | cut -d" " -f4 | tr -d '\n' > \
> > +             gpgsm --homedir "${GNUPGHOME}" 2>/dev/null -K |
> > +             grep fingerprint: | cut -d" " -f4 | tr -d '\n' > \
> >                       ${GNUPGHOME}/trustlist.txt &&
>
> I think this would be more readable with one item from the pipeline
> per line:
>
>                 gpgsm --homedir ... |
>                 grep ... |
>                 cut ... |
>                 tr ... >... &&
>
Done.

> [...]
> > --- a/t/t1006-cat-file.sh
> > +++ b/t/t1006-cat-file.sh
> > @@ -218,8 +218,8 @@ test_expect_success "--batch-check for a non-existent hash" '
> >      test "0000000000000000000000000000000000000042 missing
> >  0000000000000000000000000000000000000084 missing" = \
> >      "$( ( echo 0000000000000000000000000000000000000042;
> > -         echo_without_newline 0000000000000000000000000000000000000084; ) \
> > -       | git cat-file --batch-check)"
> > +         echo_without_newline 0000000000000000000000000000000000000084; ) |
> > +       git cat-file --batch-check)"
>
> This test is problematic in a lot of ways.  Most importantly, it ignores
> the exist status from git cat-file.
>
[...]
> but unless there's a linter that we're helping support, it's probably
> better to skip this file and use a dedicated patch to modernize its
> style more generally.

Yes, the cat-file.sh test is kind of funky, and I like the style of
your suggestions much better, but in this case I think that perfect is
the enemy of good. Fixing everything wrong with these lines would
necessitate fixing the surrounding couple of tests that also swallow
up the exit code of git cat-file. This may in turn necessitate other
fixes for consistency that may even spread to other files... I am
basing my argument here on what's in Documentation/CodingGuidelines,
which indicates that minor stylistic nits that result in code churn
are not recommended, and that we must be consistent with the
surrounding code. The surrounding code here looks for the most part
like:

 test "asdf" = $(echo "asdf" | git foo-bar)

Which I think is satisfactory in its own context. You asked me to fix
other test files later on, which I did, since they didn't seem to have
such a contrarian style, so the fixes were very localized, and I was
already editing many lines in those files already.

>
> [...]
> > --- a/t/t5317-pack-objects-filter-objects.sh
> > +++ b/t/t5317-pack-objects-filter-objects.sh
> > @@ -20,17 +20,20 @@ test_expect_success 'setup r1' '
> >  '
> >
> >  test_expect_success 'verify blob count in normal packfile' '
> > -     git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 \
> > -             | awk -f print_2.awk \
> > -             | sort >expected &&
> > +     git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 |
> > +     awk -f print_2.awk |
> > +     sort >expected &&
>
> This loses the exit status from git, so we should make it write to a
> temporary file instead (as a separate patch).
Fixed.

>
> [...]
> > -     git -C r1 verify-pack -v ../all.pack \
> > -             | grep blob \
> > -             | awk -f print_1.awk \
> > -             | sort >observed &&
> > +
> > +     git -C r1 verify-pack -v ../all.pack |
>
> Likewise (and likewise for the rest in this file).
Fixed this file's exit code issues in a separate patch.

>
> [...]
> > --- a/t/t5500-fetch-pack.sh
> > +++ b/t/t5500-fetch-pack.sh
> > @@ -50,8 +50,9 @@ pull_to_client () {
> >                       case "$heads" in *B*)
> >                           git update-ref refs/heads/B "$BTIP";;
> >                       esac &&
> > -                     git symbolic-ref HEAD refs/heads/$(echo $heads \
> > -                             | sed -e "s/^\(.\).*$/\1/") &&
> > +
> > +                     git symbolic-ref HEAD refs/heads/$(echo $heads |
> > +                     sed -e "s/^\(.\).*$/\1/") &&
>
> It would be better to use a temporary variable.  If we're just
> changing line wrapping, then this would be
>
>                         git symbolic-ref HAD refs/heads/$(
>                                 echo $heads |
>                                 sed ...
>                         ) &&
>
Fixed using your suggestion (only fixed the line wrapping)

> [...]
> > --- a/t/t5616-partial-clone.sh
> > +++ b/t/t5616-partial-clone.sh
> > @@ -34,10 +34,12 @@ test_expect_success 'setup bare clone for server' '
> >  # confirm partial clone was registered in the local config.
> >  test_expect_success 'do partial clone 1' '
> >       git clone --no-checkout --filter=blob:none "file://$(pwd)/srv.bare" pc1 &&
> > -     git -C pc1 rev-list HEAD --quiet --objects --missing=print \
> > -             | awk -f print_1.awk \
> > -             | sed "s/?//" \
> > -             | sort >observed.oids &&
> > +
> > +     git -C pc1 rev-list HEAD --quiet --objects --missing=print |
>
> Also needs to write to a temporary to avoid losing the exist status
> (and likewise for the rest of this file).
Done in a separate patch, although I didn't do this for pipes inside
of $( ) and for a trivial "git rev-parse HEAD".

>
> [...]
> > --- a/t/t6112-rev-list-filters-objects.sh
> > +++ b/t/t6112-rev-list-filters-objects.sh
> > @@ -20,24 +20,28 @@ test_expect_success 'setup r1' '
> >  '
> >
> >  test_expect_success 'verify blob:none omits all 5 blobs' '
> > -     git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 \
> > -             | awk -f print_2.awk \
> > -             | sort >expected &&
> > -     git -C r1 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:none \
> > -             | awk -f print_1.awk \
> > -             | sed "s/~//" \
> > -             | sort >observed &&
> > +     git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 |
> > +     awk -f print_2.awk |
> > +     sort >expected &&
>
> Likewise.
Fixed this file.
>
> [...]
> > --- a/t/t9101-git-svn-props.sh
> > +++ b/t/t9101-git-svn-props.sh
> > @@ -193,8 +193,8 @@ test_expect_success 'test propget' "
> >       git svn propget svn:ignore . | cmp - prop.expect &&
> >       cd deeply &&
> >       git svn propget svn:ignore . | cmp - ../prop.expect &&
> > -     git svn propget svn:entry:committed-rev nested/directory/.keep \
> > -       | cmp - ../prop2.expect &&
> > +     git svn propget svn:entry:committed-rev nested/directory/.keep |
> > +     cmp - ../prop2.expect &&
>
> Likewise.
Fixed this section, including the one earlier in this file. This
section is not a trivial change, so I put it in a different commit.

>
> Thanks and hope that helps,
> Jonathan
I will send an updated patchset shortly.

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 0/6] Clean up tests for test_cmp arg ordering and pipe placement
  2018-09-15  0:02 [PATCH v1 0/2] Cleanup tests for test_cmp argument ordering and "|" placement Matthew DeVore
                   ` (2 preceding siblings ...)
  2018-09-15 15:55 ` [PATCH v1 0/2] Cleanup tests for test_cmp argument ordering and "|" placement Junio C Hamano
@ 2018-09-17 22:24 ` Matthew DeVore
  2018-09-17 22:24   ` [PATCH v2 4/6] tests: Add linter check for pipe placement style Matthew DeVore
       [not found] ` <cover.1537223021.git.matvore@google.com>
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 66+ messages in thread
From: Matthew DeVore @ 2018-09-17 22:24 UTC (permalink / raw)
  To: git; +Cc: Matthew DeVore, peff, jonathantanmy, gitster, jrn

This applies the suggestions from jrn@'s response to v1 here:
https://public-inbox.org/git/20180917163137.GB89942@aiede.svl.corp.google.com/

The major changes are:
 - Added two bullet points to Documentation/CodingGuidelines about 1) how to
   format pipe sequences and 2) using temporary files rather than pipes to
   avoid masking potiential error exit codes.
 - A new commit which introduces a linter check to enforce (1) above, which I
   am requesting feedback for. I'd be happy to drop it.
 - A new commit to fix violations of (2) above in t9101-git-svn-props.sh since
   it was not so trivial.
 - A better message to describe the pipe placement commit.

Thank you,

Matthew DeVore (6):
  CodingGuidelines: add shell piping guidelines
  tests: standardize pipe placement
  t/*: fix ordering of expected/observed arguments
  tests: Add linter check for pipe placement style
  tests: split up pipes
  t9109-git-svn-props.sh: split up several pipes

 Documentation/CodingGuidelines         |  29 ++
 t/Makefile                             |  12 +-
 t/lib-gpg.sh                           |   9 +-
 t/t0000-basic.sh                       |   2 +-
 t/t0021-conversion.sh                  |   4 +-
 t/t1006-cat-file.sh                    |   8 +-
 t/t1300-config.sh                      |   9 +-
 t/t1303-wacky-config.sh                |   4 +-
 t/t2101-update-index-reupdate.sh       |   2 +-
 t/t3200-branch.sh                      |   2 +-
 t/t3320-notes-merge-worktrees.sh       |   4 +-
 t/t3400-rebase.sh                      |   8 +-
 t/t3417-rebase-whitespace-fix.sh       |   6 +-
 t/t3702-add-edit.sh                    |   4 +-
 t/t3903-stash.sh                       |   8 +-
 t/t3905-stash-include-untracked.sh     |   2 +-
 t/t4025-hunk-header.sh                 |   2 +-
 t/t4117-apply-reject.sh                |   6 +-
 t/t4124-apply-ws-rule.sh               |  30 +--
 t/t4138-apply-ws-expansion.sh          |   2 +-
 t/t5317-pack-objects-filter-objects.sh | 360 ++++++++++++++-----------
 t/t5318-commit-graph.sh                |   2 +-
 t/t5500-fetch-pack.sh                  |   7 +-
 t/t5616-partial-clone.sh               |  30 ++-
 t/t5701-git-serve.sh                   |  14 +-
 t/t5702-protocol-v2.sh                 |  10 +-
 t/t6023-merge-file.sh                  |  12 +-
 t/t6027-merge-binary.sh                |   4 +-
 t/t6031-merge-filemode.sh              |   2 +-
 t/t6112-rev-list-filters-objects.sh    | 224 ++++++++-------
 t/t7201-co.sh                          |   4 +-
 t/t7406-submodule-update.sh            |   8 +-
 t/t7800-difftool.sh                    |   2 +-
 t/t9100-git-svn-basic.sh               |   2 +-
 t/t9101-git-svn-props.sh               |  24 +-
 t/t9133-git-svn-nested-git-repo.sh     |   6 +-
 t/t9600-cvsimport.sh                   |   2 +-
 t/t9603-cvsimport-patchsets.sh         |   4 +-
 t/t9604-cvsimport-timestamps.sh        |   4 +-
 39 files changed, 511 insertions(+), 363 deletions(-)

-- 
2.19.0.444.g18242da7ef-goog


^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 1/6] CodingGuidelines: add shell piping guidelines
       [not found] ` <cover.1537223021.git.matvore@google.com>
@ 2018-09-17 22:24   ` Matthew DeVore
  2018-09-18  0:16     ` Eric Sunshine
  2018-09-17 22:24   ` [PATCH v2 2/6] tests: standardize pipe placement Matthew DeVore
                     ` (4 subsequent siblings)
  5 siblings, 1 reply; 66+ messages in thread
From: Matthew DeVore @ 2018-09-17 22:24 UTC (permalink / raw)
  To: git; +Cc: Matthew DeVore, peff, jonathantanmy, gitster, jrn

Add two guidelines:

 - pipe characters should appear at the end of lines, and not cause
   indentation
 - pipes should be avoided when they swallow exit codes that can
   potentially fail
---
 Documentation/CodingGuidelines | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines
index 48aa4edfb..7f903c1aa 100644
--- a/Documentation/CodingGuidelines
+++ b/Documentation/CodingGuidelines
@@ -163,6 +163,35 @@ For shell scripts specifically (not exhaustive):
 
    does not have such a problem.
 
+ - In a piped sequence which spans multiple lines, put each statement
+   on a separate line and put pipes on the end of each line, rather
+   than the start. This means you don't need to use \ to join lines,
+   since | implies a join already. Also, do not indent subsequent
+   lines; if you need a sequence to visually stand apart from the
+   surrounding code, use a blank line before and/or after the piped
+   sequence.
+
+	(incorrect)
+	echo '...' > expected
+	git ls-files -s file.1 file.2 file.3 file.4 file.5 \
+		| awk '{print $1}' \
+		| sort >observed
+	test_cmp expected actual
+
+	(correct)
+	echo '...' > expected
+
+	git ls-files -s file.1 file.2 file.3 file.4 file.5 |
+	awk '{print $1}' |
+	sort >observed
+
+	test_cmp expected actual
+
+ - In a pipe, any non-zero exit codes returned by processes besides
+   the last will be ignored. If there is any possibility some
+   non-final command in the pipe will raise an error, prefer writing
+   the output of that command to a temporary file with '>' rather than
+   pipe it.
 
 For C programs:
 
-- 
2.19.0.444.g18242da7ef-goog


^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [PATCH v2 2/6] tests: standardize pipe placement
       [not found] ` <cover.1537223021.git.matvore@google.com>
  2018-09-17 22:24   ` [PATCH v2 1/6] CodingGuidelines: add shell piping guidelines Matthew DeVore
@ 2018-09-17 22:24   ` Matthew DeVore
  2018-09-17 22:24   ` [PATCH v2 3/6] t/*: fix ordering of expected/observed arguments Matthew DeVore
                     ` (3 subsequent siblings)
  5 siblings, 0 replies; 66+ messages in thread
From: Matthew DeVore @ 2018-09-17 22:24 UTC (permalink / raw)
  To: git; +Cc: Matthew DeVore, peff, jonathantanmy, gitster, jrn

Instead of using a line-continuation and pipe on the second line, take
advantage of the shell's implicit line continuation after a pipe
character.  So for example, instead of

	some long line \
		| next line

use

	some long line |
	next line

And add a blank line before and after the pipe where it aids readability
(it usually does).

This better matches the coding style documented in
Documentation/CodingGuidelines and used in shell scripts elsewhere in
the tree.

Signed-off-by: Matthew DeVore <matvore@google.com>
---
 t/lib-gpg.sh                           |   9 +-
 t/t1006-cat-file.sh                    |   8 +-
 t/t1300-config.sh                      |   5 +-
 t/t5317-pack-objects-filter-objects.sh | 330 ++++++++++++++-----------
 t/t5500-fetch-pack.sh                  |   5 +-
 t/t5616-partial-clone.sh               |  32 ++-
 t/t6112-rev-list-filters-objects.sh    | 203 ++++++++-------
 7 files changed, 342 insertions(+), 250 deletions(-)

diff --git a/t/lib-gpg.sh b/t/lib-gpg.sh
index 3fe02876c..f1277bef4 100755
--- a/t/lib-gpg.sh
+++ b/t/lib-gpg.sh
@@ -57,9 +57,12 @@ then
 		echo | gpgsm --homedir "${GNUPGHOME}" 2>/dev/null \
 			--passphrase-fd 0 --pinentry-mode loopback \
 			--import "$TEST_DIRECTORY"/lib-gpg/gpgsm_cert.p12 &&
-		gpgsm --homedir "${GNUPGHOME}" 2>/dev/null -K \
-			| grep fingerprint: | cut -d" " -f4 | tr -d '\n' > \
-			${GNUPGHOME}/trustlist.txt &&
+
+		gpgsm --homedir "${GNUPGHOME}" 2>/dev/null -K |
+		grep fingerprint: |
+		cut -d" " -f4 |
+		tr -d '\n' >"${GNUPGHOME}/trustlist.txt" &&
+
 		echo " S relax" >> ${GNUPGHOME}/trustlist.txt &&
 		(gpgconf --kill gpg-agent >/dev/null 2>&1 || : ) &&
 		echo hello | gpgsm --homedir "${GNUPGHOME}" >/dev/null \
diff --git a/t/t1006-cat-file.sh b/t/t1006-cat-file.sh
index 7f19d591f..a0fa926d3 100755
--- a/t/t1006-cat-file.sh
+++ b/t/t1006-cat-file.sh
@@ -218,8 +218,8 @@ test_expect_success "--batch-check for a non-existent hash" '
     test "0000000000000000000000000000000000000042 missing
 0000000000000000000000000000000000000084 missing" = \
     "$( ( echo 0000000000000000000000000000000000000042;
-         echo_without_newline 0000000000000000000000000000000000000084; ) \
-       | git cat-file --batch-check)"
+         echo_without_newline 0000000000000000000000000000000000000084; ) |
+       git cat-file --batch-check)"
 '
 
 test_expect_success "--batch for an existent and a non-existent hash" '
@@ -227,8 +227,8 @@ test_expect_success "--batch for an existent and a non-existent hash" '
 $tag_content
 0000000000000000000000000000000000000000 missing" = \
     "$( ( echo $tag_sha1;
-         echo_without_newline 0000000000000000000000000000000000000000; ) \
-       | git cat-file --batch)"
+         echo_without_newline 0000000000000000000000000000000000000000; ) |
+       git cat-file --batch)"
 '
 
 test_expect_success "--batch-check for an empty line" '
diff --git a/t/t1300-config.sh b/t/t1300-config.sh
index cdf1fed5d..5869d6cb6 100755
--- a/t/t1300-config.sh
+++ b/t/t1300-config.sh
@@ -1770,8 +1770,9 @@ test_expect_success '--show-origin stdin with file include' '
 	cat >expect <<-EOF &&
 		file:$INCLUDE_DIR/stdin.include	include
 	EOF
-	echo "[include]path=\"$INCLUDE_DIR\"/stdin.include" \
-		| git config --show-origin --includes --file - user.stdin >output &&
+	echo "[include]path=\"$INCLUDE_DIR\"/stdin.include" |
+	git config --show-origin --includes --file - user.stdin >output &&
+
 	test_cmp expect output
 '
 
diff --git a/t/t5317-pack-objects-filter-objects.sh b/t/t5317-pack-objects-filter-objects.sh
index 6710c8bc8..ce69148ec 100755
--- a/t/t5317-pack-objects-filter-objects.sh
+++ b/t/t5317-pack-objects-filter-objects.sh
@@ -20,17 +20,20 @@ test_expect_success 'setup r1' '
 '
 
 test_expect_success 'verify blob count in normal packfile' '
-	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	git -C r1 pack-objects --rev --stdout >all.pack <<-EOF &&
 	HEAD
 	EOF
 	git -C r1 index-pack ../all.pack &&
-	git -C r1 verify-pack -v ../all.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r1 verify-pack -v ../all.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
@@ -39,23 +42,27 @@ test_expect_success 'verify blob:none packfile has no blobs' '
 	HEAD
 	EOF
 	git -C r1 index-pack ../filter.pack &&
-	git -C r1 verify-pack -v ../filter.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r1 verify-pack -v ../filter.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	nr=$(wc -l <observed) &&
 	test 0 -eq $nr
 '
 
 test_expect_success 'verify normal and blob:none packfiles have same commits/trees' '
-	git -C r1 verify-pack -v ../all.pack \
-		| grep -E "commit|tree" \
-		| awk -f print_1.awk \
-		| sort >expected &&
-	git -C r1 verify-pack -v ../filter.pack \
-		| grep -E "commit|tree" \
-		| awk -f print_1.awk \
-		| sort >observed &&
+	git -C r1 verify-pack -v ../all.pack |
+	grep -E "commit|tree" |
+	awk -f print_1.awk |
+	sort >expected &&
+
+	git -C r1 verify-pack -v ../filter.pack |
+	grep -E "commit|tree" |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
@@ -75,17 +82,20 @@ test_expect_success 'setup r2' '
 '
 
 test_expect_success 'verify blob count in normal packfile' '
-	git -C r2 ls-files -s large.1000 large.10000 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r2 ls-files -s large.1000 large.10000 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	git -C r2 pack-objects --rev --stdout >all.pack <<-EOF &&
 	HEAD
 	EOF
 	git -C r2 index-pack ../all.pack &&
-	git -C r2 verify-pack -v ../all.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r2 verify-pack -v ../all.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
@@ -94,10 +104,12 @@ test_expect_success 'verify blob:limit=500 omits all blobs' '
 	HEAD
 	EOF
 	git -C r2 index-pack ../filter.pack &&
-	git -C r2 verify-pack -v ../filter.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r2 verify-pack -v ../filter.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	nr=$(wc -l <observed) &&
 	test 0 -eq $nr
 '
@@ -107,99 +119,118 @@ test_expect_success 'verify blob:limit=1000' '
 	HEAD
 	EOF
 	git -C r2 index-pack ../filter.pack &&
-	git -C r2 verify-pack -v ../filter.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r2 verify-pack -v ../filter.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	nr=$(wc -l <observed) &&
 	test 0 -eq $nr
 '
 
 test_expect_success 'verify blob:limit=1001' '
-	git -C r2 ls-files -s large.1000 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r2 ls-files -s large.1000 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	git -C r2 pack-objects --rev --stdout --filter=blob:limit=1001 >filter.pack <<-EOF &&
 	HEAD
 	EOF
 	git -C r2 index-pack ../filter.pack &&
-	git -C r2 verify-pack -v ../filter.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r2 verify-pack -v ../filter.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify blob:limit=10001' '
-	git -C r2 ls-files -s large.1000 large.10000 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r2 ls-files -s large.1000 large.10000 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	git -C r2 pack-objects --rev --stdout --filter=blob:limit=10001 >filter.pack <<-EOF &&
 	HEAD
 	EOF
 	git -C r2 index-pack ../filter.pack &&
-	git -C r2 verify-pack -v ../filter.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r2 verify-pack -v ../filter.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify blob:limit=1k' '
-	git -C r2 ls-files -s large.1000 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r2 ls-files -s large.1000 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	git -C r2 pack-objects --rev --stdout --filter=blob:limit=1k >filter.pack <<-EOF &&
 	HEAD
 	EOF
 	git -C r2 index-pack ../filter.pack &&
-	git -C r2 verify-pack -v ../filter.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r2 verify-pack -v ../filter.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify explicitly specifying oversized blob in input' '
-	git -C r2 ls-files -s large.1000 large.10000 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r2 ls-files -s large.1000 large.10000 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	git -C r2 pack-objects --rev --stdout --filter=blob:limit=1k >filter.pack <<-EOF &&
 	HEAD
 	$(git -C r2 rev-parse HEAD:large.10000)
 	EOF
 	git -C r2 index-pack ../filter.pack &&
-	git -C r2 verify-pack -v ../filter.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r2 verify-pack -v ../filter.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify blob:limit=1m' '
-	git -C r2 ls-files -s large.1000 large.10000 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r2 ls-files -s large.1000 large.10000 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	git -C r2 pack-objects --rev --stdout --filter=blob:limit=1m >filter.pack <<-EOF &&
 	HEAD
 	EOF
 	git -C r2 index-pack ../filter.pack &&
-	git -C r2 verify-pack -v ../filter.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r2 verify-pack -v ../filter.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify normal and blob:limit packfiles have same commits/trees' '
-	git -C r2 verify-pack -v ../all.pack \
-		| grep -E "commit|tree" \
-		| awk -f print_1.awk \
-		| sort >expected &&
-	git -C r2 verify-pack -v ../filter.pack \
-		| grep -E "commit|tree" \
-		| awk -f print_1.awk \
-		| sort >observed &&
+	git -C r2 verify-pack -v ../all.pack |
+	grep -E "commit|tree" |
+	awk -f print_1.awk |
+	sort >expected &&
+
+	git -C r2 verify-pack -v ../filter.pack |
+	grep -E "commit|tree" |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
@@ -224,71 +255,84 @@ test_expect_success 'setup r3' '
 '
 
 test_expect_success 'verify blob count in normal packfile' '
-	git -C r3 ls-files -s sparse1 sparse2 dir1/sparse1 dir1/sparse2 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r3 ls-files -s sparse1 sparse2 dir1/sparse1 dir1/sparse2 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	git -C r3 pack-objects --rev --stdout >all.pack <<-EOF &&
 	HEAD
 	EOF
 	git -C r3 index-pack ../all.pack &&
-	git -C r3 verify-pack -v ../all.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r3 verify-pack -v ../all.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify sparse:path=pattern1' '
-	git -C r3 ls-files -s dir1/sparse1 dir1/sparse2 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r3 ls-files -s dir1/sparse1 dir1/sparse2 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	git -C r3 pack-objects --rev --stdout --filter=sparse:path=../pattern1 >filter.pack <<-EOF &&
 	HEAD
 	EOF
 	git -C r3 index-pack ../filter.pack &&
-	git -C r3 verify-pack -v ../filter.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r3 verify-pack -v ../filter.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify normal and sparse:path=pattern1 packfiles have same commits/trees' '
-	git -C r3 verify-pack -v ../all.pack \
-		| grep -E "commit|tree" \
-		| awk -f print_1.awk \
-		| sort >expected &&
-	git -C r3 verify-pack -v ../filter.pack \
-		| grep -E "commit|tree" \
-		| awk -f print_1.awk \
-		| sort >observed &&
+	git -C r3 verify-pack -v ../all.pack |
+	grep -E "commit|tree" |
+	awk -f print_1.awk |
+	sort >expected &&
+
+	git -C r3 verify-pack -v ../filter.pack |
+	grep -E "commit|tree" |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify sparse:path=pattern2' '
-	git -C r3 ls-files -s sparse1 dir1/sparse1 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r3 ls-files -s sparse1 dir1/sparse1 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	git -C r3 pack-objects --rev --stdout --filter=sparse:path=../pattern2 >filter.pack <<-EOF &&
 	HEAD
 	EOF
 	git -C r3 index-pack ../filter.pack &&
-	git -C r3 verify-pack -v ../filter.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r3 verify-pack -v ../filter.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify normal and sparse:path=pattern2 packfiles have same commits/trees' '
-	git -C r3 verify-pack -v ../all.pack \
-		| grep -E "commit|tree" \
-		| awk -f print_1.awk \
-		| sort >expected &&
-	git -C r3 verify-pack -v ../filter.pack \
-		| grep -E "commit|tree" \
-		| awk -f print_1.awk \
-		| sort >observed &&
+	git -C r3 verify-pack -v ../all.pack |
+	grep -E "commit|tree" |
+	awk -f print_1.awk |
+	sort >expected &&
+
+	git -C r3 verify-pack -v ../filter.pack |
+	grep -E "commit|tree" |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
@@ -312,48 +356,57 @@ test_expect_success 'setup r4' '
 '
 
 test_expect_success 'verify blob count in normal packfile' '
-	git -C r4 ls-files -s pattern sparse1 sparse2 dir1/sparse1 dir1/sparse2 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r4 ls-files -s pattern sparse1 sparse2 dir1/sparse1 dir1/sparse2 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	git -C r4 pack-objects --rev --stdout >all.pack <<-EOF &&
 	HEAD
 	EOF
 	git -C r4 index-pack ../all.pack &&
-	git -C r4 verify-pack -v ../all.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r4 verify-pack -v ../all.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify sparse:oid=OID' '
-	git -C r4 ls-files -s dir1/sparse1 dir1/sparse2 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r4 ls-files -s dir1/sparse1 dir1/sparse2 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	oid=$(git -C r4 ls-files -s pattern | awk -f print_2.awk) &&
 	git -C r4 pack-objects --rev --stdout --filter=sparse:oid=$oid >filter.pack <<-EOF &&
 	HEAD
 	EOF
 	git -C r4 index-pack ../filter.pack &&
-	git -C r4 verify-pack -v ../filter.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r4 verify-pack -v ../filter.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify sparse:oid=oid-ish' '
-	git -C r4 ls-files -s dir1/sparse1 dir1/sparse2 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r4 ls-files -s dir1/sparse1 dir1/sparse2 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	git -C r4 pack-objects --rev --stdout --filter=sparse:oid=master:pattern >filter.pack <<-EOF &&
 	HEAD
 	EOF
 	git -C r4 index-pack ../filter.pack &&
-	git -C r4 verify-pack -v ../filter.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r4 verify-pack -v ../filter.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
@@ -361,9 +414,10 @@ test_expect_success 'verify sparse:oid=oid-ish' '
 # This models previously omitted objects that we did not receive.
 
 test_expect_success 'setup r1 - delete loose blobs' '
-	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	for id in `cat expected | sed "s|..|&/|"`
 	do
 		rm r1/.git/objects/$id
diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh
index 1b5a4a6d3..5ac6f286d 100755
--- a/t/t5500-fetch-pack.sh
+++ b/t/t5500-fetch-pack.sh
@@ -50,8 +50,9 @@ pull_to_client () {
 			case "$heads" in *B*)
 			    git update-ref refs/heads/B "$BTIP";;
 			esac &&
-			git symbolic-ref HEAD refs/heads/$(echo $heads \
-				| sed -e "s/^\(.\).*$/\1/") &&
+
+			git symbolic-ref HEAD refs/heads/$(echo $heads |
+			sed -e "s/^\(.\).*$/\1/") &&
 
 			git fsck --full &&
 
diff --git a/t/t5616-partial-clone.sh b/t/t5616-partial-clone.sh
index bbbe7537d..e4d032c9d 100755
--- a/t/t5616-partial-clone.sh
+++ b/t/t5616-partial-clone.sh
@@ -34,10 +34,12 @@ test_expect_success 'setup bare clone for server' '
 # confirm partial clone was registered in the local config.
 test_expect_success 'do partial clone 1' '
 	git clone --no-checkout --filter=blob:none "file://$(pwd)/srv.bare" pc1 &&
-	git -C pc1 rev-list HEAD --quiet --objects --missing=print \
-		| awk -f print_1.awk \
-		| sed "s/?//" \
-		| sort >observed.oids &&
+
+	git -C pc1 rev-list HEAD --quiet --objects --missing=print |
+	awk -f print_1.awk |
+	sed "s/?//" |
+	sort >observed.oids &&
+
 	test_cmp expect_1.oids observed.oids &&
 	test "$(git -C pc1 config --local core.repositoryformatversion)" = "1" &&
 	test "$(git -C pc1 config --local extensions.partialclone)" = "origin" &&
@@ -130,16 +132,20 @@ test_expect_success 'push new commits to server for file.3.txt' '
 # perhaps combined with a command in dry-run mode.
 test_expect_success 'manual prefetch of missing objects' '
 	git -C pc1 fetch --filter=blob:none origin &&
-	git -C pc1 rev-list master..origin/master --quiet --objects --missing=print \
-		| awk -f print_1.awk \
-		| sed "s/?//" \
-		| sort >observed.oids &&
+
+	git -C pc1 rev-list master..origin/master --quiet --objects --missing=print |
+	awk -f print_1.awk |
+	sed "s/?//" |
+	sort >observed.oids &&
+
 	test_line_count = 6 observed.oids &&
 	git -C pc1 fetch-pack --stdin "file://$(pwd)/srv.bare" <observed.oids &&
-	git -C pc1 rev-list master..origin/master --quiet --objects --missing=print \
-		| awk -f print_1.awk \
-		| sed "s/?//" \
-		| sort >observed.oids &&
+
+	git -C pc1 rev-list master..origin/master --quiet --objects --missing=print |
+	awk -f print_1.awk |
+	sed "s/?//" |
+	sort >observed.oids &&
+
 	test_line_count = 0 observed.oids
 '
 
@@ -194,7 +200,7 @@ test_expect_success 'upon cloning, check that all refs point to objects' '
 
 	# Craft a packfile not including that blob.
 	git -C "$SERVER" rev-parse HEAD |
-		git -C "$SERVER" pack-objects --stdout >incomplete.pack &&
+	git -C "$SERVER" pack-objects --stdout >incomplete.pack &&
 
 	# Replace the existing packfile with the crafted one. The protocol
 	# requires that the packfile be sent in sideband 1, hence the extra
diff --git a/t/t6112-rev-list-filters-objects.sh b/t/t6112-rev-list-filters-objects.sh
index d4ff0b3be..0f6b569e1 100755
--- a/t/t6112-rev-list-filters-objects.sh
+++ b/t/t6112-rev-list-filters-objects.sh
@@ -20,24 +20,28 @@ test_expect_success 'setup r1' '
 '
 
 test_expect_success 'verify blob:none omits all 5 blobs' '
-	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 \
-		| awk -f print_2.awk \
-		| sort >expected &&
-	git -C r1 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:none \
-		| awk -f print_1.awk \
-		| sed "s/~//" \
-		| sort >observed &&
+	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 |
+	awk -f print_2.awk |
+	sort >expected &&
+
+	git -C r1 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:none |
+	awk -f print_1.awk |
+	sed "s/~//" |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify emitted+omitted == all' '
-	git -C r1 rev-list HEAD --objects \
-		| awk -f print_1.awk \
-		| sort >expected &&
-	git -C r1 rev-list HEAD --objects --filter-print-omitted --filter=blob:none \
-		| awk -f print_1.awk \
-		| sed "s/~//" \
-		| sort >observed &&
+	git -C r1 rev-list HEAD --objects |
+	awk -f print_1.awk |
+	sort >expected &&
+
+	git -C r1 rev-list HEAD --objects --filter-print-omitted --filter=blob:none |
+	awk -f print_1.awk |
+	sed "s/~//" |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
@@ -58,65 +62,76 @@ test_expect_success 'setup r2' '
 '
 
 test_expect_success 'verify blob:limit=500 omits all blobs' '
-	git -C r2 ls-files -s large.1000 large.10000 \
-		| awk -f print_2.awk \
-		| sort >expected &&
-	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=500 \
-		| awk -f print_1.awk \
-		| sed "s/~//" \
-		| sort >observed &&
+	git -C r2 ls-files -s large.1000 large.10000 |
+	awk -f print_2.awk |
+	sort >expected &&
+
+	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=500 |
+	awk -f print_1.awk |
+	sed "s/~//" |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify emitted+omitted == all' '
-	git -C r2 rev-list HEAD --objects \
-		| awk -f print_1.awk \
-		| sort >expected &&
-	git -C r2 rev-list HEAD --objects --filter-print-omitted --filter=blob:limit=500 \
-		| awk -f print_1.awk \
-		| sed "s/~//" \
-		| sort >observed &&
+	git -C r2 rev-list HEAD --objects |
+	awk -f print_1.awk |
+	sort >expected &&
+
+	git -C r2 rev-list HEAD --objects --filter-print-omitted --filter=blob:limit=500 |
+	awk -f print_1.awk |
+	sed "s/~//" |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify blob:limit=1000' '
-	git -C r2 ls-files -s large.1000 large.10000 \
-		| awk -f print_2.awk \
-		| sort >expected &&
-	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1000 \
-		| awk -f print_1.awk \
-		| sed "s/~//" \
-		| sort >observed &&
+	git -C r2 ls-files -s large.1000 large.10000 |
+	awk -f print_2.awk |
+	sort >expected &&
+
+	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1000 |
+	awk -f print_1.awk |
+	sed "s/~//" |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify blob:limit=1001' '
-	git -C r2 ls-files -s large.10000 \
-		| awk -f print_2.awk \
-		| sort >expected &&
-	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1001 \
-		| awk -f print_1.awk \
-		| sed "s/~//" \
-		| sort >observed &&
+	git -C r2 ls-files -s large.10000 |
+	awk -f print_2.awk |
+	sort >expected &&
+
+	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1001 |
+	awk -f print_1.awk |
+	sed "s/~//" |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify blob:limit=1k' '
-	git -C r2 ls-files -s large.10000 \
-		| awk -f print_2.awk \
-		| sort >expected &&
-	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1k \
-		| awk -f print_1.awk \
-		| sed "s/~//" \
-		| sort >observed &&
+	git -C r2 ls-files -s large.10000 |
+	awk -f print_2.awk |
+	sort >expected &&
+
+	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1k |
+	awk -f print_1.awk |
+	sed "s/~//" |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify blob:limit=1m' '
-	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1m \
-		| awk -f print_1.awk \
-		| sed "s/~//" \
-		| sort >observed &&
+	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1m |
+	awk -f print_1.awk |
+	sed "s/~//" |
+	sort >observed &&
+
 	test_must_be_empty observed
 '
 
@@ -141,24 +156,28 @@ test_expect_success 'setup r3' '
 '
 
 test_expect_success 'verify sparse:path=pattern1 omits top-level files' '
-	git -C r3 ls-files -s sparse1 sparse2 \
-		| awk -f print_2.awk \
-		| sort >expected &&
-	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:path=../pattern1 \
-		| awk -f print_1.awk \
-		| sed "s/~//" \
-		| sort >observed &&
+	git -C r3 ls-files -s sparse1 sparse2 |
+	awk -f print_2.awk |
+	sort >expected &&
+
+	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:path=../pattern1 |
+	awk -f print_1.awk |
+	sed "s/~//" |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify sparse:path=pattern2 omits both sparse2 files' '
-	git -C r3 ls-files -s sparse2 dir1/sparse2 \
-		| awk -f print_2.awk \
-		| sort >expected &&
-	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:path=../pattern2 \
-		| awk -f print_1.awk \
-		| sed "s/~//" \
-		| sort >observed &&
+	git -C r3 ls-files -s sparse2 dir1/sparse2 |
+	awk -f print_2.awk |
+	sort >expected &&
+
+	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:path=../pattern2 |
+	awk -f print_1.awk |
+	sed "s/~//" |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
@@ -173,25 +192,30 @@ test_expect_success 'setup r3 part 2' '
 '
 
 test_expect_success 'verify sparse:oid=OID omits top-level files' '
-	git -C r3 ls-files -s pattern sparse1 sparse2 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r3 ls-files -s pattern sparse1 sparse2 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	oid=$(git -C r3 ls-files -s pattern | awk -f print_2.awk) &&
-	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:oid=$oid \
-		| awk -f print_1.awk \
-		| sed "s/~//" \
-		| sort >observed &&
+
+	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:oid=$oid |
+	awk -f print_1.awk |
+	sed "s/~//" |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify sparse:oid=oid-ish omits top-level files' '
-	git -C r3 ls-files -s pattern sparse1 sparse2 \
-		| awk -f print_2.awk \
-		| sort >expected &&
-	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:oid=master:pattern \
-		| awk -f print_1.awk \
-		| sed "s/~//" \
-		| sort >observed &&
+	git -C r3 ls-files -s pattern sparse1 sparse2 |
+	awk -f print_2.awk |
+	sort >expected &&
+
+	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:oid=master:pattern |
+	awk -f print_1.awk |
+	sed "s/~//" |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
@@ -199,17 +223,20 @@ test_expect_success 'verify sparse:oid=oid-ish omits top-level files' '
 # This models previously omitted objects that we did not receive.
 
 test_expect_success 'rev-list W/ --missing=print' '
-	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	for id in `cat expected | sed "s|..|&/|"`
 	do
 		rm r1/.git/objects/$id
 	done &&
-	git -C r1 rev-list --quiet HEAD --missing=print --objects \
-		| awk -f print_1.awk \
-		| sed "s/?//" \
-		| sort >observed &&
+
+	git -C r1 rev-list --quiet HEAD --missing=print --objects |
+	awk -f print_1.awk |
+	sed "s/?//" |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
-- 
2.19.0.444.g18242da7ef-goog


^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [PATCH v2 3/6] t/*: fix ordering of expected/observed arguments
       [not found] ` <cover.1537223021.git.matvore@google.com>
  2018-09-17 22:24   ` [PATCH v2 1/6] CodingGuidelines: add shell piping guidelines Matthew DeVore
  2018-09-17 22:24   ` [PATCH v2 2/6] tests: standardize pipe placement Matthew DeVore
@ 2018-09-17 22:24   ` Matthew DeVore
  2018-09-17 22:24   ` [PATCH v2 4/6] tests: add linter check for pipe placement style Matthew DeVore
                     ` (2 subsequent siblings)
  5 siblings, 0 replies; 66+ messages in thread
From: Matthew DeVore @ 2018-09-17 22:24 UTC (permalink / raw)
  To: git; +Cc: Matthew DeVore, peff, jonathantanmy, gitster, jrn

Fix various places where the ordering was obviously wrong, meaning it
was easy to find with grep.

Signed-off-by: Matthew DeVore <matvore@google.com>
---
 t/t0000-basic.sh                       |  2 +-
 t/t0021-conversion.sh                  |  4 +--
 t/t1300-config.sh                      |  4 +--
 t/t1303-wacky-config.sh                |  4 +--
 t/t2101-update-index-reupdate.sh       |  2 +-
 t/t3200-branch.sh                      |  2 +-
 t/t3320-notes-merge-worktrees.sh       |  4 +--
 t/t3400-rebase.sh                      |  8 +++---
 t/t3417-rebase-whitespace-fix.sh       |  6 ++---
 t/t3702-add-edit.sh                    |  4 +--
 t/t3903-stash.sh                       |  8 +++---
 t/t3905-stash-include-untracked.sh     |  2 +-
 t/t4025-hunk-header.sh                 |  2 +-
 t/t4117-apply-reject.sh                |  6 ++---
 t/t4124-apply-ws-rule.sh               | 30 +++++++++++------------
 t/t4138-apply-ws-expansion.sh          |  2 +-
 t/t5317-pack-objects-filter-objects.sh | 34 +++++++++++++-------------
 t/t5318-commit-graph.sh                |  2 +-
 t/t5701-git-serve.sh                   | 14 +++++------
 t/t5702-protocol-v2.sh                 | 10 ++++----
 t/t6023-merge-file.sh                  | 12 ++++-----
 t/t6027-merge-binary.sh                |  4 +--
 t/t6031-merge-filemode.sh              |  2 +-
 t/t6112-rev-list-filters-objects.sh    | 24 +++++++++---------
 t/t7201-co.sh                          |  4 +--
 t/t7406-submodule-update.sh            |  8 +++---
 t/t7800-difftool.sh                    |  2 +-
 t/t9100-git-svn-basic.sh               |  2 +-
 t/t9133-git-svn-nested-git-repo.sh     |  6 ++---
 t/t9600-cvsimport.sh                   |  2 +-
 t/t9603-cvsimport-patchsets.sh         |  4 +--
 t/t9604-cvsimport-timestamps.sh        |  4 +--
 32 files changed, 112 insertions(+), 112 deletions(-)

diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh
index 850f651e4..224c098a8 100755
--- a/t/t0000-basic.sh
+++ b/t/t0000-basic.sh
@@ -1018,7 +1018,7 @@ test_expect_success SHA1 'validate git diff-files output for a know cache/work t
 :120000 120000 6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c 0000000000000000000000000000000000000000 M	path3/subp3/file3sym
 EOF
 	git diff-files >current &&
-	test_cmp current expected
+	test_cmp expected current
 '
 
 test_expect_success 'git update-index --refresh should succeed' '
diff --git a/t/t0021-conversion.sh b/t/t0021-conversion.sh
index 308cd28f3..fd5f1ac64 100755
--- a/t/t0021-conversion.sh
+++ b/t/t0021-conversion.sh
@@ -166,10 +166,10 @@ test_expect_success expanded_in_repo '
 	rm -f expanded-keywords expanded-keywords-crlf &&
 
 	git checkout -- expanded-keywords &&
-	test_cmp expanded-keywords expected-output &&
+	test_cmp expected-output expanded-keywords &&
 
 	git checkout -- expanded-keywords-crlf &&
-	test_cmp expanded-keywords-crlf expected-output-crlf
+	test_cmp expected-output-crlf expanded-keywords-crlf
 '
 
 # The use of %f in a filter definition is expanded to the path to
diff --git a/t/t1300-config.sh b/t/t1300-config.sh
index 5869d6cb6..e2cd50ecf 100755
--- a/t/t1300-config.sh
+++ b/t/t1300-config.sh
@@ -1001,7 +1001,7 @@ EOF
 
 test_expect_success 'value continued on next line' '
 	git config --list > result &&
-	test_cmp result expect
+	test_cmp expect result
 '
 
 cat > .git/config <<\EOF
@@ -1882,7 +1882,7 @@ test_expect_success '--replace-all does not invent newlines' '
 	Qkey = b
 	EOF
 	git config --replace-all abc.key b &&
-	test_cmp .git/config expect
+	test_cmp expect .git/config
 '
 
 test_done
diff --git a/t/t1303-wacky-config.sh b/t/t1303-wacky-config.sh
index 3b92083e1..0000e664e 100755
--- a/t/t1303-wacky-config.sh
+++ b/t/t1303-wacky-config.sh
@@ -14,7 +14,7 @@ setup() {
 check() {
 	echo "$2" >expected
 	git config --get "$1" >actual 2>&1
-	test_cmp actual expected
+	test_cmp expected actual
 }
 
 # 'check section.key regex value' verifies that the entry for
@@ -22,7 +22,7 @@ check() {
 check_regex() {
 	echo "$3" >expected
 	git config --get "$1" "$2" >actual 2>&1
-	test_cmp actual expected
+	test_cmp expected actual
 }
 
 test_expect_success 'modify same key' '
diff --git a/t/t2101-update-index-reupdate.sh b/t/t2101-update-index-reupdate.sh
index 685ec4563..6c32d42c8 100755
--- a/t/t2101-update-index-reupdate.sh
+++ b/t/t2101-update-index-reupdate.sh
@@ -73,7 +73,7 @@ test_expect_success 'update-index --update from subdir' '
 	100644 $(git hash-object dir1/file3) 0	dir1/file3
 	100644 $file2 0	file2
 	EOF
-	test_cmp current expected
+	test_cmp expected current
 '
 
 test_expect_success 'update-index --update with pathspec' '
diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index 93f21ab07..478b82cf9 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -1221,7 +1221,7 @@ test_expect_success 'use --edit-description' '
 	EOF
 	EDITOR=./editor git branch --edit-description &&
 	echo "New contents" >expect &&
-	test_cmp EDITOR_OUTPUT expect
+	test_cmp expect EDITOR_OUTPUT
 '
 
 test_expect_success 'detect typo in branch name when using --edit-description' '
diff --git a/t/t3320-notes-merge-worktrees.sh b/t/t3320-notes-merge-worktrees.sh
index 10bfc8b94..823fdbda1 100755
--- a/t/t3320-notes-merge-worktrees.sh
+++ b/t/t3320-notes-merge-worktrees.sh
@@ -44,7 +44,7 @@ test_expect_success 'merge z into y fails and sets NOTES_MERGE_REF' '
 	git config core.notesRef refs/notes/y &&
 	test_must_fail git notes merge z &&
 	echo "ref: refs/notes/y" >expect &&
-	test_cmp .git/NOTES_MERGE_REF expect
+	test_cmp expect .git/NOTES_MERGE_REF
 '
 
 test_expect_success 'merge z into y while mid-merge in another workdir fails' '
@@ -66,7 +66,7 @@ test_expect_success 'merge z into x while mid-merge on y succeeds' '
 		grep -v "A notes merge into refs/notes/x is already in-progress in" out
 	) &&
 	echo "ref: refs/notes/x" >expect &&
-	test_cmp .git/worktrees/worktree2/NOTES_MERGE_REF expect
+	test_cmp expect .git/worktrees/worktree2/NOTES_MERGE_REF
 '
 
 test_done
diff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh
index 3996ee013..3e73f7584 100755
--- a/t/t3400-rebase.sh
+++ b/t/t3400-rebase.sh
@@ -183,13 +183,13 @@ test_expect_success 'cherry-picked commits and fork-point work together' '
 	test_commit final_B B "Final B" &&
 	git rebase &&
 	echo Amended >expect &&
-	test_cmp A expect &&
+	test_cmp expect A &&
 	echo "Final B" >expect &&
-	test_cmp B expect &&
+	test_cmp expect B &&
 	echo C >expect &&
-	test_cmp C expect &&
+	test_cmp expect C &&
 	echo D >expect &&
-	test_cmp D expect
+	test_cmp expect D
 '
 
 test_expect_success 'rebase -q is quiet' '
diff --git a/t/t3417-rebase-whitespace-fix.sh b/t/t3417-rebase-whitespace-fix.sh
index 1fb3e499b..e85cdc703 100755
--- a/t/t3417-rebase-whitespace-fix.sh
+++ b/t/t3417-rebase-whitespace-fix.sh
@@ -55,7 +55,7 @@ test_expect_success 'blank line at end of file; extend at end of file' '
 	git add file &&	git commit -m second &&
 	git rebase --whitespace=fix HEAD^^ &&
 	git diff --exit-code HEAD^:file expect-first &&
-	test_cmp file expect-second
+	test_cmp expect-second file
 '
 
 # prepare third revision of "file"
@@ -82,7 +82,7 @@ test_expect_success 'two blanks line at end of file; extend at end of file' '
 	cp third file && git add file && git commit -m third &&
 	git rebase --whitespace=fix HEAD^^ &&
 	git diff --exit-code HEAD^:file expect-second &&
-	test_cmp file expect-third
+	test_cmp expect-third file
 '
 
 test_expect_success 'same, but do not remove trailing spaces' '
@@ -120,7 +120,7 @@ test_expect_success 'at beginning of file' '
 	done >> file &&
 	git commit -m more file	&&
 	git rebase --whitespace=fix HEAD^^ &&
-	test_cmp file expect-beginning
+	test_cmp expect-beginning file
 '
 
 test_done
diff --git a/t/t3702-add-edit.sh b/t/t3702-add-edit.sh
index c6af7f82b..6c676645d 100755
--- a/t/t3702-add-edit.sh
+++ b/t/t3702-add-edit.sh
@@ -110,10 +110,10 @@ test_expect_success 'add -e' '
 	cp second-part file &&
 	git add -e &&
 	test_cmp second-part file &&
-	test_cmp orig-patch expected-patch &&
+	test_cmp expected-patch orig-patch &&
 	git diff --cached >actual &&
 	grep -v index actual >out &&
-	test_cmp out expected
+	test_cmp expected out
 
 '
 
diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh
index 6450bc669..cd216655b 100755
--- a/t/t3903-stash.sh
+++ b/t/t3903-stash.sh
@@ -36,7 +36,7 @@ EOF
 test_expect_success 'parents of stash' '
 	test $(git rev-parse stash^) = $(git rev-parse HEAD) &&
 	git diff stash^2..stash > output &&
-	test_cmp output expect
+	test_cmp expect output
 '
 
 test_expect_success 'applying bogus stash does nothing' '
@@ -210,9 +210,9 @@ test_expect_success 'stash branch' '
 	test refs/heads/stashbranch = $(git symbolic-ref HEAD) &&
 	test $(git rev-parse HEAD) = $(git rev-parse master^) &&
 	git diff --cached > output &&
-	test_cmp output expect &&
+	test_cmp expect output &&
 	git diff > output &&
-	test_cmp output expect1 &&
+	test_cmp expect1 output &&
 	git add file &&
 	git commit -m alternate\ second &&
 	git diff master..stashbranch > output &&
@@ -710,7 +710,7 @@ test_expect_success 'stash where working directory contains "HEAD" file' '
 	git diff-index --cached --quiet HEAD &&
 	test "$(git rev-parse stash^)" = "$(git rev-parse HEAD)" &&
 	git diff stash^..stash > output &&
-	test_cmp output expect
+	test_cmp expect output
 '
 
 test_expect_success 'store called with invalid commit' '
diff --git a/t/t3905-stash-include-untracked.sh b/t/t3905-stash-include-untracked.sh
index 597b0637d..cc1c8a7bb 100755
--- a/t/t3905-stash-include-untracked.sh
+++ b/t/t3905-stash-include-untracked.sh
@@ -142,7 +142,7 @@ test_expect_success 'stash save --include-untracked removed files' '
 	rm -f file &&
 	git stash save --include-untracked &&
 	echo 1 > expect &&
-	test_cmp file expect
+	test_cmp expect file
 '
 
 rm -f expect
diff --git a/t/t4025-hunk-header.sh b/t/t4025-hunk-header.sh
index fa44e7886..35578f2bb 100755
--- a/t/t4025-hunk-header.sh
+++ b/t/t4025-hunk-header.sh
@@ -37,7 +37,7 @@ test_expect_success 'hunk header truncation with an overly long line' '
 		echo " A $N$N$N$N$N$N$N$N$N2" &&
 		echo " L  $N$N$N$N$N$N$N$N$N1"
 	) >expected &&
-	test_cmp actual expected
+	test_cmp expected actual
 
 '
 
diff --git a/t/t4117-apply-reject.sh b/t/t4117-apply-reject.sh
index d80187de9..f7de6f077 100755
--- a/t/t4117-apply-reject.sh
+++ b/t/t4117-apply-reject.sh
@@ -72,7 +72,7 @@ test_expect_success 'apply with --reject should fail but update the file' '
 	rm -f file1.rej file2.rej &&
 
 	test_must_fail git apply --reject patch.1 &&
-	test_cmp file1 expected &&
+	test_cmp expected file1 &&
 
 	cat file1.rej &&
 	test_path_is_missing file2.rej
@@ -85,7 +85,7 @@ test_expect_success 'apply with --reject should fail but update the file' '
 
 	test_must_fail git apply --reject patch.2 >rejects &&
 	test_path_is_missing file1 &&
-	test_cmp file2 expected &&
+	test_cmp expected file2 &&
 
 	cat file2.rej &&
 	test_path_is_missing file1.rej
@@ -99,7 +99,7 @@ test_expect_success 'the same test with --verbose' '
 
 	test_must_fail git apply --reject --verbose patch.2 >rejects &&
 	test_path_is_missing file1 &&
-	test_cmp file2 expected &&
+	test_cmp expected file2 &&
 
 	cat file2.rej &&
 	test_path_is_missing file1.rej
diff --git a/t/t4124-apply-ws-rule.sh b/t/t4124-apply-ws-rule.sh
index 7e32237a2..ff51e9e78 100755
--- a/t/t4124-apply-ws-rule.sh
+++ b/t/t4124-apply-ws-rule.sh
@@ -313,9 +313,9 @@ test_expect_success 'applying beyond EOF requires one non-blank context line' '
 	{ echo a; echo; } >one &&
 	cp one expect &&
 	test_must_fail git apply --whitespace=fix patch &&
-	test_cmp one expect &&
+	test_cmp expect one &&
 	test_must_fail git apply --ignore-space-change --whitespace=fix patch &&
-	test_cmp one expect
+	test_cmp expect one
 '
 
 test_expect_success 'tons of blanks at EOF should not apply' '
@@ -342,10 +342,10 @@ test_expect_success 'missing blank line at end with --whitespace=fix' '
 	cp one saved-one &&
 	test_must_fail git apply patch &&
 	git apply --whitespace=fix patch &&
-	test_cmp one expect &&
+	test_cmp expect one &&
 	mv saved-one one &&
 	git apply --ignore-space-change --whitespace=fix patch &&
-	test_cmp one expect
+	test_cmp expect one
 '
 
 test_expect_success 'two missing blank lines at end with --whitespace=fix' '
@@ -360,11 +360,11 @@ test_expect_success 'two missing blank lines at end with --whitespace=fix' '
 	cp no-blank-lines one &&
 	test_must_fail git apply patch &&
 	git apply --whitespace=fix patch &&
-	test_cmp one expect &&
+	test_cmp expect one &&
 	mv no-blank-lines one &&
 	test_must_fail git apply patch &&
 	git apply --ignore-space-change --whitespace=fix patch &&
-	test_cmp one expect
+	test_cmp expect one
 '
 
 test_expect_success 'missing blank line at end, insert before end, --whitespace=fix' '
@@ -376,7 +376,7 @@ test_expect_success 'missing blank line at end, insert before end, --whitespace=
 	echo a >one &&
 	test_must_fail git apply patch &&
 	git apply --whitespace=fix patch &&
-	test_cmp one expect
+	test_cmp expect one
 '
 
 test_expect_success 'shrink file with tons of missing blanks at end of file' '
@@ -392,10 +392,10 @@ test_expect_success 'shrink file with tons of missing blanks at end of file' '
 	cp no-blank-lines one &&
 	test_must_fail git apply patch &&
 	git apply --whitespace=fix patch &&
-	test_cmp one expect &&
+	test_cmp expect one &&
 	mv no-blank-lines one &&
 	git apply --ignore-space-change --whitespace=fix patch &&
-	test_cmp one expect
+	test_cmp expect one
 '
 
 test_expect_success 'missing blanks at EOF must only match blank lines' '
@@ -427,7 +427,7 @@ test_expect_success 'missing blank line should match context line with spaces' '
 	git add one &&
 
 	git apply --whitespace=fix patch &&
-	test_cmp one expect
+	test_cmp expect one
 '
 
 sed -e's/Z//' >one <<EOF
@@ -447,7 +447,7 @@ test_expect_success 'same, but with the --ignore-space-option' '
 
 	git checkout-index -f one &&
 	git apply --ignore-space-change --whitespace=fix patch &&
-	test_cmp one expect
+	test_cmp expect one
 '
 
 test_expect_success 'same, but with CR-LF line endings && cr-at-eol set' '
@@ -464,7 +464,7 @@ test_expect_success 'same, but with CR-LF line endings && cr-at-eol set' '
 	mv save-one one &&
 
 	git apply --ignore-space-change --whitespace=fix patch &&
-	test_cmp one expect
+	test_cmp expect one
 '
 
 test_expect_success 'CR-LF line endings && add line && text=auto' '
@@ -478,7 +478,7 @@ test_expect_success 'CR-LF line endings && add line && text=auto' '
 	mv save-one one &&
 	echo "one text=auto" >.gitattributes &&
 	git apply patch &&
-	test_cmp one expect
+	test_cmp expect one
 '
 
 test_expect_success 'CR-LF line endings && change line && text=auto' '
@@ -491,7 +491,7 @@ test_expect_success 'CR-LF line endings && change line && text=auto' '
 	mv save-one one &&
 	echo "one text=auto" >.gitattributes &&
 	git apply patch &&
-	test_cmp one expect
+	test_cmp expect one
 '
 
 test_expect_success 'LF in repo, CRLF in worktree && change line && text=auto' '
@@ -503,7 +503,7 @@ test_expect_success 'LF in repo, CRLF in worktree && change line && text=auto' '
 	echo "one text=auto" >.gitattributes &&
 	git -c core.eol=CRLF apply patch &&
 	printf "b\r\n" >expect &&
-	test_cmp one expect
+	test_cmp expect one
 '
 
 test_expect_success 'whitespace=fix to expand' '
diff --git a/t/t4138-apply-ws-expansion.sh b/t/t4138-apply-ws-expansion.sh
index 0ffe33fbe..3b636a63a 100755
--- a/t/t4138-apply-ws-expansion.sh
+++ b/t/t4138-apply-ws-expansion.sh
@@ -114,7 +114,7 @@ for t in 1 2 3 4
 do
 	test_expect_success 'apply with ws expansion (t=$t)' '
 		git apply patch$t.patch &&
-		test_cmp test-$t expect-$t
+		test_cmp expect-$t test-$t
 	'
 done
 
diff --git a/t/t5317-pack-objects-filter-objects.sh b/t/t5317-pack-objects-filter-objects.sh
index ce69148ec..c093eb891 100755
--- a/t/t5317-pack-objects-filter-objects.sh
+++ b/t/t5317-pack-objects-filter-objects.sh
@@ -34,7 +34,7 @@ test_expect_success 'verify blob count in normal packfile' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify blob:none packfile has no blobs' '
@@ -63,7 +63,7 @@ test_expect_success 'verify normal and blob:none packfiles have same commits/tre
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 # Test blob:limit=<n>[kmg] filter.
@@ -96,7 +96,7 @@ test_expect_success 'verify blob count in normal packfile' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify blob:limit=500 omits all blobs' '
@@ -144,7 +144,7 @@ test_expect_success 'verify blob:limit=1001' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify blob:limit=10001' '
@@ -162,7 +162,7 @@ test_expect_success 'verify blob:limit=10001' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify blob:limit=1k' '
@@ -180,7 +180,7 @@ test_expect_success 'verify blob:limit=1k' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify explicitly specifying oversized blob in input' '
@@ -199,7 +199,7 @@ test_expect_success 'verify explicitly specifying oversized blob in input' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify blob:limit=1m' '
@@ -217,7 +217,7 @@ test_expect_success 'verify blob:limit=1m' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify normal and blob:limit packfiles have same commits/trees' '
@@ -231,7 +231,7 @@ test_expect_success 'verify normal and blob:limit packfiles have same commits/tr
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 # Test sparse:path=<path> filter.
@@ -269,7 +269,7 @@ test_expect_success 'verify blob count in normal packfile' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify sparse:path=pattern1' '
@@ -287,7 +287,7 @@ test_expect_success 'verify sparse:path=pattern1' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify normal and sparse:path=pattern1 packfiles have same commits/trees' '
@@ -301,7 +301,7 @@ test_expect_success 'verify normal and sparse:path=pattern1 packfiles have same
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify sparse:path=pattern2' '
@@ -319,7 +319,7 @@ test_expect_success 'verify sparse:path=pattern2' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify normal and sparse:path=pattern2 packfiles have same commits/trees' '
@@ -333,7 +333,7 @@ test_expect_success 'verify normal and sparse:path=pattern2 packfiles have same
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 # Test sparse:oid=<oid-ish> filter.
@@ -370,7 +370,7 @@ test_expect_success 'verify blob count in normal packfile' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify sparse:oid=OID' '
@@ -389,7 +389,7 @@ test_expect_success 'verify sparse:oid=OID' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify sparse:oid=oid-ish' '
@@ -407,7 +407,7 @@ test_expect_success 'verify sparse:oid=oid-ish' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 # Delete some loose objects and use pack-objects, but WITHOUT any filtering.
diff --git a/t/t5318-commit-graph.sh b/t/t5318-commit-graph.sh
index 0c500f7ca..d6da3ce4e 100755
--- a/t/t5318-commit-graph.sh
+++ b/t/t5318-commit-graph.sh
@@ -35,7 +35,7 @@ test_expect_success 'create commits and repack' '
 graph_git_two_modes() {
 	git -c core.commitGraph=true $1 >output
 	git -c core.commitGraph=false $1 >expect
-	test_cmp output expect
+	test_cmp expect output
 }
 
 graph_git_behavior() {
diff --git a/t/t5701-git-serve.sh b/t/t5701-git-serve.sh
index 75ec79e6c..bf139e245 100755
--- a/t/t5701-git-serve.sh
+++ b/t/t5701-git-serve.sh
@@ -16,7 +16,7 @@ test_expect_success 'test capability advertisement' '
 
 	git serve --advertise-capabilities >out &&
 	test-pkt-line unpack <out >actual &&
-	test_cmp actual expect
+	test_cmp expect actual
 '
 
 test_expect_success 'stateless-rpc flag does not list capabilities' '
@@ -89,7 +89,7 @@ test_expect_success 'basics of ls-refs' '
 
 	git serve --stateless-rpc <in >out &&
 	test-pkt-line unpack <out >actual &&
-	test_cmp actual expect
+	test_cmp expect actual
 '
 
 test_expect_success 'basic ref-prefixes' '
@@ -109,7 +109,7 @@ test_expect_success 'basic ref-prefixes' '
 
 	git serve --stateless-rpc <in >out &&
 	test-pkt-line unpack <out >actual &&
-	test_cmp actual expect
+	test_cmp expect actual
 '
 
 test_expect_success 'refs/heads prefix' '
@@ -129,7 +129,7 @@ test_expect_success 'refs/heads prefix' '
 
 	git serve --stateless-rpc <in >out &&
 	test-pkt-line unpack <out >actual &&
-	test_cmp actual expect
+	test_cmp expect actual
 '
 
 test_expect_success 'peel parameter' '
@@ -150,7 +150,7 @@ test_expect_success 'peel parameter' '
 
 	git serve --stateless-rpc <in >out &&
 	test-pkt-line unpack <out >actual &&
-	test_cmp actual expect
+	test_cmp expect actual
 '
 
 test_expect_success 'symrefs parameter' '
@@ -171,7 +171,7 @@ test_expect_success 'symrefs parameter' '
 
 	git serve --stateless-rpc <in >out &&
 	test-pkt-line unpack <out >actual &&
-	test_cmp actual expect
+	test_cmp expect actual
 '
 
 test_expect_success 'sending server-options' '
@@ -191,7 +191,7 @@ test_expect_success 'sending server-options' '
 
 	git serve --stateless-rpc <in >out &&
 	test-pkt-line unpack <out >actual &&
-	test_cmp actual expect
+	test_cmp expect actual
 '
 
 test_expect_success 'unexpected lines are not allowed in fetch request' '
diff --git a/t/t5702-protocol-v2.sh b/t/t5702-protocol-v2.sh
index 3beeed454..54727450b 100755
--- a/t/t5702-protocol-v2.sh
+++ b/t/t5702-protocol-v2.sh
@@ -29,7 +29,7 @@ test_expect_success 'list refs with git:// using protocol v2' '
 	grep "git< version 2" log &&
 
 	git ls-remote --symref "$GIT_DAEMON_URL/parent" >expect &&
-	test_cmp actual expect
+	test_cmp expect actual
 '
 
 test_expect_success 'ref advertisment is filtered with ls-remote using protocol v2' '
@@ -42,7 +42,7 @@ test_expect_success 'ref advertisment is filtered with ls-remote using protocol
 	$(git -C "$daemon_parent" rev-parse refs/heads/master)$(printf "\t")refs/heads/master
 	EOF
 
-	test_cmp actual expect
+	test_cmp expect actual
 '
 
 test_expect_success 'clone with git:// using protocol v2' '
@@ -138,7 +138,7 @@ test_expect_success 'list refs with file:// using protocol v2' '
 	grep "git< version 2" log &&
 
 	git ls-remote --symref "file://$(pwd)/file_parent" >expect &&
-	test_cmp actual expect
+	test_cmp expect actual
 '
 
 test_expect_success 'ref advertisment is filtered with ls-remote using protocol v2' '
@@ -151,7 +151,7 @@ test_expect_success 'ref advertisment is filtered with ls-remote using protocol
 	$(git -C file_parent rev-parse refs/heads/master)$(printf "\t")refs/heads/master
 	EOF
 
-	test_cmp actual expect
+	test_cmp expect actual
 '
 
 test_expect_success 'server-options are sent when using ls-remote' '
@@ -164,7 +164,7 @@ test_expect_success 'server-options are sent when using ls-remote' '
 	$(git -C file_parent rev-parse refs/heads/master)$(printf "\t")refs/heads/master
 	EOF
 
-	test_cmp actual expect &&
+	test_cmp expect actual &&
 	grep "server-option=hello" log &&
 	grep "server-option=world" log
 '
diff --git a/t/t6023-merge-file.sh b/t/t6023-merge-file.sh
index 20aee43f9..51ee887a7 100755
--- a/t/t6023-merge-file.sh
+++ b/t/t6023-merge-file.sh
@@ -99,7 +99,7 @@ EOF
 printf "propter nomen suum." >> expect.txt
 
 test_expect_success "merge does not add LF away of change" \
-	"test_cmp test3.txt expect.txt"
+	"test_cmp expect.txt test3.txt"
 
 cp test.txt backup.txt
 test_expect_success "merge with conflicts" \
@@ -122,7 +122,7 @@ non timebo mala, quoniam tu mecum es:
 virga tua et baculus tuus ipsa me consolata sunt.
 EOF
 
-test_expect_success "expected conflict markers" "test_cmp test.txt expect.txt"
+test_expect_success "expected conflict markers" "test_cmp expect.txt test.txt"
 
 cp backup.txt test.txt
 
@@ -138,7 +138,7 @@ non timebo mala, quoniam tu mecum es:
 virga tua et baculus tuus ipsa me consolata sunt.
 EOF
 test_expect_success "merge conflicting with --ours" \
-	"git merge-file --ours test.txt orig.txt new3.txt && test_cmp test.txt expect.txt"
+	"git merge-file --ours test.txt orig.txt new3.txt && test_cmp expect.txt test.txt"
 cp backup.txt test.txt
 
 cat > expect.txt << EOF
@@ -154,7 +154,7 @@ non timebo mala, quoniam tu mecum es:
 virga tua et baculus tuus ipsa me consolata sunt.
 EOF
 test_expect_success "merge conflicting with --theirs" \
-	"git merge-file --theirs test.txt orig.txt new3.txt && test_cmp test.txt expect.txt"
+	"git merge-file --theirs test.txt orig.txt new3.txt && test_cmp expect.txt test.txt"
 cp backup.txt test.txt
 
 cat > expect.txt << EOF
@@ -171,7 +171,7 @@ non timebo mala, quoniam tu mecum es:
 virga tua et baculus tuus ipsa me consolata sunt.
 EOF
 test_expect_success "merge conflicting with --union" \
-	"git merge-file --union test.txt orig.txt new3.txt && test_cmp test.txt expect.txt"
+	"git merge-file --union test.txt orig.txt new3.txt && test_cmp expect.txt test.txt"
 cp backup.txt test.txt
 
 test_expect_success "merge with conflicts, using -L" \
@@ -195,7 +195,7 @@ virga tua et baculus tuus ipsa me consolata sunt.
 EOF
 
 test_expect_success "expected conflict markers, with -L" \
-	"test_cmp test.txt expect.txt"
+	"test_cmp expect.txt test.txt"
 
 sed "s/ tu / TU /" < new1.txt > new5.txt
 test_expect_success "conflict in removed tail" \
diff --git a/t/t6027-merge-binary.sh b/t/t6027-merge-binary.sh
index 07735410b..4e6c7cb77 100755
--- a/t/t6027-merge-binary.sh
+++ b/t/t6027-merge-binary.sh
@@ -45,7 +45,7 @@ test_expect_success resolve '
 		false
 	else
 		git ls-files -s >current
-		test_cmp current expect
+		test_cmp expect current
 	fi
 '
 
@@ -60,7 +60,7 @@ test_expect_success recursive '
 		false
 	else
 		git ls-files -s >current
-		test_cmp current expect
+		test_cmp expect current
 	fi
 '
 
diff --git a/t/t6031-merge-filemode.sh b/t/t6031-merge-filemode.sh
index 7d06461f1..87741efad 100755
--- a/t/t6031-merge-filemode.sh
+++ b/t/t6031-merge-filemode.sh
@@ -61,7 +61,7 @@ do_both_modes () {
 		git checkout -f a2 &&
 		test_must_fail git merge -s $strategy b2 &&
 		git ls-files -u >actual &&
-		test_cmp actual expect &&
+		test_cmp expect actual &&
 		git ls-files -s file2 | grep ^100755
 	'
 
diff --git a/t/t6112-rev-list-filters-objects.sh b/t/t6112-rev-list-filters-objects.sh
index 0f6b569e1..ae4402226 100755
--- a/t/t6112-rev-list-filters-objects.sh
+++ b/t/t6112-rev-list-filters-objects.sh
@@ -29,7 +29,7 @@ test_expect_success 'verify blob:none omits all 5 blobs' '
 	sed "s/~//" |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify emitted+omitted == all' '
@@ -42,7 +42,7 @@ test_expect_success 'verify emitted+omitted == all' '
 	sed "s/~//" |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 
@@ -71,7 +71,7 @@ test_expect_success 'verify blob:limit=500 omits all blobs' '
 	sed "s/~//" |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify emitted+omitted == all' '
@@ -84,7 +84,7 @@ test_expect_success 'verify emitted+omitted == all' '
 	sed "s/~//" |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify blob:limit=1000' '
@@ -97,7 +97,7 @@ test_expect_success 'verify blob:limit=1000' '
 	sed "s/~//" |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify blob:limit=1001' '
@@ -110,7 +110,7 @@ test_expect_success 'verify blob:limit=1001' '
 	sed "s/~//" |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify blob:limit=1k' '
@@ -123,7 +123,7 @@ test_expect_success 'verify blob:limit=1k' '
 	sed "s/~//" |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify blob:limit=1m' '
@@ -165,7 +165,7 @@ test_expect_success 'verify sparse:path=pattern1 omits top-level files' '
 	sed "s/~//" |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify sparse:path=pattern2 omits both sparse2 files' '
@@ -178,7 +178,7 @@ test_expect_success 'verify sparse:path=pattern2 omits both sparse2 files' '
 	sed "s/~//" |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 # Test sparse:oid=<oid-ish> filter.
@@ -203,7 +203,7 @@ test_expect_success 'verify sparse:oid=OID omits top-level files' '
 	sed "s/~//" |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify sparse:oid=oid-ish omits top-level files' '
@@ -216,7 +216,7 @@ test_expect_success 'verify sparse:oid=oid-ish omits top-level files' '
 	sed "s/~//" |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 # Delete some loose objects and use rev-list, but WITHOUT any filtering.
@@ -237,7 +237,7 @@ test_expect_success 'rev-list W/ --missing=print' '
 	sed "s/?//" |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'rev-list W/O --missing fails' '
diff --git a/t/t7201-co.sh b/t/t7201-co.sh
index 324933acf..826987ca8 100755
--- a/t/t7201-co.sh
+++ b/t/t7201-co.sh
@@ -160,7 +160,7 @@ test_expect_success 'checkout -m with merge conflict' '
 	git diff master:one :3:uno |
 	sed -e "1,/^@@/d" -e "/^ /d" -e "s/^-/d/" -e "s/^+/a/" >current &&
 	fill d2 aT d7 aS >expect &&
-	test_cmp current expect &&
+	test_cmp expect current &&
 	git diff --cached two >current &&
 	test_must_be_empty current
 '
@@ -174,7 +174,7 @@ test_expect_success 'format of merge conflict from checkout -m' '
 
 	git ls-files >current &&
 	fill same two two two >expect &&
-	test_cmp current expect &&
+	test_cmp expect current &&
 
 	cat <<-EOF >expect &&
 	<<<<<<< simple
diff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh
index 10dc91620..e87164aa8 100755
--- a/t/t7406-submodule-update.sh
+++ b/t/t7406-submodule-update.sh
@@ -789,7 +789,7 @@ test_expect_success 'submodule add places git-dir in superprojects git-dir' '
 	 (cd .git/modules/deeper/submodule &&
 	  git log > ../../../../actual
 	 ) &&
-	 test_cmp actual expected
+	 test_cmp expected actual
 	)
 '
 
@@ -807,7 +807,7 @@ test_expect_success 'submodule update places git-dir in superprojects git-dir' '
 	 (cd .git/modules/deeper/submodule &&
 	  git log > ../../../../actual
 	 ) &&
-	 test_cmp actual expected
+	 test_cmp expected actual
 	)
 '
 
@@ -827,7 +827,7 @@ test_expect_success 'submodule add places git-dir in superprojects git-dir recur
 	 git add deeper/submodule &&
 	 git commit -m "update submodule" &&
 	 git push origin : &&
-	 test_cmp actual expected
+	 test_cmp expected actual
 	)
 '
 
@@ -874,7 +874,7 @@ test_expect_success 'submodule update places git-dir in superprojects git-dir re
 	 (cd .git/modules/submodule/modules/subsubmodule &&
 	  git log > ../../../../../actual
 	 ) &&
-	 test_cmp actual expected
+	 test_cmp expected actual
 	)
 '
 
diff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh
index 668bbee73..562bd215a 100755
--- a/t/t7800-difftool.sh
+++ b/t/t7800-difftool.sh
@@ -557,7 +557,7 @@ test_expect_success SYMLINKS 'difftool --dir-diff --symlink without unstaged cha
 	EOF
 	git difftool --dir-diff --symlink \
 		--extcmd "./.git/CHECK_SYMLINKS" branch HEAD &&
-	test_cmp actual expect
+	test_cmp expect actual
 '
 
 write_script modify-right-file <<\EOF
diff --git a/t/t9100-git-svn-basic.sh b/t/t9100-git-svn-basic.sh
index 9af607884..2c309a57d 100755
--- a/t/t9100-git-svn-basic.sh
+++ b/t/t9100-git-svn-basic.sh
@@ -221,7 +221,7 @@ tree d667270a1f7b109f5eb3aaea21ede14b56bfdd6e
 tree 8f51f74cf0163afc9ad68a4b1537288c4558b5a4
 EOF
 
-test_expect_success POSIXPERM,SYMLINKS "$name" "test_cmp a expected"
+test_expect_success POSIXPERM,SYMLINKS "$name" "test_cmp expected a"
 
 test_expect_success 'exit if remote refs are ambigious' '
         git config --add svn-remote.svn.fetch \
diff --git a/t/t9133-git-svn-nested-git-repo.sh b/t/t9133-git-svn-nested-git-repo.sh
index f3c30e63b..f89486086 100755
--- a/t/t9133-git-svn-nested-git-repo.sh
+++ b/t/t9133-git-svn-nested-git-repo.sh
@@ -45,7 +45,7 @@ test_expect_success 'update git svn-cloned repo' '
 		git svn rebase &&
 		echo a > expect &&
 		echo b >> expect &&
-		test_cmp a expect &&
+		test_cmp expect a &&
 		rm expect
 	)
 '
@@ -69,7 +69,7 @@ test_expect_success 'update git svn-cloned repo' '
 		git svn rebase &&
 		echo a > expect &&
 		echo b >> expect &&
-		test_cmp a expect &&
+		test_cmp expect a &&
 		rm expect
 	)
 '
@@ -93,7 +93,7 @@ test_expect_success 'update git svn-cloned repo again' '
 		echo a > expect &&
 		echo b >> expect &&
 		echo c >> expect &&
-		test_cmp a expect &&
+		test_cmp expect a &&
 		rm expect
 	)
 '
diff --git a/t/t9600-cvsimport.sh b/t/t9600-cvsimport.sh
index 5dfee07d9..251fdd66c 100755
--- a/t/t9600-cvsimport.sh
+++ b/t/t9600-cvsimport.sh
@@ -148,7 +148,7 @@ test_expect_success PERL 'import from a CVS working tree' '
 		git cvsimport -a -z0 &&
 		echo 1 >expect &&
 		git log -1 --pretty=format:%s%n >actual &&
-		test_cmp actual expect
+		test_cmp expect actual
 	)
 
 '
diff --git a/t/t9603-cvsimport-patchsets.sh b/t/t9603-cvsimport-patchsets.sh
index c4c3c4954..3e64b11ea 100755
--- a/t/t9603-cvsimport-patchsets.sh
+++ b/t/t9603-cvsimport-patchsets.sh
@@ -29,11 +29,11 @@ test_expect_failure PERL 'import with criss cross times on revisions' '
 Rev 3
 Rev 2
 Rev 1" > expect-master &&
-    test_cmp actual-master expect-master &&
+    test_cmp expect-master actual-master &&
 
     echo "Rev 5 Branch A Wed Mar 11 19:09:10 2009 +0000
 Rev 4 Branch A Wed Mar 11 19:03:52 2009 +0000" > expect-A &&
-    test_cmp actual-A expect-A
+    test_cmp expect-A actual-A
 '
 
 test_done
diff --git a/t/t9604-cvsimport-timestamps.sh b/t/t9604-cvsimport-timestamps.sh
index a4b3db24b..2ff4aa932 100755
--- a/t/t9604-cvsimport-timestamps.sh
+++ b/t/t9604-cvsimport-timestamps.sh
@@ -31,7 +31,7 @@ test_expect_success PERL 'check timestamps are UTC (TZ=CST6CDT)' '
 	Rev  2 2005-02-01 00:00:00 +0000
 	Rev  1 2005-01-01 00:00:00 +0000
 	EOF
-	test_cmp actual-1 expect-1
+	test_cmp expect-1 actual-1
 '
 
 test_expect_success PERL 'check timestamps with author-specific timezones' '
@@ -65,7 +65,7 @@ test_expect_success PERL 'check timestamps with author-specific timezones' '
 	Rev  2 2005-01-31 18:00:00 -0600 User Two
 	Rev  1 2005-01-01 00:00:00 +0000 User One
 	EOF
-	test_cmp actual-2 expect-2
+	test_cmp expect-2 actual-2
 '
 
 test_done
-- 
2.19.0.444.g18242da7ef-goog


^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [PATCH v2 4/6] tests: Add linter check for pipe placement style
  2018-09-17 22:24 ` [PATCH v2 0/6] Clean up tests for test_cmp arg ordering and pipe placement Matthew DeVore
@ 2018-09-17 22:24   ` Matthew DeVore
  2018-09-18  0:34     ` Eric Sunshine
  0 siblings, 1 reply; 66+ messages in thread
From: Matthew DeVore @ 2018-09-17 22:24 UTC (permalink / raw)
  To: git; +Cc: Matthew DeVore, peff, jonathantanmy, gitster, jrn

---
 t/Makefile | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/t/Makefile b/t/Makefile
index c83fd1886..4eceabbd5 100644
--- a/t/Makefile
+++ b/t/Makefile
@@ -78,7 +78,7 @@ check-chainlint:
 	done && exit $$err
 
 test-lint: test-lint-duplicates test-lint-executable test-lint-shell-syntax \
-	test-lint-filenames
+	test-lint-filenames test-lint-pipes
 
 test-lint-duplicates:
 	@dups=`echo $(T) | tr ' ' '\n' | sed 's/-.*//' | sort | uniq -d` && \
@@ -101,6 +101,16 @@ test-lint-filenames:
 		test -z "$$bad" || { \
 		echo >&2 "non-portable file name(s): $$bad"; exit 1; }
 
+test-lint-pipes:
+	@# Do not use \ to join lines when the next line starts with a
+	@# pipe. Instead, end the prior line with the pipe, and allow that to
+	@# join the lines implicitly.
+	@bad="$$(${PERL_PATH} -n0e 'm/(\n[^\n|]+\\\n[\t ]+\|[^\n]*)/ and \
+	      print qq{$$ARGV:$$1\n\n}' $(T))"; \
+		test -z "$$bad" || { \
+		printf >&2 "pipe at start of line in file(s):\n%s\n" "$$bad"; \
+		exit 1; }
+
 aggregate-results-and-cleanup: $(T)
 	$(MAKE) aggregate-results
 	$(MAKE) clean
-- 
2.19.0.444.g18242da7ef-goog


^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [PATCH v2 4/6] tests: add linter check for pipe placement style
       [not found] ` <cover.1537223021.git.matvore@google.com>
                     ` (2 preceding siblings ...)
  2018-09-17 22:24   ` [PATCH v2 3/6] t/*: fix ordering of expected/observed arguments Matthew DeVore
@ 2018-09-17 22:24   ` Matthew DeVore
  2018-09-17 22:24   ` [PATCH v2 5/6] tests: split up pipes Matthew DeVore
  2018-09-17 22:24   ` [PATCH v2 6/6] t9109-git-svn-props.sh: split up several pipes Matthew DeVore
  5 siblings, 0 replies; 66+ messages in thread
From: Matthew DeVore @ 2018-09-17 22:24 UTC (permalink / raw)
  To: git; +Cc: Matthew DeVore, peff, jonathantanmy, gitster, jrn

---
 t/Makefile | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/t/Makefile b/t/Makefile
index c83fd1886..4eceabbd5 100644
--- a/t/Makefile
+++ b/t/Makefile
@@ -78,7 +78,7 @@ check-chainlint:
 	done && exit $$err
 
 test-lint: test-lint-duplicates test-lint-executable test-lint-shell-syntax \
-	test-lint-filenames
+	test-lint-filenames test-lint-pipes
 
 test-lint-duplicates:
 	@dups=`echo $(T) | tr ' ' '\n' | sed 's/-.*//' | sort | uniq -d` && \
@@ -101,6 +101,16 @@ test-lint-filenames:
 		test -z "$$bad" || { \
 		echo >&2 "non-portable file name(s): $$bad"; exit 1; }
 
+test-lint-pipes:
+	@# Do not use \ to join lines when the next line starts with a
+	@# pipe. Instead, end the prior line with the pipe, and allow that to
+	@# join the lines implicitly.
+	@bad="$$(${PERL_PATH} -n0e 'm/(\n[^\n|]+\\\n[\t ]+\|[^\n]*)/ and \
+	      print qq{$$ARGV:$$1\n\n}' $(T))"; \
+		test -z "$$bad" || { \
+		printf >&2 "pipe at start of line in file(s):\n%s\n" "$$bad"; \
+		exit 1; }
+
 aggregate-results-and-cleanup: $(T)
 	$(MAKE) aggregate-results
 	$(MAKE) clean
-- 
2.19.0.444.g18242da7ef-goog


^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [PATCH v2 5/6] tests: split up pipes
       [not found] ` <cover.1537223021.git.matvore@google.com>
                     ` (3 preceding siblings ...)
  2018-09-17 22:24   ` [PATCH v2 4/6] tests: add linter check for pipe placement style Matthew DeVore
@ 2018-09-17 22:24   ` Matthew DeVore
  2018-09-18  1:30     ` Eric Sunshine
  2018-09-17 22:24   ` [PATCH v2 6/6] t9109-git-svn-props.sh: split up several pipes Matthew DeVore
  5 siblings, 1 reply; 66+ messages in thread
From: Matthew DeVore @ 2018-09-17 22:24 UTC (permalink / raw)
  To: git; +Cc: Matthew DeVore, peff, jonathantanmy, gitster, jrn

Some pipes in tests lose the exit code of git processes, which can mask
unexpected behavior. Split these pipes up so that git commands are at
the end of pipes rather than the beginning or middle.
---
 t/t5317-pack-objects-filter-objects.sh | 156 +++++++++++++------------
 t/t5500-fetch-pack.sh                  |   6 +-
 t/t5616-partial-clone.sh               |  14 ++-
 t/t6112-rev-list-filters-objects.sh    | 103 ++++++++--------
 t/t9101-git-svn-props.sh               |   3 +-
 5 files changed, 147 insertions(+), 135 deletions(-)

diff --git a/t/t5317-pack-objects-filter-objects.sh b/t/t5317-pack-objects-filter-objects.sh
index c093eb891..2e718f0bd 100755
--- a/t/t5317-pack-objects-filter-objects.sh
+++ b/t/t5317-pack-objects-filter-objects.sh
@@ -20,8 +20,9 @@ test_expect_success 'setup r1' '
 '
 
 test_expect_success 'verify blob count in normal packfile' '
-	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 |
-	awk -f print_2.awk |
+	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 \
+		>ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	git -C r1 pack-objects --rev --stdout >all.pack <<-EOF &&
@@ -29,8 +30,8 @@ test_expect_success 'verify blob count in normal packfile' '
 	EOF
 	git -C r1 index-pack ../all.pack &&
 
-	git -C r1 verify-pack -v ../all.pack |
-	grep blob |
+	git -C r1 verify-pack -v ../all.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -43,8 +44,8 @@ test_expect_success 'verify blob:none packfile has no blobs' '
 	EOF
 	git -C r1 index-pack ../filter.pack &&
 
-	git -C r1 verify-pack -v ../filter.pack |
-	grep blob |
+	git -C r1 verify-pack -v ../filter.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -53,13 +54,13 @@ test_expect_success 'verify blob:none packfile has no blobs' '
 '
 
 test_expect_success 'verify normal and blob:none packfiles have same commits/trees' '
-	git -C r1 verify-pack -v ../all.pack |
-	grep -E "commit|tree" |
+	git -C r1 verify-pack -v ../all.pack >verify_result &&
+	grep -E "commit|tree" verify_result |
 	awk -f print_1.awk |
 	sort >expected &&
 
-	git -C r1 verify-pack -v ../filter.pack |
-	grep -E "commit|tree" |
+	git -C r1 verify-pack -v ../filter.pack >verify_result &&
+	grep -E "commit|tree" verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -82,8 +83,8 @@ test_expect_success 'setup r2' '
 '
 
 test_expect_success 'verify blob count in normal packfile' '
-	git -C r2 ls-files -s large.1000 large.10000 |
-	awk -f print_2.awk |
+	git -C r2 ls-files -s large.1000 large.10000 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	git -C r2 pack-objects --rev --stdout >all.pack <<-EOF &&
@@ -91,8 +92,8 @@ test_expect_success 'verify blob count in normal packfile' '
 	EOF
 	git -C r2 index-pack ../all.pack &&
 
-	git -C r2 verify-pack -v ../all.pack |
-	grep blob |
+	git -C r2 verify-pack -v ../all.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -105,8 +106,8 @@ test_expect_success 'verify blob:limit=500 omits all blobs' '
 	EOF
 	git -C r2 index-pack ../filter.pack &&
 
-	git -C r2 verify-pack -v ../filter.pack |
-	grep blob |
+	git -C r2 verify-pack -v ../filter.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -120,8 +121,8 @@ test_expect_success 'verify blob:limit=1000' '
 	EOF
 	git -C r2 index-pack ../filter.pack &&
 
-	git -C r2 verify-pack -v ../filter.pack |
-	grep blob |
+	git -C r2 verify-pack -v ../filter.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -130,8 +131,8 @@ test_expect_success 'verify blob:limit=1000' '
 '
 
 test_expect_success 'verify blob:limit=1001' '
-	git -C r2 ls-files -s large.1000 |
-	awk -f print_2.awk |
+	git -C r2 ls-files -s large.1000 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	git -C r2 pack-objects --rev --stdout --filter=blob:limit=1001 >filter.pack <<-EOF &&
@@ -139,8 +140,8 @@ test_expect_success 'verify blob:limit=1001' '
 	EOF
 	git -C r2 index-pack ../filter.pack &&
 
-	git -C r2 verify-pack -v ../filter.pack |
-	grep blob |
+	git -C r2 verify-pack -v ../filter.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -148,8 +149,8 @@ test_expect_success 'verify blob:limit=1001' '
 '
 
 test_expect_success 'verify blob:limit=10001' '
-	git -C r2 ls-files -s large.1000 large.10000 |
-	awk -f print_2.awk |
+	git -C r2 ls-files -s large.1000 large.10000 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	git -C r2 pack-objects --rev --stdout --filter=blob:limit=10001 >filter.pack <<-EOF &&
@@ -157,8 +158,8 @@ test_expect_success 'verify blob:limit=10001' '
 	EOF
 	git -C r2 index-pack ../filter.pack &&
 
-	git -C r2 verify-pack -v ../filter.pack |
-	grep blob |
+	git -C r2 verify-pack -v ../filter.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -166,8 +167,8 @@ test_expect_success 'verify blob:limit=10001' '
 '
 
 test_expect_success 'verify blob:limit=1k' '
-	git -C r2 ls-files -s large.1000 |
-	awk -f print_2.awk |
+	git -C r2 ls-files -s large.1000 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	git -C r2 pack-objects --rev --stdout --filter=blob:limit=1k >filter.pack <<-EOF &&
@@ -175,8 +176,8 @@ test_expect_success 'verify blob:limit=1k' '
 	EOF
 	git -C r2 index-pack ../filter.pack &&
 
-	git -C r2 verify-pack -v ../filter.pack |
-	grep blob |
+	git -C r2 verify-pack -v ../filter.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -184,8 +185,8 @@ test_expect_success 'verify blob:limit=1k' '
 '
 
 test_expect_success 'verify explicitly specifying oversized blob in input' '
-	git -C r2 ls-files -s large.1000 large.10000 |
-	awk -f print_2.awk |
+	git -C r2 ls-files -s large.1000 large.10000 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	git -C r2 pack-objects --rev --stdout --filter=blob:limit=1k >filter.pack <<-EOF &&
@@ -194,8 +195,8 @@ test_expect_success 'verify explicitly specifying oversized blob in input' '
 	EOF
 	git -C r2 index-pack ../filter.pack &&
 
-	git -C r2 verify-pack -v ../filter.pack |
-	grep blob |
+	git -C r2 verify-pack -v ../filter.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -203,8 +204,8 @@ test_expect_success 'verify explicitly specifying oversized blob in input' '
 '
 
 test_expect_success 'verify blob:limit=1m' '
-	git -C r2 ls-files -s large.1000 large.10000 |
-	awk -f print_2.awk |
+	git -C r2 ls-files -s large.1000 large.10000 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	git -C r2 pack-objects --rev --stdout --filter=blob:limit=1m >filter.pack <<-EOF &&
@@ -212,8 +213,8 @@ test_expect_success 'verify blob:limit=1m' '
 	EOF
 	git -C r2 index-pack ../filter.pack &&
 
-	git -C r2 verify-pack -v ../filter.pack |
-	grep blob |
+	git -C r2 verify-pack -v ../filter.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -221,13 +222,13 @@ test_expect_success 'verify blob:limit=1m' '
 '
 
 test_expect_success 'verify normal and blob:limit packfiles have same commits/trees' '
-	git -C r2 verify-pack -v ../all.pack |
-	grep -E "commit|tree" |
+	git -C r2 verify-pack -v ../all.pack >verify_result &&
+	grep -E "commit|tree" verify_result |
 	awk -f print_1.awk |
 	sort >expected &&
 
-	git -C r2 verify-pack -v ../filter.pack |
-	grep -E "commit|tree" |
+	git -C r2 verify-pack -v ../filter.pack >verify_result &&
+	grep -E "commit|tree" verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -255,8 +256,9 @@ test_expect_success 'setup r3' '
 '
 
 test_expect_success 'verify blob count in normal packfile' '
-	git -C r3 ls-files -s sparse1 sparse2 dir1/sparse1 dir1/sparse2 |
-	awk -f print_2.awk |
+	git -C r3 ls-files -s sparse1 sparse2 dir1/sparse1 dir1/sparse2 \
+		>ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	git -C r3 pack-objects --rev --stdout >all.pack <<-EOF &&
@@ -264,8 +266,8 @@ test_expect_success 'verify blob count in normal packfile' '
 	EOF
 	git -C r3 index-pack ../all.pack &&
 
-	git -C r3 verify-pack -v ../all.pack |
-	grep blob |
+	git -C r3 verify-pack -v ../all.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -273,8 +275,8 @@ test_expect_success 'verify blob count in normal packfile' '
 '
 
 test_expect_success 'verify sparse:path=pattern1' '
-	git -C r3 ls-files -s dir1/sparse1 dir1/sparse2 |
-	awk -f print_2.awk |
+	git -C r3 ls-files -s dir1/sparse1 dir1/sparse2 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	git -C r3 pack-objects --rev --stdout --filter=sparse:path=../pattern1 >filter.pack <<-EOF &&
@@ -282,8 +284,8 @@ test_expect_success 'verify sparse:path=pattern1' '
 	EOF
 	git -C r3 index-pack ../filter.pack &&
 
-	git -C r3 verify-pack -v ../filter.pack |
-	grep blob |
+	git -C r3 verify-pack -v ../filter.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -291,13 +293,13 @@ test_expect_success 'verify sparse:path=pattern1' '
 '
 
 test_expect_success 'verify normal and sparse:path=pattern1 packfiles have same commits/trees' '
-	git -C r3 verify-pack -v ../all.pack |
-	grep -E "commit|tree" |
+	git -C r3 verify-pack -v ../all.pack >verify_result &&
+	grep -E "commit|tree" verify_result |
 	awk -f print_1.awk |
 	sort >expected &&
 
-	git -C r3 verify-pack -v ../filter.pack |
-	grep -E "commit|tree" |
+	git -C r3 verify-pack -v ../filter.pack >verify_result &&
+	grep -E "commit|tree" verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -305,8 +307,8 @@ test_expect_success 'verify normal and sparse:path=pattern1 packfiles have same
 '
 
 test_expect_success 'verify sparse:path=pattern2' '
-	git -C r3 ls-files -s sparse1 dir1/sparse1 |
-	awk -f print_2.awk |
+	git -C r3 ls-files -s sparse1 dir1/sparse1 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	git -C r3 pack-objects --rev --stdout --filter=sparse:path=../pattern2 >filter.pack <<-EOF &&
@@ -314,8 +316,8 @@ test_expect_success 'verify sparse:path=pattern2' '
 	EOF
 	git -C r3 index-pack ../filter.pack &&
 
-	git -C r3 verify-pack -v ../filter.pack |
-	grep blob |
+	git -C r3 verify-pack -v ../filter.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -323,13 +325,13 @@ test_expect_success 'verify sparse:path=pattern2' '
 '
 
 test_expect_success 'verify normal and sparse:path=pattern2 packfiles have same commits/trees' '
-	git -C r3 verify-pack -v ../all.pack |
-	grep -E "commit|tree" |
+	git -C r3 verify-pack -v ../all.pack >verify_result &&
+	grep -E "commit|tree" verify_result |
 	awk -f print_1.awk |
 	sort >expected &&
 
-	git -C r3 verify-pack -v ../filter.pack |
-	grep -E "commit|tree" |
+	git -C r3 verify-pack -v ../filter.pack >verify_result &&
+	grep -E "commit|tree" verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -356,8 +358,9 @@ test_expect_success 'setup r4' '
 '
 
 test_expect_success 'verify blob count in normal packfile' '
-	git -C r4 ls-files -s pattern sparse1 sparse2 dir1/sparse1 dir1/sparse2 |
-	awk -f print_2.awk |
+	git -C r4 ls-files -s pattern sparse1 sparse2 dir1/sparse1 dir1/sparse2 \
+		>ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	git -C r4 pack-objects --rev --stdout >all.pack <<-EOF &&
@@ -365,8 +368,8 @@ test_expect_success 'verify blob count in normal packfile' '
 	EOF
 	git -C r4 index-pack ../all.pack &&
 
-	git -C r4 verify-pack -v ../all.pack |
-	grep blob |
+	git -C r4 verify-pack -v ../all.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -374,8 +377,8 @@ test_expect_success 'verify blob count in normal packfile' '
 '
 
 test_expect_success 'verify sparse:oid=OID' '
-	git -C r4 ls-files -s dir1/sparse1 dir1/sparse2 |
-	awk -f print_2.awk |
+	git -C r4 ls-files -s dir1/sparse1 dir1/sparse2 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	oid=$(git -C r4 ls-files -s pattern | awk -f print_2.awk) &&
@@ -384,8 +387,8 @@ test_expect_success 'verify sparse:oid=OID' '
 	EOF
 	git -C r4 index-pack ../filter.pack &&
 
-	git -C r4 verify-pack -v ../filter.pack |
-	grep blob |
+	git -C r4 verify-pack -v ../filter.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -393,8 +396,8 @@ test_expect_success 'verify sparse:oid=OID' '
 '
 
 test_expect_success 'verify sparse:oid=oid-ish' '
-	git -C r4 ls-files -s dir1/sparse1 dir1/sparse2 |
-	awk -f print_2.awk |
+	git -C r4 ls-files -s dir1/sparse1 dir1/sparse2 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	git -C r4 pack-objects --rev --stdout --filter=sparse:oid=master:pattern >filter.pack <<-EOF &&
@@ -402,8 +405,8 @@ test_expect_success 'verify sparse:oid=oid-ish' '
 	EOF
 	git -C r4 index-pack ../filter.pack &&
 
-	git -C r4 verify-pack -v ../filter.pack |
-	grep blob |
+	git -C r4 verify-pack -v ../filter.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -414,8 +417,9 @@ test_expect_success 'verify sparse:oid=oid-ish' '
 # This models previously omitted objects that we did not receive.
 
 test_expect_success 'setup r1 - delete loose blobs' '
-	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 |
-	awk -f print_2.awk |
+	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 \
+		>ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	for id in `cat expected | sed "s|..|&/|"`
diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh
index 5ac6f286d..086f2c40f 100755
--- a/t/t5500-fetch-pack.sh
+++ b/t/t5500-fetch-pack.sh
@@ -51,8 +51,10 @@ pull_to_client () {
 			    git update-ref refs/heads/B "$BTIP";;
 			esac &&
 
-			git symbolic-ref HEAD refs/heads/$(echo $heads |
-			sed -e "s/^\(.\).*$/\1/") &&
+			git symbolic-ref HEAD refs/heads/$(
+				echo $heads |
+				sed -e "s/^\(.\).*$/\1/"
+			) &&
 
 			git fsck --full &&
 
diff --git a/t/t5616-partial-clone.sh b/t/t5616-partial-clone.sh
index e4d032c9d..fc7aeb1ab 100755
--- a/t/t5616-partial-clone.sh
+++ b/t/t5616-partial-clone.sh
@@ -35,8 +35,8 @@ test_expect_success 'setup bare clone for server' '
 test_expect_success 'do partial clone 1' '
 	git clone --no-checkout --filter=blob:none "file://$(pwd)/srv.bare" pc1 &&
 
-	git -C pc1 rev-list HEAD --quiet --objects --missing=print |
-	awk -f print_1.awk |
+	git -C pc1 rev-list HEAD --quiet --objects --missing=print >revs &&
+	awk -f print_1.awk revs |
 	sed "s/?//" |
 	sort >observed.oids &&
 
@@ -133,16 +133,18 @@ test_expect_success 'push new commits to server for file.3.txt' '
 test_expect_success 'manual prefetch of missing objects' '
 	git -C pc1 fetch --filter=blob:none origin &&
 
-	git -C pc1 rev-list master..origin/master --quiet --objects --missing=print |
-	awk -f print_1.awk |
+	git -C pc1 rev-list master..origin/master --quiet --objects --missing=print \
+		>revs &&
+	awk -f print_1.awk revs |
 	sed "s/?//" |
 	sort >observed.oids &&
 
 	test_line_count = 6 observed.oids &&
 	git -C pc1 fetch-pack --stdin "file://$(pwd)/srv.bare" <observed.oids &&
 
-	git -C pc1 rev-list master..origin/master --quiet --objects --missing=print |
-	awk -f print_1.awk |
+	git -C pc1 rev-list master..origin/master --quiet --objects --missing=print \
+		>revs &&
+	awk -f print_1.awk revs |
 	sed "s/?//" |
 	sort >observed.oids &&
 
diff --git a/t/t6112-rev-list-filters-objects.sh b/t/t6112-rev-list-filters-objects.sh
index ae4402226..b00cf6fa8 100755
--- a/t/t6112-rev-list-filters-objects.sh
+++ b/t/t6112-rev-list-filters-objects.sh
@@ -20,12 +20,13 @@ test_expect_success 'setup r1' '
 '
 
 test_expect_success 'verify blob:none omits all 5 blobs' '
-	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 |
-	awk -f print_2.awk |
+	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 \
+		>ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
-	git -C r1 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:none |
-	awk -f print_1.awk |
+	git -C r1 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:none >revs &&
+	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
 
@@ -33,12 +34,13 @@ test_expect_success 'verify blob:none omits all 5 blobs' '
 '
 
 test_expect_success 'verify emitted+omitted == all' '
-	git -C r1 rev-list HEAD --objects |
-	awk -f print_1.awk |
+	git -C r1 rev-list HEAD --objects >revs &&
+	awk -f print_1.awk revs |
 	sort >expected &&
 
-	git -C r1 rev-list HEAD --objects --filter-print-omitted --filter=blob:none |
-	awk -f print_1.awk |
+	git -C r1 rev-list HEAD --objects --filter-print-omitted --filter=blob:none \
+		>revs &&
+	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
 
@@ -62,12 +64,12 @@ test_expect_success 'setup r2' '
 '
 
 test_expect_success 'verify blob:limit=500 omits all blobs' '
-	git -C r2 ls-files -s large.1000 large.10000 |
-	awk -f print_2.awk |
+	git -C r2 ls-files -s large.1000 large.10000 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
-	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=500 |
-	awk -f print_1.awk |
+	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=500 >revs &&
+	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
 
@@ -75,12 +77,12 @@ test_expect_success 'verify blob:limit=500 omits all blobs' '
 '
 
 test_expect_success 'verify emitted+omitted == all' '
-	git -C r2 rev-list HEAD --objects |
-	awk -f print_1.awk |
+	git -C r2 rev-list HEAD --objects >revs &&
+	awk -f print_1.awk revs |
 	sort >expected &&
 
-	git -C r2 rev-list HEAD --objects --filter-print-omitted --filter=blob:limit=500 |
-	awk -f print_1.awk |
+	git -C r2 rev-list HEAD --objects --filter-print-omitted --filter=blob:limit=500 >revs &&
+	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
 
@@ -88,12 +90,12 @@ test_expect_success 'verify emitted+omitted == all' '
 '
 
 test_expect_success 'verify blob:limit=1000' '
-	git -C r2 ls-files -s large.1000 large.10000 |
-	awk -f print_2.awk |
+	git -C r2 ls-files -s large.1000 large.10000 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
-	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1000 |
-	awk -f print_1.awk |
+	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1000 >revs &&
+	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
 
@@ -101,12 +103,12 @@ test_expect_success 'verify blob:limit=1000' '
 '
 
 test_expect_success 'verify blob:limit=1001' '
-	git -C r2 ls-files -s large.10000 |
-	awk -f print_2.awk |
+	git -C r2 ls-files -s large.10000 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
-	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1001 |
-	awk -f print_1.awk |
+	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1001 >revs &&
+	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
 
@@ -114,12 +116,12 @@ test_expect_success 'verify blob:limit=1001' '
 '
 
 test_expect_success 'verify blob:limit=1k' '
-	git -C r2 ls-files -s large.10000 |
-	awk -f print_2.awk |
+	git -C r2 ls-files -s large.10000 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
-	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1k |
-	awk -f print_1.awk |
+	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1k >revs &&
+	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
 
@@ -127,8 +129,8 @@ test_expect_success 'verify blob:limit=1k' '
 '
 
 test_expect_success 'verify blob:limit=1m' '
-	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1m |
-	awk -f print_1.awk |
+	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1m >revs &&
+	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
 
@@ -156,12 +158,12 @@ test_expect_success 'setup r3' '
 '
 
 test_expect_success 'verify sparse:path=pattern1 omits top-level files' '
-	git -C r3 ls-files -s sparse1 sparse2 |
-	awk -f print_2.awk |
+	git -C r3 ls-files -s sparse1 sparse2 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
-	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:path=../pattern1 |
-	awk -f print_1.awk |
+	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:path=../pattern1 >revs &&
+	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
 
@@ -169,12 +171,12 @@ test_expect_success 'verify sparse:path=pattern1 omits top-level files' '
 '
 
 test_expect_success 'verify sparse:path=pattern2 omits both sparse2 files' '
-	git -C r3 ls-files -s sparse2 dir1/sparse2 |
-	awk -f print_2.awk |
+	git -C r3 ls-files -s sparse2 dir1/sparse2 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
-	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:path=../pattern2 |
-	awk -f print_1.awk |
+	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:path=../pattern2 >revs &&
+	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
 
@@ -192,14 +194,14 @@ test_expect_success 'setup r3 part 2' '
 '
 
 test_expect_success 'verify sparse:oid=OID omits top-level files' '
-	git -C r3 ls-files -s pattern sparse1 sparse2 |
-	awk -f print_2.awk |
+	git -C r3 ls-files -s pattern sparse1 sparse2 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	oid=$(git -C r3 ls-files -s pattern | awk -f print_2.awk) &&
 
-	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:oid=$oid |
-	awk -f print_1.awk |
+	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:oid=$oid >revs &&
+	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
 
@@ -207,12 +209,12 @@ test_expect_success 'verify sparse:oid=OID omits top-level files' '
 '
 
 test_expect_success 'verify sparse:oid=oid-ish omits top-level files' '
-	git -C r3 ls-files -s pattern sparse1 sparse2 |
-	awk -f print_2.awk |
+	git -C r3 ls-files -s pattern sparse1 sparse2 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
-	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:oid=master:pattern |
-	awk -f print_1.awk |
+	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:oid=master:pattern >revs &&
+	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
 
@@ -223,8 +225,9 @@ test_expect_success 'verify sparse:oid=oid-ish omits top-level files' '
 # This models previously omitted objects that we did not receive.
 
 test_expect_success 'rev-list W/ --missing=print' '
-	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 |
-	awk -f print_2.awk |
+	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 \
+		>ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	for id in `cat expected | sed "s|..|&/|"`
@@ -232,8 +235,8 @@ test_expect_success 'rev-list W/ --missing=print' '
 		rm r1/.git/objects/$id
 	done &&
 
-	git -C r1 rev-list --quiet HEAD --missing=print --objects |
-	awk -f print_1.awk |
+	git -C r1 rev-list --quiet HEAD --missing=print --objects >revs &&
+	awk -f print_1.awk revs |
 	sed "s/?//" |
 	sort >observed &&
 
diff --git a/t/t9101-git-svn-props.sh b/t/t9101-git-svn-props.sh
index 8a5c8dc1a..8cba331fc 100755
--- a/t/t9101-git-svn-props.sh
+++ b/t/t9101-git-svn-props.sh
@@ -174,7 +174,8 @@ test_expect_success 'test create-ignore' "
 	cmp ./deeply/.gitignore create-ignore.expect &&
 	cmp ./deeply/nested/.gitignore create-ignore.expect &&
 	cmp ./deeply/nested/directory/.gitignore create-ignore.expect &&
-	git ls-files -s | grep gitignore | cmp - create-ignore-index.expect
+	git ls-files -s >ls_files_result &&
+	grep gitignore ls_files_result | cmp - create-ignore-index.expect
 	"
 
 cat >prop.expect <<\EOF
-- 
2.19.0.444.g18242da7ef-goog


^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [PATCH v2 6/6] t9109-git-svn-props.sh: split up several pipes
       [not found] ` <cover.1537223021.git.matvore@google.com>
                     ` (4 preceding siblings ...)
  2018-09-17 22:24   ` [PATCH v2 5/6] tests: split up pipes Matthew DeVore
@ 2018-09-17 22:24   ` Matthew DeVore
  2018-09-18  1:56     ` Eric Sunshine
  5 siblings, 1 reply; 66+ messages in thread
From: Matthew DeVore @ 2018-09-17 22:24 UTC (permalink / raw)
  To: git; +Cc: Matthew DeVore, peff, jonathantanmy, gitster, jrn

A test uses several separate pipe sequences in a row which are awkward
to split up. Wrap the split-up pipe in a function so the awkwardness is
not repeated.

Signed-off-by: Matthew DeVore <matvore@google.com>
---
 t/t9101-git-svn-props.sh | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/t/t9101-git-svn-props.sh b/t/t9101-git-svn-props.sh
index 8cba331fc..952bd4814 100755
--- a/t/t9101-git-svn-props.sh
+++ b/t/t9101-git-svn-props.sh
@@ -190,16 +190,21 @@ EOF
 # This test can be improved: since all the svn:ignore contain the same
 # pattern, it can pass even though the propget did not execute on the
 # right directory.
+# Note we avoid using pipes in order to ensure that git exits with 0.
 test_expect_success 'test propget' "
-	git svn propget svn:ignore . | cmp - prop.expect &&
+	test_propget () {
+		git svn propget $1 $2 >observed
+		cmp - $3
+	} &&
+	test_propget svn:ignore . prop.expect &&
 	cd deeply &&
-	git svn propget svn:ignore . | cmp - ../prop.expect &&
-	git svn propget svn:entry:committed-rev nested/directory/.keep \
-	  | cmp - ../prop2.expect &&
-	git svn propget svn:ignore .. | cmp - ../prop.expect &&
-	git svn propget svn:ignore nested/ | cmp - ../prop.expect &&
-	git svn propget svn:ignore ./nested | cmp - ../prop.expect &&
-	git svn propget svn:ignore .././deeply/nested | cmp - ../prop.expect
+	test_propget svn:ignore . ../prop.expect &&
+	test_propget svn:entry:committed-rev nested/directory/.keep \
+		../prop2.expect &&
+	test_propget svn:ignore .. ../prop.expect &&
+	test_propget svn:ignore nested/ ../prop.expect &&
+	test_propget svn:ignore ./nested ../prop.expect &&
+	test_propget svn:ignore .././deeply/nested ../prop.expect
 	"
 
 cat >prop.expect <<\EOF
-- 
2.19.0.444.g18242da7ef-goog


^ permalink raw reply related	[flat|nested] 66+ messages in thread

* Re: [PATCH v2 1/6] CodingGuidelines: add shell piping guidelines
  2018-09-17 22:24   ` [PATCH v2 1/6] CodingGuidelines: add shell piping guidelines Matthew DeVore
@ 2018-09-18  0:16     ` Eric Sunshine
  2018-09-19  2:11       ` Matthew DeVore
  0 siblings, 1 reply; 66+ messages in thread
From: Eric Sunshine @ 2018-09-18  0:16 UTC (permalink / raw)
  To: matvore; +Cc: Git List, Jeff King, Jonathan Tan, Junio C Hamano,
	Jonathan Nieder

On Mon, Sep 17, 2018 at 6:24 PM Matthew DeVore <matvore@google.com> wrote:
> diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines
> @@ -163,6 +163,35 @@ For shell scripts specifically (not exhaustive):
> + - In a piped sequence which spans multiple lines, put each statement
> +   on a separate line and put pipes on the end of each line, rather
> +   than the start. This means you don't need to use \ to join lines,
> +   since | implies a join already. Also, do not indent subsequent
> +   lines; if you need a sequence to visually stand apart from the
> +   surrounding code, use a blank line before and/or after the piped
> +   sequence.
> +
> +       (incorrect)
> +       [...]
> +       (correct)
> +       echo '...' > expected

Existing tests seem to favor the name "expect" over "expected", so
perhaps use that instead.

    $ git grep '>expect\b' -- t | wc -l
    2674
    $ git grep '>expected\b' -- t | wc -l
    1406

> +       git ls-files -s file.1 file.2 file.3 file.4 file.5 |
> +       awk '{print $1}' |
> +       sort >observed

This is not a great example since it flatly contradicts the very next
bit of advice added by this patch about not placing a Git command
upstream in a pipe. Perhaps come up with an example which doesn't
suffer this shortcoming.

I've seen the advice earlier in the thread of not indenting the
sub-commands in a pipe, but I find that the result makes it far more
difficult to see which commands are part of the pipe sequence than
with them indented, so I'm not convinced that this advice should be in
the guidelines. (But that just my opinion.)

> + - In a pipe, any non-zero exit codes returned by processes besides
> +   the last will be ignored. If there is any possibility some
> +   non-final command in the pipe will raise an error, prefer writing
> +   the output of that command to a temporary file with '>' rather than
> +   pipe it.

It's not so much that we care about losing a non-zero exit code (which
might be perfectly acceptable depending upon the context) but that we
care about missing a Git command which outright crashes. So, it might
make sense to make this text more specific by saying that ("exit code
indicating a crash" and "Git command") rather than being generic in
saying only "exit code" and "command".

Also, what about expression like $(git foo) by which a crash of a Git
command can also be lost? Do we want to talk about that, as well?

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v2 4/6] tests: Add linter check for pipe placement style
  2018-09-17 22:24   ` [PATCH v2 4/6] tests: Add linter check for pipe placement style Matthew DeVore
@ 2018-09-18  0:34     ` Eric Sunshine
  2018-09-19 17:39       ` Matthew DeVore
  0 siblings, 1 reply; 66+ messages in thread
From: Eric Sunshine @ 2018-09-18  0:34 UTC (permalink / raw)
  To: matvore; +Cc: Git List, Jeff King, Jonathan Tan, Junio C Hamano,
	Jonathan Nieder

On Mon, Sep 17, 2018 at 6:25 PM Matthew DeVore <matvore@google.com> wrote:
> tests: Add linter check for pipe placement style

Until now, the various "lint" checks have been for genuine portability
problems (except perhaps 'test-lint-duplicates'). This new lint check
makes style violations worthy of failing "make test". Is the indeed
the direction we want to go? (Genuine question. I can formulate
arguments for either side.)

> ---
> diff --git a/t/Makefile b/t/Makefile
> @@ -101,6 +101,16 @@ test-lint-filenames:
> +test-lint-pipes:
> +       @# Do not use \ to join lines when the next line starts with a
> +       @# pipe. Instead, end the prior line with the pipe, and allow that to
> +       @# join the lines implicitly.
> +       @bad="$$(${PERL_PATH} -n0e 'm/(\n[^\n|]+\\\n[\t ]+\|[^\n]*)/ and \
> +             print qq{$$ARGV:$$1\n\n}' $(T))"; \
> +               test -z "$$bad" || { \
> +               printf >&2 "pipe at start of line in file(s):\n%s\n" "$$bad"; \
> +               exit 1; }

If we're going in the direction of linting style violations, then
maybe generalize this by calling it "test-lint-style" rather than
"test-lint-pipes", and perhaps move the body of the test to a new
script check-shell-style.pl (or something), much as portability
violations are housed in check-non-portable-shell.pl.

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v2 5/6] tests: split up pipes
  2018-09-17 22:24   ` [PATCH v2 5/6] tests: split up pipes Matthew DeVore
@ 2018-09-18  1:30     ` Eric Sunshine
  2018-09-19  2:33       ` Matthew DeVore
  0 siblings, 1 reply; 66+ messages in thread
From: Eric Sunshine @ 2018-09-18  1:30 UTC (permalink / raw)
  To: matvore; +Cc: Git List, Jeff King, Jonathan Tan, Junio C Hamano,
	Jonathan Nieder

On Mon, Sep 17, 2018 at 6:25 PM Matthew DeVore <matvore@google.com> wrote:
> tests: split up pipes

This title explains the mechanical changes the patch is making but not
the intent. Perhaps reword it to say something like:

    tests: avoid swallowing Git exit code upstream of a pipe

> Some pipes in tests lose the exit code of git processes, which can mask
> unexpected behavior. Split these pipes up so that git commands are at
> the end of pipes rather than the beginning or middle.

Can you say something about how you chose which tests to fix in this
patch? Is this fixing all such cases or only a subset? It looks like
it's only fixing "ls-files" and "verify-pack" invocations. If that's
the case, the commit message should explain that.

Also, missing sign-off.

> ---
> diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh
> @@ -51,8 +51,10 @@ pull_to_client () {
> -                       git symbolic-ref HEAD refs/heads/$(echo $heads |
> -                       sed -e "s/^\(.\).*$/\1/") &&
> +                       git symbolic-ref HEAD refs/heads/$(
> +                               echo $heads |
> +                               sed -e "s/^\(.\).*$/\1/"
> +                       ) &&

Why is this change included in the patch? There is no Git invocation
upstream of a pipe here. While the cleanup itself may be desirable, it
doesn't belong in this patch.

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v2 6/6] t9109-git-svn-props.sh: split up several pipes
  2018-09-17 22:24   ` [PATCH v2 6/6] t9109-git-svn-props.sh: split up several pipes Matthew DeVore
@ 2018-09-18  1:56     ` Eric Sunshine
  2018-09-19  2:56       ` Matthew DeVore
  0 siblings, 1 reply; 66+ messages in thread
From: Eric Sunshine @ 2018-09-18  1:56 UTC (permalink / raw)
  To: matvore; +Cc: Git List, Jeff King, Jonathan Tan, Junio C Hamano,
	Jonathan Nieder

On Mon, Sep 17, 2018 at 6:25 PM Matthew DeVore <matvore@google.com> wrote:
> t9109-git-svn-props.sh: split up several pipes

Similar to my comment about 5/6, this title talks about the mechanical
changes made by the patch but not the intent. Perhaps reword it like
this:

    t9109: avoid swallowing Git exit code upstream of a pipe

> A test uses several separate pipe sequences in a row which are awkward
> to split up. Wrap the split-up pipe in a function so the awkwardness is
> not repeated.
>
> Signed-off-by: Matthew DeVore <matvore@google.com>
> ---
> diff --git a/t/t9101-git-svn-props.sh b/t/t9101-git-svn-props.sh
> @@ -190,16 +190,21 @@ EOF
> +# Note we avoid using pipes in order to ensure that git exits with 0.

This new comment doesn't really add value for someone reading the
patch without knowing the history leading up to the point the comment
was added. It should probably be dropped. (The actual text of the
comment is rather confusing anyhow since avoiding pipes has nothing to
do with ensuring that git exits with 0, thus another reason why this
comment ought to be dropped.)

>  test_expect_success 'test propget' "
> -       git svn propget svn:ignore . | cmp - prop.expect &&
> +       test_propget () {
> +               git svn propget $1 $2 >observed

The &&-chain is broken here, which means you're losing the exit status
from the Git command anyhow (despite the point of the patch being to
avoid losing it).

Also, for consistency, how about calling this "actual" rather than "observed"?

> +               cmp - $3

This is just wrong. The "-" argument to 'cmp' says to read from
standard input, but there is nothing being passed to 'cmp' on standard
input anymore now that you're removed the pipe. I'm guessing that you
really meant to use "observed" here (and reverse the order of
arguments to be consistent with the expect-then-actual idiom).
Finally, since these (apparently) might be binary, you can use
test_cmp_bin() instead.

> +       } &&
> +       test_propget svn:ignore . prop.expect &&
>         cd deeply &&
> -       git svn propget svn:ignore . | cmp - ../prop.expect &&
> -       git svn propget svn:entry:committed-rev nested/directory/.keep \
> -         | cmp - ../prop2.expect &&
> -       git svn propget svn:ignore .. | cmp - ../prop.expect &&
> -       git svn propget svn:ignore nested/ | cmp - ../prop.expect &&
> -       git svn propget svn:ignore ./nested | cmp - ../prop.expect &&
> -       git svn propget svn:ignore .././deeply/nested | cmp - ../prop.expect
> +       test_propget svn:ignore . ../prop.expect &&
> +       test_propget svn:entry:committed-rev nested/directory/.keep \
> +               ../prop2.expect &&
> +       test_propget svn:ignore .. ../prop.expect &&
> +       test_propget svn:ignore nested/ ../prop.expect &&
> +       test_propget svn:ignore ./nested ../prop.expect &&
> +       test_propget svn:ignore .././deeply/nested ../prop.expect
>         "

After this patch, the test is even more broken than appears at first
glance since the test body is inside double-quotes. This means that
the $1, $2, $3 inside the test_propget() function are getting expanded
_before_ the function itself is ever defined, to whatever bogus values
$1, $2, $3 hold at that point. I can't see how this could ever have
worked (except only appearing to work by pure accident).

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v2 1/6] CodingGuidelines: add shell piping guidelines
  2018-09-18  0:16     ` Eric Sunshine
@ 2018-09-19  2:11       ` Matthew DeVore
  2018-09-19 12:36         ` Eric Sunshine
  2018-09-19 14:24         ` Junio C Hamano
  0 siblings, 2 replies; 66+ messages in thread
From: Matthew DeVore @ 2018-09-19  2:11 UTC (permalink / raw)
  To: sunshine; +Cc: git, Jeff King, Jonathan Tan, Junio C Hamano, Jonathan Nieder

On Mon, Sep 17, 2018 at 5:16 PM Eric Sunshine <sunshine@sunshineco.com> wrote:
>
> On Mon, Sep 17, 2018 at 6:24 PM Matthew DeVore <matvore@google.com> wrote:
> > diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines
> > @@ -163,6 +163,35 @@ For shell scripts specifically (not exhaustive):
> > + - In a piped sequence which spans multiple lines, put each statement
> > +   on a separate line and put pipes on the end of each line, rather
> > +   than the start. This means you don't need to use \ to join lines,
> > +   since | implies a join already. Also, do not indent subsequent
> > +   lines; if you need a sequence to visually stand apart from the
> > +   surrounding code, use a blank line before and/or after the piped
> > +   sequence.
> > +
> > +       (incorrect)
> > +       [...]
> > +       (correct)
> > +       echo '...' > expected
>
> Existing tests seem to favor the name "expect" over "expected", so
> perhaps use that instead.
>
>     $ git grep '>expect\b' -- t | wc -l
>     2674
>     $ git grep '>expected\b' -- t | wc -l
>     1406
Thank you for clarifying that out for me, but I'm not longer using
that example, so it's moot.

>
> > +       git ls-files -s file.1 file.2 file.3 file.4 file.5 |
> > +       awk '{print $1}' |
> > +       sort >observed
>
> This is not a great example since it flatly contradicts the very next
> bit of advice added by this patch about not placing a Git command
> upstream in a pipe. Perhaps come up with an example which doesn't
> suffer this shortcoming.
Done.

>
> I've seen the advice earlier in the thread of not indenting the
> sub-commands in a pipe, but I find that the result makes it far more
> difficult to see which commands are part of the pipe sequence than
> with them indented, so I'm not convinced that this advice should be in
> the guidelines. (But that just my opinion.)
I'm not totally sure either way, nor do I have a strong opinion. I
agree it's probably better to not codify this in the documentation
until there's a great reason to.

>
> > + - In a pipe, any non-zero exit codes returned by processes besides
> > +   the last will be ignored. If there is any possibility some
> > +   non-final command in the pipe will raise an error, prefer writing
> > +   the output of that command to a temporary file with '>' rather than
> > +   pipe it.
>
> It's not so much that we care about losing a non-zero exit code (which
> might be perfectly acceptable depending upon the context) but that we
> care about missing a Git command which outright crashes. So, it might
> make sense to make this text more specific by saying that ("exit code
> indicating a crash" and "Git command") rather than being generic in
> saying only "exit code" and "command".
Fixed.

>
> Also, what about expression like $(git foo) by which a crash of a Git
> command can also be lost? Do we want to talk about that, as well?
Yes, it's probably better to add a point about that. Here is the new
documentation after applying your suggestions:

 - If a piped sequence which spans multiple lines, put each statement
   on a separate line and put pipes on the end of each line, rather
   than the start. This means you don't need to use \ to join lines,
   since | implies a join already.

        (incorrect)
        grep blob verify_pack_result \
        | awk -f print_1.awk \
        | sort >actual &&
        ...

        (correct)
        grep blob verify_pack_result |
        awk -f print_1.awk |
        sort >actual &&
        ...

 - In a pipe, any exit codes returned by processes besides the last
   are ignored. This means that if git crashes at the beginning or
   middle of a pipe, it may go undetected. Prefer writing the output
   of that command to a temporary file with '>' rather than pipe it.

 - The $(git ...) construct also discards git's exit code, so if the
   goal is to test that particular command, redirect its output to a
   temporary file rather than wrap it with $( ).

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v2 5/6] tests: split up pipes
  2018-09-18  1:30     ` Eric Sunshine
@ 2018-09-19  2:33       ` Matthew DeVore
  0 siblings, 0 replies; 66+ messages in thread
From: Matthew DeVore @ 2018-09-19  2:33 UTC (permalink / raw)
  To: sunshine; +Cc: git, Jeff King, Jonathan Tan, Junio C Hamano, Jonathan Nieder

On Mon, Sep 17, 2018 at 6:30 PM Eric Sunshine <sunshine@sunshineco.com> wrote:
>
> On Mon, Sep 17, 2018 at 6:25 PM Matthew DeVore <matvore@google.com> wrote:
> > tests: split up pipes
>
> This title explains the mechanical changes the patch is making but not
> the intent. Perhaps reword it to say something like:
>
>     tests: avoid swallowing Git exit code upstream of a pipe
>
> > Some pipes in tests lose the exit code of git processes, which can mask
> > unexpected behavior. Split these pipes up so that git commands are at
> > the end of pipes rather than the beginning or middle.
>
> Can you say something about how you chose which tests to fix in this
> patch? Is this fixing all such cases or only a subset? It looks like
> it's only fixing "ls-files" and "verify-pack" invocations. If that's
> the case, the commit message should explain that.
>
> Also, missing sign-off.
Fixed - here is the new commit message (I changed the wording of your
header to fit within 50 chars):

    tests: don't swallow Git errors upstream of pipes

    Some pipes in tests lose the exit code of git processes, which can mask
    unexpected behavior like crashes. Split these pipes up so that git
    commands are only at the end of pipes rather than the beginning or
    middle.

    The violations fixed in this patch were found in the process of fixing
    pipe placement in a prior patch.

    Signed-off-by: Matthew DeVore <matvore@google.com>

>
> > ---
> > diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh
> > @@ -51,8 +51,10 @@ pull_to_client () {
> > -                       git symbolic-ref HEAD refs/heads/$(echo $heads |
> > -                       sed -e "s/^\(.\).*$/\1/") &&
> > +                       git symbolic-ref HEAD refs/heads/$(
> > +                               echo $heads |
> > +                               sed -e "s/^\(.\).*$/\1/"
> > +                       ) &&
>
> Why is this change included in the patch? There is no Git invocation
> upstream of a pipe here. While the cleanup itself may be desirable, it
> doesn't belong in this patch.
This actually should have been part of the "tests: standardize pipe
placement" patch, but I did "git commit --fixup=SHA" with the wrong
SHA. Fixed.

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v2 6/6] t9109-git-svn-props.sh: split up several pipes
  2018-09-18  1:56     ` Eric Sunshine
@ 2018-09-19  2:56       ` Matthew DeVore
  2018-09-19 12:50         ` Eric Sunshine
  0 siblings, 1 reply; 66+ messages in thread
From: Matthew DeVore @ 2018-09-19  2:56 UTC (permalink / raw)
  To: sunshine; +Cc: git, Jeff King, Jonathan Tan, Junio C Hamano, Jonathan Nieder

On Mon, Sep 17, 2018 at 6:57 PM Eric Sunshine <sunshine@sunshineco.com> wrote:
>
> On Mon, Sep 17, 2018 at 6:25 PM Matthew DeVore <matvore@google.com> wrote:
> > t9109-git-svn-props.sh: split up several pipes
>
> Similar to my comment about 5/6, this title talks about the mechanical
> changes made by the patch but not the intent. Perhaps reword it like
> this:
>
>     t9109: avoid swallowing Git exit code upstream of a pipe
>
Here is my new commit description:

    t9109: don't swallow Git errors upstream of pipe

    'git ... | foo' will mask any errors or crashes in git, so split up such
    pipes.

    One testcase uses several separate pipe sequences in a row which are
    awkward to split up. Wrap the split-up pipe in a function so the
    awkwardness is not repeated.

    Signed-off-by: Matthew DeVore <matvore@google.com>

> > diff --git a/t/t9101-git-svn-props.sh b/t/t9101-git-svn-props.sh
> > @@ -190,16 +190,21 @@ EOF
> > +# Note we avoid using pipes in order to ensure that git exits with 0.
>
> This new comment doesn't really add value for someone reading the
> patch without knowing the history leading up to the point the comment
> was added. It should probably be dropped. (The actual text of the
> comment is rather confusing anyhow since avoiding pipes has nothing to
> do with ensuring that git exits with 0, thus another reason why this
> comment ought to be dropped.)
Yes, this comment was worded quite poorly. I've removed it since I
agree it doesn't add a lot of value.

>
> >  test_expect_success 'test propget' "
> > -       git svn propget svn:ignore . | cmp - prop.expect &&
> > +       test_propget () {
> > +               git svn propget $1 $2 >observed
>
> The &&-chain is broken here, which means you're losing the exit status
> from the Git command anyhow (despite the point of the patch being to
> avoid losing it).
Fixed.

>
> Also, for consistency, how about calling this "actual" rather than "observed"?
Done.

>
> > +               cmp - $3
>
> This is just wrong. The "-" argument to 'cmp' says to read from
> standard input, but there is nothing being passed to 'cmp' on standard
> input anymore now that you're removed the pipe. I'm guessing that you
> really meant to use "observed" here (and reverse the order of
> arguments to be consistent with the expect-then-actual idiom).
> Finally, since these (apparently) might be binary, you can use
> test_cmp_bin() instead.
Fixed, except for the test_cmp_bin part. My understanding is that git
svn propget is supposed to be printing human-readable strings. My
understanding is based soley on this page:
http://svnbook.red-bean.com/en/1.6/svn.ref.svn.c.propget.html

>
> > +       } &&
> > +       test_propget svn:ignore . prop.expect &&
> >         cd deeply &&
> > -       git svn propget svn:ignore . | cmp - ../prop.expect &&
> > -       git svn propget svn:entry:committed-rev nested/directory/.keep \
> > -         | cmp - ../prop2.expect &&
> > -       git svn propget svn:ignore .. | cmp - ../prop.expect &&
> > -       git svn propget svn:ignore nested/ | cmp - ../prop.expect &&
> > -       git svn propget svn:ignore ./nested | cmp - ../prop.expect &&
> > -       git svn propget svn:ignore .././deeply/nested | cmp - ../prop.expect
> > +       test_propget svn:ignore . ../prop.expect &&
> > +       test_propget svn:entry:committed-rev nested/directory/.keep \
> > +               ../prop2.expect &&
> > +       test_propget svn:ignore .. ../prop.expect &&
> > +       test_propget svn:ignore nested/ ../prop.expect &&
> > +       test_propget svn:ignore ./nested ../prop.expect &&
> > +       test_propget svn:ignore .././deeply/nested ../prop.expect
> >         "
>
> After this patch, the test is even more broken than appears at first
> glance since the test body is inside double-quotes. This means that
> the $1, $2, $3 inside the test_propget() function are getting expanded
> _before_ the function itself is ever defined, to whatever bogus values
> $1, $2, $3 hold at that point. I can't see how this could ever have
> worked (except only appearing to work by pure accident).
Fixed, and here is the new test:

test_expect_success 'test propget' "
        test_propget () {
                git svn propget \$1 \$2 >actual &&
                cmp \$3 actual
        } &&
        test_propget svn:ignore . prop.expect &&
        cd deeply &&
        test_propget svn:ignore . ../prop.expect &&
        test_propget svn:entry:committed-rev nested/directory/.keep \
                ../prop2.expect &&
        test_propget svn:ignore .. ../prop.expect &&
        test_propget svn:ignore nested/ ../prop.expect &&
        test_propget svn:ignore ./nested ../prop.expect &&
        test_propget svn:ignore .././deeply/nested ../prop.expect
        "

I confirmed that git's exit code is being checked by putting "!" in
front of git and making sure the test failed. I made sure that
"actual" was actually being compared and the exit code of "cmp" was
checked by adding "echo foo >> actual &&" before cmp, and again making
sure the test failed. This test should be well-formed now.

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v2 1/6] CodingGuidelines: add shell piping guidelines
  2018-09-19  2:11       ` Matthew DeVore
@ 2018-09-19 12:36         ` Eric Sunshine
  2018-09-19 14:24         ` Junio C Hamano
  1 sibling, 0 replies; 66+ messages in thread
From: Eric Sunshine @ 2018-09-19 12:36 UTC (permalink / raw)
  To: Matthew DeVore
  Cc: Git List, Jeff King, Jonathan Tan, Junio C Hamano,
	Jonathan Nieder

On Tue, Sep 18, 2018 at 10:11 PM Matthew DeVore <matvore@google.com> wrote:
> Yes, it's probably better to add a point about that. Here is the new
> documentation after applying your suggestions:
>
>  - If a piped sequence which spans multiple lines, put each statement

s/which//

>    on a separate line and put pipes on the end of each line, rather
>    than the start. This means you don't need to use \ to join lines,
>    since | implies a join already.
>         [...]
>  - In a pipe, any exit codes returned by processes besides the last
>    are ignored. This means that if git crashes at the beginning or
>    middle of a pipe, it may go undetected. Prefer writing the output
>    of that command to a temporary file with '>' rather than pipe it.
>
>  - The $(git ...) construct also discards git's exit code, so if the
>    goal is to test that particular command, redirect its output to a
>    temporary file rather than wrap it with $( ).

This all sounds better.

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v2 6/6] t9109-git-svn-props.sh: split up several pipes
  2018-09-19  2:56       ` Matthew DeVore
@ 2018-09-19 12:50         ` Eric Sunshine
  2018-09-19 18:43           ` Matthew DeVore
  0 siblings, 1 reply; 66+ messages in thread
From: Eric Sunshine @ 2018-09-19 12:50 UTC (permalink / raw)
  To: Matthew DeVore
  Cc: Git List, Jeff King, Jonathan Tan, Junio C Hamano,
	Jonathan Nieder

On Tue, Sep 18, 2018 at 10:56 PM Matthew DeVore <matvore@google.com> wrote:
> On Mon, Sep 17, 2018 at 6:57 PM Eric Sunshine <sunshine@sunshineco.com> wrote:
> > On Mon, Sep 17, 2018 at 6:25 PM Matthew DeVore <matvore@google.com> wrote:
> > > +               cmp - $3
> >
> > This is just wrong. The "-" argument to 'cmp' says to read from
> > standard input, but there is nothing being passed to 'cmp' on standard
> > input anymore now that you're removed the pipe. I'm guessing that you
> > really meant to use "observed" here (and reverse the order of
> > arguments to be consistent with the expect-then-actual idiom).
> > Finally, since these (apparently) might be binary, you can use
> > test_cmp_bin() instead.
> Fixed, except for the test_cmp_bin part. My understanding is that git
> svn propget is supposed to be printing human-readable strings.

If so, then please use test_cmp() rather than raw 'cmp' since
test_cmp() will show the actual difference between the expected and
actual files, which can be helpful when diagnosing a failing test.

> > After this patch, the test is even more broken than appears at first
> > glance since the test body is inside double-quotes. This means that
> > the $1, $2, $3 inside the test_propget() function are getting expanded
> > _before_ the function itself is ever defined, to whatever bogus values
> > $1, $2, $3 hold at that point. I can't see how this could ever have
> > worked (except only appearing to work by pure accident).
> Fixed, and here is the new test:
>
> test_expect_success 'test propget' "
>         test_propget () {
>                 git svn propget \$1 \$2 >actual &&
>                 cmp \$3 actual
>         } &&

Rather than escaping "$" with backslash, a cleaner fix would be to
change the double quotes around the test body to single quotes. Those
double quotes weren't needed anyhow since there are no variable
interpolations in the body. Single quotes would make that obvious at a
glance in addition to avoiding unexpected behavior in the future (like
$1, $2, etc. being interpolated at the wrong time). Single quotes
would also make the test more idiomatic and consistent with the bulk
of other tests in the suite. If you do go the route of swapping
quotes, please be sure to mention the change in the commit message.

Thanks.

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v2 1/6] CodingGuidelines: add shell piping guidelines
  2018-09-19  2:11       ` Matthew DeVore
  2018-09-19 12:36         ` Eric Sunshine
@ 2018-09-19 14:24         ` Junio C Hamano
  2018-09-19 20:06           ` Matthew DeVore
  1 sibling, 1 reply; 66+ messages in thread
From: Junio C Hamano @ 2018-09-19 14:24 UTC (permalink / raw)
  To: Matthew DeVore; +Cc: sunshine, git, Jeff King, Jonathan Tan, Jonathan Nieder

Matthew DeVore <matvore@google.com> writes:

> Yes, it's probably better to add a point about that. Here is the new
> documentation after applying your suggestions:
>
>  - If a piped sequence which spans multiple lines, put each statement
>    on a separate line and put pipes on the end of each line, rather
>    than the start. This means you don't need to use \ to join lines,
>    since | implies a join already.
>
>         (incorrect)
>         grep blob verify_pack_result \
>         | awk -f print_1.awk \
>         | sort >actual &&
>         ...
>
>         (correct)
>         grep blob verify_pack_result |
>         awk -f print_1.awk |
>         sort >actual &&
>         ...

The formatting advice to place '|' at the end applies equally to
'&&' and '||' because these three syntactic elements share exactly
the same trait: the shell knows you haven't finished speaking when
it sees them at the end of the line and keeps listening, and humans
would know that too, so there is no need for explicitly continuing
the line with backslash.

Organizationally speaking, I wonder if the above about formatting
would better appear separate from the latter two points that are
about semantics.

>  - In a pipe, any exit codes returned by processes besides the last
>    are ignored. This means that if git crashes at the beginning or
>    middle of a pipe, it may go undetected. Prefer writing the output
>    of that command to a temporary file with '>' rather than pipe it.
>
>  - The $(git ...) construct also discards git's exit code, so if the
>    goal is to test that particular command, redirect its output to a
>    temporary file rather than wrap it with $( ).

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v2 4/6] tests: Add linter check for pipe placement style
  2018-09-18  0:34     ` Eric Sunshine
@ 2018-09-19 17:39       ` Matthew DeVore
  0 siblings, 0 replies; 66+ messages in thread
From: Matthew DeVore @ 2018-09-19 17:39 UTC (permalink / raw)
  To: sunshine; +Cc: git, Jeff King, Jonathan Tan, Junio C Hamano, Jonathan Nieder

On Mon, Sep 17, 2018 at 5:34 PM Eric Sunshine <sunshine@sunshineco.com> wrote:
>
> On Mon, Sep 17, 2018 at 6:25 PM Matthew DeVore <matvore@google.com> wrote:
> > tests: Add linter check for pipe placement style
>
> Until now, the various "lint" checks have been for genuine portability
> problems (except perhaps 'test-lint-duplicates'). This new lint check
> makes style violations worthy of failing "make test". Is the indeed
> the direction we want to go? (Genuine question. I can formulate
> arguments for either side.)
>
> > ---
> > diff --git a/t/Makefile b/t/Makefile
> > @@ -101,6 +101,16 @@ test-lint-filenames:
> > +test-lint-pipes:
> > +       @# Do not use \ to join lines when the next line starts with a
> > +       @# pipe. Instead, end the prior line with the pipe, and allow that to
> > +       @# join the lines implicitly.
> > +       @bad="$$(${PERL_PATH} -n0e 'm/(\n[^\n|]+\\\n[\t ]+\|[^\n]*)/ and \
> > +             print qq{$$ARGV:$$1\n\n}' $(T))"; \
> > +               test -z "$$bad" || { \
> > +               printf >&2 "pipe at start of line in file(s):\n%s\n" "$$bad"; \
> > +               exit 1; }
>
> If we're going in the direction of linting style violations, then
> maybe generalize this by calling it "test-lint-style" rather than
> "test-lint-pipes", and perhaps move the body of the test to a new
> script check-shell-style.pl (or something), much as portability
> violations are housed in check-non-portable-shell.pl.

I agree with moving this code to a separate file. I also notice that
there is logic in a file called t/chainlint.sed which normalizes
scripts for the purpose of lint checks (e.g. it removes heredocs) and
I ought to be re-using this logic in order to make the new lint check
robust.

I think I'd like to shelve this particular commit and come back to it
once I have the time and I'm more familiar with the code base. It is
not critical to this patchset.

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v2 6/6] t9109-git-svn-props.sh: split up several pipes
  2018-09-19 12:50         ` Eric Sunshine
@ 2018-09-19 18:43           ` Matthew DeVore
  0 siblings, 0 replies; 66+ messages in thread
From: Matthew DeVore @ 2018-09-19 18:43 UTC (permalink / raw)
  To: sunshine; +Cc: git, Jeff King, Jonathan Tan, Junio C Hamano, Jonathan Nieder

On Wed, Sep 19, 2018 at 5:50 AM Eric Sunshine <sunshine@sunshineco.com> wrote:
>
> If so, then please use test_cmp() rather than raw 'cmp' since
> test_cmp() will show the actual difference between the expected and
> actual files, which can be helpful when diagnosing a failing test.
>
All the other testcases in this file use "cmp" and I would prefer to
maintain the consistency in this file. Note that the non-stylistic
fixes (breaking up pipes) in this test were originally not the goal of
this patchset, so changing this entire file to use test_cmp (or even
just a single testcase) seems like it's just getting even farther away
from the original goal of making pipe placement consistent in the code
base.

> Rather than escaping "$" with backslash, a cleaner fix would be to
> change the double quotes around the test body to single quotes. Those
> double quotes weren't needed anyhow since there are no variable
> interpolations in the body. Single quotes would make that obvious at a
> glance in addition to avoiding unexpected behavior in the future (like
> $1, $2, etc. being interpolated at the wrong time). Single quotes
> would also make the test more idiomatic and consistent with the bulk
> of other tests in the suite. If you do go the route of swapping
> quotes, please be sure to mention the change in the commit message.
Done. I thought of that earlier and thought that I should use double
quotes for consistency with the surrounding code, but then I saw that
there were testcases farther away in the same file that used single
quotes.

Here is the new commit message:

t9109: don't swallow Git errors upstream of pipes

'git ... | foo' will mask any errors or crashes in git, so split up such
pipes in this file.

One testcase uses several separate pipe sequences in a row which are
awkward to split up. Wrap the split-up pipe in a function so the
awkwardness is not repeated. Also change that testcase's surrounding
quotes from double to single to avoid premature string interpolation.

Signed-off-by: Matthew DeVore <matvore@google.com>

>
> Thanks.
Thank you!

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v2 1/6] CodingGuidelines: add shell piping guidelines
  2018-09-19 14:24         ` Junio C Hamano
@ 2018-09-19 20:06           ` Matthew DeVore
  0 siblings, 0 replies; 66+ messages in thread
From: Matthew DeVore @ 2018-09-19 20:06 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: sunshine, git, Jeff King, Jonathan Tan, Jonathan Nieder

On Wed, Sep 19, 2018 at 5:36 AM Eric Sunshine <sunshine@sunshineco.com> wrote:
>
> On Tue, Sep 18, 2018 at 10:11 PM Matthew DeVore <matvore@google.com> wrote:
> > Yes, it's probably better to add a point about that. Here is the new
> > documentation after applying your suggestions:
> >
> >  - If a piped sequence which spans multiple lines, put each statement
>
> s/which//
Done.

On Wed, Sep 19, 2018 at 7:24 AM Junio C Hamano <gitster@pobox.com> wrote:
> The formatting advice to place '|' at the end applies equally to
> '&&' and '||' because these three syntactic elements share exactly
> the same trait: the shell knows you haven't finished speaking when
> it sees them at the end of the line and keeps listening, and humans
> would know that too, so there is no need for explicitly continuing
> the line with backslash.
>
I've reworded the text to indicate the advice applies to && and || as well.

> Organizationally speaking, I wonder if the above about formatting
> would better appear separate from the latter two points that are
> about semantics.
>
I moved the formatting point to right under the point about formatting
if statements, which does seem like a more natural progression.

Here is the new patch to summarize the changes (warning: tabs are mangled):

--------------------------------------------------------------------------------

    CodingGuidelines: add shell piping guidelines

    Add two guidelines:

     - pipe characters should appear at the end of lines, and not cause
       indentation
     - pipes should be avoided when they swallow exit codes that can
       potentially fail

diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines
index 48aa4edfb..6d265327c 100644
--- a/Documentation/CodingGuidelines
+++ b/Documentation/CodingGuidelines
@@ -118,6 +118,24 @@ For shell scripts specifically (not exhaustive):
                 do this
         fi

+ - If a command sequence joined with && or || or | spans multiple
+   lines, put each command on a separate line and put && and || and |
+   operators at the end of each line, rather than the start. This
+   means you don't need to use \ to join lines, since the above
+   operators imply the sequence isn't finished.
+
+        (incorrect)
+        grep blob verify_pack_result \
+        | awk -f print_1.awk \
+        | sort >actual &&
+        ...
+
+        (correct)
+        grep blob verify_pack_result |
+        awk -f print_1.awk |
+        sort >actual &&
+        ...
+
  - We prefer "test" over "[ ... ]".

  - We do not write the noiseword "function" in front of shell
@@ -163,6 +181,15 @@ For shell scripts specifically (not exhaustive):

    does not have such a problem.

+ - In a piped chain such as "grep blob objects | sort", the exit codes
+   returned by processes besides the last are ignored. This means that
+   if git crashes at the beginning or middle of a chain, it may go
+   undetected. Prefer writing the output of that command to a
+   temporary file with '>' rather than pipe it.
+
+ - The $(git ...) construct also discards git's exit code, so if the
+   goal is to test that particular command, redirect its output to a
+   temporary file rather than wrap it with $( ).

 For C programs:

^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [PATCH v3 0/5] Clean up tests for test_cmp arg ordering and pipe placement
  2018-09-15  0:02 [PATCH v1 0/2] Cleanup tests for test_cmp argument ordering and "|" placement Matthew DeVore
                   ` (4 preceding siblings ...)
       [not found] ` <cover.1537223021.git.matvore@google.com>
@ 2018-09-21  1:43 ` Matthew DeVore
  2018-09-21  1:43   ` [PATCH v3 1/5] CodingGuidelines: add shell piping guidelines Matthew DeVore
                     ` (4 more replies)
  2018-10-03 16:25 ` [PATCH v4 0/7] Clean up tests for test_cmp arg ordering and pipe placement Matthew DeVore
  2018-10-05 21:54 ` [PATCH v5 0/7] subject: Clean up tests for test_cmp arg ordering and pipe placement Matthew DeVore
  7 siblings, 5 replies; 66+ messages in thread
From: Matthew DeVore @ 2018-09-21  1:43 UTC (permalink / raw)
  To: git; +Cc: Matthew DeVore, peff, jonathantanmy, gitster, jrn, sunshine

Two of the commits have changed drastically (see second and third points below)
so I'm sending this again.

Summary of changes since last time:
 - Remove the hacky linter check which makes sure pipes are placed at the end of
   the line in tests - I may add this back in a more polished form when I have
   time.
 - Unbroke t9101 git-svn test which I had broken pretty badly in v2 of the
   patchset.
 - Cleaned up and generalized the wording of the added points in
   CodingGuidelines.

Thank you,

Matthew DeVore (5):
  CodingGuidelines: add shell piping guidelines
  tests: standardize pipe placement
  t/*: fix ordering of expected/observed arguments
  tests: don't swallow Git errors upstream of pipes
  t9109: don't swallow Git errors upstream of pipes

 Documentation/CodingGuidelines         |  27 ++
 t/lib-gpg.sh                           |   9 +-
 t/t0000-basic.sh                       |   2 +-
 t/t0021-conversion.sh                  |   4 +-
 t/t1006-cat-file.sh                    |   8 +-
 t/t1300-config.sh                      |   9 +-
 t/t1303-wacky-config.sh                |   4 +-
 t/t2101-update-index-reupdate.sh       |   2 +-
 t/t3200-branch.sh                      |   2 +-
 t/t3320-notes-merge-worktrees.sh       |   4 +-
 t/t3400-rebase.sh                      |   8 +-
 t/t3417-rebase-whitespace-fix.sh       |   6 +-
 t/t3702-add-edit.sh                    |   4 +-
 t/t3903-stash.sh                       |   8 +-
 t/t3905-stash-include-untracked.sh     |   2 +-
 t/t4025-hunk-header.sh                 |   2 +-
 t/t4117-apply-reject.sh                |   6 +-
 t/t4124-apply-ws-rule.sh               |  30 +--
 t/t4138-apply-ws-expansion.sh          |   2 +-
 t/t5317-pack-objects-filter-objects.sh | 360 ++++++++++++++-----------
 t/t5318-commit-graph.sh                |   2 +-
 t/t5500-fetch-pack.sh                  |   7 +-
 t/t5616-partial-clone.sh               |  30 ++-
 t/t5701-git-serve.sh                   |  14 +-
 t/t5702-protocol-v2.sh                 |  10 +-
 t/t6023-merge-file.sh                  |  12 +-
 t/t6027-merge-binary.sh                |   4 +-
 t/t6031-merge-filemode.sh              |   2 +-
 t/t6112-rev-list-filters-objects.sh    | 224 ++++++++-------
 t/t7201-co.sh                          |   4 +-
 t/t7406-submodule-update.sh            |   8 +-
 t/t7800-difftool.sh                    |   2 +-
 t/t9100-git-svn-basic.sh               |   2 +-
 t/t9101-git-svn-props.sh               |  34 ++-
 t/t9133-git-svn-nested-git-repo.sh     |   6 +-
 t/t9600-cvsimport.sh                   |   2 +-
 t/t9603-cvsimport-patchsets.sh         |   4 +-
 t/t9604-cvsimport-timestamps.sh        |   4 +-
 38 files changed, 504 insertions(+), 366 deletions(-)

-- 
2.19.0.444.g18242da7ef-goog


^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v3 1/5] CodingGuidelines: add shell piping guidelines
  2018-09-21  1:43 ` [PATCH v3 0/5] Clean up tests for test_cmp arg ordering and pipe placement Matthew DeVore
@ 2018-09-21  1:43   ` Matthew DeVore
  2018-09-21  2:06     ` Eric Sunshine
  2018-09-24 21:03     ` SZEDER Gábor
  2018-09-21  1:43   ` [PATCH v3 2/5] tests: standardize pipe placement Matthew DeVore
                     ` (3 subsequent siblings)
  4 siblings, 2 replies; 66+ messages in thread
From: Matthew DeVore @ 2018-09-21  1:43 UTC (permalink / raw)
  To: git; +Cc: Matthew DeVore, peff, jonathantanmy, gitster, jrn, sunshine

Add two guidelines:

 - pipe characters should appear at the end of lines, and not cause
   indentation
 - pipes should be avoided when they swallow exit codes that can
   potentially fail
---
 Documentation/CodingGuidelines | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines
index 48aa4edfb..6d265327c 100644
--- a/Documentation/CodingGuidelines
+++ b/Documentation/CodingGuidelines
@@ -118,6 +118,24 @@ For shell scripts specifically (not exhaustive):
 		do this
 	fi
 
+ - If a command sequence joined with && or || or | spans multiple
+   lines, put each command on a separate line and put && and || and |
+   operators at the end of each line, rather than the start. This
+   means you don't need to use \ to join lines, since the above
+   operators imply the sequence isn't finished.
+
+	(incorrect)
+	grep blob verify_pack_result \
+	| awk -f print_1.awk \
+	| sort >actual &&
+	...
+
+	(correct)
+	grep blob verify_pack_result |
+	awk -f print_1.awk |
+	sort >actual &&
+	...
+
  - We prefer "test" over "[ ... ]".
 
  - We do not write the noiseword "function" in front of shell
@@ -163,6 +181,15 @@ For shell scripts specifically (not exhaustive):
 
    does not have such a problem.
 
+ - In a piped chain such as "grep blob objects | sort", the exit codes
+   returned by processes besides the last are ignored. This means that
+   if git crashes at the beginning or middle of a chain, it may go
+   undetected. Prefer writing the output of that command to a
+   temporary file with '>' rather than pipe it.
+
+ - The $(git ...) construct also discards git's exit code, so if the
+   goal is to test that particular command, redirect its output to a
+   temporary file rather than wrap it with $( ).
 
 For C programs:
 
-- 
2.19.0.444.g18242da7ef-goog


^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [PATCH v3 2/5] tests: standardize pipe placement
  2018-09-21  1:43 ` [PATCH v3 0/5] Clean up tests for test_cmp arg ordering and pipe placement Matthew DeVore
  2018-09-21  1:43   ` [PATCH v3 1/5] CodingGuidelines: add shell piping guidelines Matthew DeVore
@ 2018-09-21  1:43   ` Matthew DeVore
  2018-09-21  1:43   ` [PATCH v3 3/5] t/*: fix ordering of expected/observed arguments Matthew DeVore
                     ` (2 subsequent siblings)
  4 siblings, 0 replies; 66+ messages in thread
From: Matthew DeVore @ 2018-09-21  1:43 UTC (permalink / raw)
  To: git; +Cc: Matthew DeVore, peff, jonathantanmy, gitster, jrn, sunshine

Instead of using a line-continuation and pipe on the second line, take
advantage of the shell's implicit line continuation after a pipe
character.  So for example, instead of

	some long line \
		| next line

use

	some long line |
	next line

And add a blank line before and after the pipe where it aids readability
(it usually does).

This better matches the coding style documented in
Documentation/CodingGuidelines and used in shell scripts elsewhere in
the tree.

Signed-off-by: Matthew DeVore <matvore@google.com>
---
 t/lib-gpg.sh                           |   9 +-
 t/t1006-cat-file.sh                    |   8 +-
 t/t1300-config.sh                      |   5 +-
 t/t5317-pack-objects-filter-objects.sh | 330 ++++++++++++++-----------
 t/t5500-fetch-pack.sh                  |   7 +-
 t/t5616-partial-clone.sh               |  32 ++-
 t/t6112-rev-list-filters-objects.sh    | 203 ++++++++-------
 7 files changed, 344 insertions(+), 250 deletions(-)

diff --git a/t/lib-gpg.sh b/t/lib-gpg.sh
index 3fe02876c..f1277bef4 100755
--- a/t/lib-gpg.sh
+++ b/t/lib-gpg.sh
@@ -57,9 +57,12 @@ then
 		echo | gpgsm --homedir "${GNUPGHOME}" 2>/dev/null \
 			--passphrase-fd 0 --pinentry-mode loopback \
 			--import "$TEST_DIRECTORY"/lib-gpg/gpgsm_cert.p12 &&
-		gpgsm --homedir "${GNUPGHOME}" 2>/dev/null -K \
-			| grep fingerprint: | cut -d" " -f4 | tr -d '\n' > \
-			${GNUPGHOME}/trustlist.txt &&
+
+		gpgsm --homedir "${GNUPGHOME}" 2>/dev/null -K |
+		grep fingerprint: |
+		cut -d" " -f4 |
+		tr -d '\n' >"${GNUPGHOME}/trustlist.txt" &&
+
 		echo " S relax" >> ${GNUPGHOME}/trustlist.txt &&
 		(gpgconf --kill gpg-agent >/dev/null 2>&1 || : ) &&
 		echo hello | gpgsm --homedir "${GNUPGHOME}" >/dev/null \
diff --git a/t/t1006-cat-file.sh b/t/t1006-cat-file.sh
index 7f19d591f..a0fa926d3 100755
--- a/t/t1006-cat-file.sh
+++ b/t/t1006-cat-file.sh
@@ -218,8 +218,8 @@ test_expect_success "--batch-check for a non-existent hash" '
     test "0000000000000000000000000000000000000042 missing
 0000000000000000000000000000000000000084 missing" = \
     "$( ( echo 0000000000000000000000000000000000000042;
-         echo_without_newline 0000000000000000000000000000000000000084; ) \
-       | git cat-file --batch-check)"
+         echo_without_newline 0000000000000000000000000000000000000084; ) |
+       git cat-file --batch-check)"
 '
 
 test_expect_success "--batch for an existent and a non-existent hash" '
@@ -227,8 +227,8 @@ test_expect_success "--batch for an existent and a non-existent hash" '
 $tag_content
 0000000000000000000000000000000000000000 missing" = \
     "$( ( echo $tag_sha1;
-         echo_without_newline 0000000000000000000000000000000000000000; ) \
-       | git cat-file --batch)"
+         echo_without_newline 0000000000000000000000000000000000000000; ) |
+       git cat-file --batch)"
 '
 
 test_expect_success "--batch-check for an empty line" '
diff --git a/t/t1300-config.sh b/t/t1300-config.sh
index cdf1fed5d..5869d6cb6 100755
--- a/t/t1300-config.sh
+++ b/t/t1300-config.sh
@@ -1770,8 +1770,9 @@ test_expect_success '--show-origin stdin with file include' '
 	cat >expect <<-EOF &&
 		file:$INCLUDE_DIR/stdin.include	include
 	EOF
-	echo "[include]path=\"$INCLUDE_DIR\"/stdin.include" \
-		| git config --show-origin --includes --file - user.stdin >output &&
+	echo "[include]path=\"$INCLUDE_DIR\"/stdin.include" |
+	git config --show-origin --includes --file - user.stdin >output &&
+
 	test_cmp expect output
 '
 
diff --git a/t/t5317-pack-objects-filter-objects.sh b/t/t5317-pack-objects-filter-objects.sh
index 6710c8bc8..ce69148ec 100755
--- a/t/t5317-pack-objects-filter-objects.sh
+++ b/t/t5317-pack-objects-filter-objects.sh
@@ -20,17 +20,20 @@ test_expect_success 'setup r1' '
 '
 
 test_expect_success 'verify blob count in normal packfile' '
-	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	git -C r1 pack-objects --rev --stdout >all.pack <<-EOF &&
 	HEAD
 	EOF
 	git -C r1 index-pack ../all.pack &&
-	git -C r1 verify-pack -v ../all.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r1 verify-pack -v ../all.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
@@ -39,23 +42,27 @@ test_expect_success 'verify blob:none packfile has no blobs' '
 	HEAD
 	EOF
 	git -C r1 index-pack ../filter.pack &&
-	git -C r1 verify-pack -v ../filter.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r1 verify-pack -v ../filter.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	nr=$(wc -l <observed) &&
 	test 0 -eq $nr
 '
 
 test_expect_success 'verify normal and blob:none packfiles have same commits/trees' '
-	git -C r1 verify-pack -v ../all.pack \
-		| grep -E "commit|tree" \
-		| awk -f print_1.awk \
-		| sort >expected &&
-	git -C r1 verify-pack -v ../filter.pack \
-		| grep -E "commit|tree" \
-		| awk -f print_1.awk \
-		| sort >observed &&
+	git -C r1 verify-pack -v ../all.pack |
+	grep -E "commit|tree" |
+	awk -f print_1.awk |
+	sort >expected &&
+
+	git -C r1 verify-pack -v ../filter.pack |
+	grep -E "commit|tree" |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
@@ -75,17 +82,20 @@ test_expect_success 'setup r2' '
 '
 
 test_expect_success 'verify blob count in normal packfile' '
-	git -C r2 ls-files -s large.1000 large.10000 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r2 ls-files -s large.1000 large.10000 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	git -C r2 pack-objects --rev --stdout >all.pack <<-EOF &&
 	HEAD
 	EOF
 	git -C r2 index-pack ../all.pack &&
-	git -C r2 verify-pack -v ../all.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r2 verify-pack -v ../all.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
@@ -94,10 +104,12 @@ test_expect_success 'verify blob:limit=500 omits all blobs' '
 	HEAD
 	EOF
 	git -C r2 index-pack ../filter.pack &&
-	git -C r2 verify-pack -v ../filter.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r2 verify-pack -v ../filter.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	nr=$(wc -l <observed) &&
 	test 0 -eq $nr
 '
@@ -107,99 +119,118 @@ test_expect_success 'verify blob:limit=1000' '
 	HEAD
 	EOF
 	git -C r2 index-pack ../filter.pack &&
-	git -C r2 verify-pack -v ../filter.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r2 verify-pack -v ../filter.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	nr=$(wc -l <observed) &&
 	test 0 -eq $nr
 '
 
 test_expect_success 'verify blob:limit=1001' '
-	git -C r2 ls-files -s large.1000 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r2 ls-files -s large.1000 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	git -C r2 pack-objects --rev --stdout --filter=blob:limit=1001 >filter.pack <<-EOF &&
 	HEAD
 	EOF
 	git -C r2 index-pack ../filter.pack &&
-	git -C r2 verify-pack -v ../filter.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r2 verify-pack -v ../filter.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify blob:limit=10001' '
-	git -C r2 ls-files -s large.1000 large.10000 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r2 ls-files -s large.1000 large.10000 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	git -C r2 pack-objects --rev --stdout --filter=blob:limit=10001 >filter.pack <<-EOF &&
 	HEAD
 	EOF
 	git -C r2 index-pack ../filter.pack &&
-	git -C r2 verify-pack -v ../filter.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r2 verify-pack -v ../filter.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify blob:limit=1k' '
-	git -C r2 ls-files -s large.1000 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r2 ls-files -s large.1000 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	git -C r2 pack-objects --rev --stdout --filter=blob:limit=1k >filter.pack <<-EOF &&
 	HEAD
 	EOF
 	git -C r2 index-pack ../filter.pack &&
-	git -C r2 verify-pack -v ../filter.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r2 verify-pack -v ../filter.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify explicitly specifying oversized blob in input' '
-	git -C r2 ls-files -s large.1000 large.10000 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r2 ls-files -s large.1000 large.10000 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	git -C r2 pack-objects --rev --stdout --filter=blob:limit=1k >filter.pack <<-EOF &&
 	HEAD
 	$(git -C r2 rev-parse HEAD:large.10000)
 	EOF
 	git -C r2 index-pack ../filter.pack &&
-	git -C r2 verify-pack -v ../filter.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r2 verify-pack -v ../filter.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify blob:limit=1m' '
-	git -C r2 ls-files -s large.1000 large.10000 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r2 ls-files -s large.1000 large.10000 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	git -C r2 pack-objects --rev --stdout --filter=blob:limit=1m >filter.pack <<-EOF &&
 	HEAD
 	EOF
 	git -C r2 index-pack ../filter.pack &&
-	git -C r2 verify-pack -v ../filter.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r2 verify-pack -v ../filter.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify normal and blob:limit packfiles have same commits/trees' '
-	git -C r2 verify-pack -v ../all.pack \
-		| grep -E "commit|tree" \
-		| awk -f print_1.awk \
-		| sort >expected &&
-	git -C r2 verify-pack -v ../filter.pack \
-		| grep -E "commit|tree" \
-		| awk -f print_1.awk \
-		| sort >observed &&
+	git -C r2 verify-pack -v ../all.pack |
+	grep -E "commit|tree" |
+	awk -f print_1.awk |
+	sort >expected &&
+
+	git -C r2 verify-pack -v ../filter.pack |
+	grep -E "commit|tree" |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
@@ -224,71 +255,84 @@ test_expect_success 'setup r3' '
 '
 
 test_expect_success 'verify blob count in normal packfile' '
-	git -C r3 ls-files -s sparse1 sparse2 dir1/sparse1 dir1/sparse2 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r3 ls-files -s sparse1 sparse2 dir1/sparse1 dir1/sparse2 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	git -C r3 pack-objects --rev --stdout >all.pack <<-EOF &&
 	HEAD
 	EOF
 	git -C r3 index-pack ../all.pack &&
-	git -C r3 verify-pack -v ../all.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r3 verify-pack -v ../all.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify sparse:path=pattern1' '
-	git -C r3 ls-files -s dir1/sparse1 dir1/sparse2 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r3 ls-files -s dir1/sparse1 dir1/sparse2 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	git -C r3 pack-objects --rev --stdout --filter=sparse:path=../pattern1 >filter.pack <<-EOF &&
 	HEAD
 	EOF
 	git -C r3 index-pack ../filter.pack &&
-	git -C r3 verify-pack -v ../filter.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r3 verify-pack -v ../filter.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify normal and sparse:path=pattern1 packfiles have same commits/trees' '
-	git -C r3 verify-pack -v ../all.pack \
-		| grep -E "commit|tree" \
-		| awk -f print_1.awk \
-		| sort >expected &&
-	git -C r3 verify-pack -v ../filter.pack \
-		| grep -E "commit|tree" \
-		| awk -f print_1.awk \
-		| sort >observed &&
+	git -C r3 verify-pack -v ../all.pack |
+	grep -E "commit|tree" |
+	awk -f print_1.awk |
+	sort >expected &&
+
+	git -C r3 verify-pack -v ../filter.pack |
+	grep -E "commit|tree" |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify sparse:path=pattern2' '
-	git -C r3 ls-files -s sparse1 dir1/sparse1 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r3 ls-files -s sparse1 dir1/sparse1 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	git -C r3 pack-objects --rev --stdout --filter=sparse:path=../pattern2 >filter.pack <<-EOF &&
 	HEAD
 	EOF
 	git -C r3 index-pack ../filter.pack &&
-	git -C r3 verify-pack -v ../filter.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r3 verify-pack -v ../filter.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify normal and sparse:path=pattern2 packfiles have same commits/trees' '
-	git -C r3 verify-pack -v ../all.pack \
-		| grep -E "commit|tree" \
-		| awk -f print_1.awk \
-		| sort >expected &&
-	git -C r3 verify-pack -v ../filter.pack \
-		| grep -E "commit|tree" \
-		| awk -f print_1.awk \
-		| sort >observed &&
+	git -C r3 verify-pack -v ../all.pack |
+	grep -E "commit|tree" |
+	awk -f print_1.awk |
+	sort >expected &&
+
+	git -C r3 verify-pack -v ../filter.pack |
+	grep -E "commit|tree" |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
@@ -312,48 +356,57 @@ test_expect_success 'setup r4' '
 '
 
 test_expect_success 'verify blob count in normal packfile' '
-	git -C r4 ls-files -s pattern sparse1 sparse2 dir1/sparse1 dir1/sparse2 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r4 ls-files -s pattern sparse1 sparse2 dir1/sparse1 dir1/sparse2 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	git -C r4 pack-objects --rev --stdout >all.pack <<-EOF &&
 	HEAD
 	EOF
 	git -C r4 index-pack ../all.pack &&
-	git -C r4 verify-pack -v ../all.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r4 verify-pack -v ../all.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify sparse:oid=OID' '
-	git -C r4 ls-files -s dir1/sparse1 dir1/sparse2 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r4 ls-files -s dir1/sparse1 dir1/sparse2 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	oid=$(git -C r4 ls-files -s pattern | awk -f print_2.awk) &&
 	git -C r4 pack-objects --rev --stdout --filter=sparse:oid=$oid >filter.pack <<-EOF &&
 	HEAD
 	EOF
 	git -C r4 index-pack ../filter.pack &&
-	git -C r4 verify-pack -v ../filter.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r4 verify-pack -v ../filter.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify sparse:oid=oid-ish' '
-	git -C r4 ls-files -s dir1/sparse1 dir1/sparse2 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r4 ls-files -s dir1/sparse1 dir1/sparse2 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	git -C r4 pack-objects --rev --stdout --filter=sparse:oid=master:pattern >filter.pack <<-EOF &&
 	HEAD
 	EOF
 	git -C r4 index-pack ../filter.pack &&
-	git -C r4 verify-pack -v ../filter.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r4 verify-pack -v ../filter.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
@@ -361,9 +414,10 @@ test_expect_success 'verify sparse:oid=oid-ish' '
 # This models previously omitted objects that we did not receive.
 
 test_expect_success 'setup r1 - delete loose blobs' '
-	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	for id in `cat expected | sed "s|..|&/|"`
 	do
 		rm r1/.git/objects/$id
diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh
index 1b5a4a6d3..086f2c40f 100755
--- a/t/t5500-fetch-pack.sh
+++ b/t/t5500-fetch-pack.sh
@@ -50,8 +50,11 @@ pull_to_client () {
 			case "$heads" in *B*)
 			    git update-ref refs/heads/B "$BTIP";;
 			esac &&
-			git symbolic-ref HEAD refs/heads/$(echo $heads \
-				| sed -e "s/^\(.\).*$/\1/") &&
+
+			git symbolic-ref HEAD refs/heads/$(
+				echo $heads |
+				sed -e "s/^\(.\).*$/\1/"
+			) &&
 
 			git fsck --full &&
 
diff --git a/t/t5616-partial-clone.sh b/t/t5616-partial-clone.sh
index bbbe7537d..e4d032c9d 100755
--- a/t/t5616-partial-clone.sh
+++ b/t/t5616-partial-clone.sh
@@ -34,10 +34,12 @@ test_expect_success 'setup bare clone for server' '
 # confirm partial clone was registered in the local config.
 test_expect_success 'do partial clone 1' '
 	git clone --no-checkout --filter=blob:none "file://$(pwd)/srv.bare" pc1 &&
-	git -C pc1 rev-list HEAD --quiet --objects --missing=print \
-		| awk -f print_1.awk \
-		| sed "s/?//" \
-		| sort >observed.oids &&
+
+	git -C pc1 rev-list HEAD --quiet --objects --missing=print |
+	awk -f print_1.awk |
+	sed "s/?//" |
+	sort >observed.oids &&
+
 	test_cmp expect_1.oids observed.oids &&
 	test "$(git -C pc1 config --local core.repositoryformatversion)" = "1" &&
 	test "$(git -C pc1 config --local extensions.partialclone)" = "origin" &&
@@ -130,16 +132,20 @@ test_expect_success 'push new commits to server for file.3.txt' '
 # perhaps combined with a command in dry-run mode.
 test_expect_success 'manual prefetch of missing objects' '
 	git -C pc1 fetch --filter=blob:none origin &&
-	git -C pc1 rev-list master..origin/master --quiet --objects --missing=print \
-		| awk -f print_1.awk \
-		| sed "s/?//" \
-		| sort >observed.oids &&
+
+	git -C pc1 rev-list master..origin/master --quiet --objects --missing=print |
+	awk -f print_1.awk |
+	sed "s/?//" |
+	sort >observed.oids &&
+
 	test_line_count = 6 observed.oids &&
 	git -C pc1 fetch-pack --stdin "file://$(pwd)/srv.bare" <observed.oids &&
-	git -C pc1 rev-list master..origin/master --quiet --objects --missing=print \
-		| awk -f print_1.awk \
-		| sed "s/?//" \
-		| sort >observed.oids &&
+
+	git -C pc1 rev-list master..origin/master --quiet --objects --missing=print |
+	awk -f print_1.awk |
+	sed "s/?//" |
+	sort >observed.oids &&
+
 	test_line_count = 0 observed.oids
 '
 
@@ -194,7 +200,7 @@ test_expect_success 'upon cloning, check that all refs point to objects' '
 
 	# Craft a packfile not including that blob.
 	git -C "$SERVER" rev-parse HEAD |
-		git -C "$SERVER" pack-objects --stdout >incomplete.pack &&
+	git -C "$SERVER" pack-objects --stdout >incomplete.pack &&
 
 	# Replace the existing packfile with the crafted one. The protocol
 	# requires that the packfile be sent in sideband 1, hence the extra
diff --git a/t/t6112-rev-list-filters-objects.sh b/t/t6112-rev-list-filters-objects.sh
index d4ff0b3be..0f6b569e1 100755
--- a/t/t6112-rev-list-filters-objects.sh
+++ b/t/t6112-rev-list-filters-objects.sh
@@ -20,24 +20,28 @@ test_expect_success 'setup r1' '
 '
 
 test_expect_success 'verify blob:none omits all 5 blobs' '
-	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 \
-		| awk -f print_2.awk \
-		| sort >expected &&
-	git -C r1 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:none \
-		| awk -f print_1.awk \
-		| sed "s/~//" \
-		| sort >observed &&
+	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 |
+	awk -f print_2.awk |
+	sort >expected &&
+
+	git -C r1 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:none |
+	awk -f print_1.awk |
+	sed "s/~//" |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify emitted+omitted == all' '
-	git -C r1 rev-list HEAD --objects \
-		| awk -f print_1.awk \
-		| sort >expected &&
-	git -C r1 rev-list HEAD --objects --filter-print-omitted --filter=blob:none \
-		| awk -f print_1.awk \
-		| sed "s/~//" \
-		| sort >observed &&
+	git -C r1 rev-list HEAD --objects |
+	awk -f print_1.awk |
+	sort >expected &&
+
+	git -C r1 rev-list HEAD --objects --filter-print-omitted --filter=blob:none |
+	awk -f print_1.awk |
+	sed "s/~//" |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
@@ -58,65 +62,76 @@ test_expect_success 'setup r2' '
 '
 
 test_expect_success 'verify blob:limit=500 omits all blobs' '
-	git -C r2 ls-files -s large.1000 large.10000 \
-		| awk -f print_2.awk \
-		| sort >expected &&
-	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=500 \
-		| awk -f print_1.awk \
-		| sed "s/~//" \
-		| sort >observed &&
+	git -C r2 ls-files -s large.1000 large.10000 |
+	awk -f print_2.awk |
+	sort >expected &&
+
+	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=500 |
+	awk -f print_1.awk |
+	sed "s/~//" |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify emitted+omitted == all' '
-	git -C r2 rev-list HEAD --objects \
-		| awk -f print_1.awk \
-		| sort >expected &&
-	git -C r2 rev-list HEAD --objects --filter-print-omitted --filter=blob:limit=500 \
-		| awk -f print_1.awk \
-		| sed "s/~//" \
-		| sort >observed &&
+	git -C r2 rev-list HEAD --objects |
+	awk -f print_1.awk |
+	sort >expected &&
+
+	git -C r2 rev-list HEAD --objects --filter-print-omitted --filter=blob:limit=500 |
+	awk -f print_1.awk |
+	sed "s/~//" |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify blob:limit=1000' '
-	git -C r2 ls-files -s large.1000 large.10000 \
-		| awk -f print_2.awk \
-		| sort >expected &&
-	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1000 \
-		| awk -f print_1.awk \
-		| sed "s/~//" \
-		| sort >observed &&
+	git -C r2 ls-files -s large.1000 large.10000 |
+	awk -f print_2.awk |
+	sort >expected &&
+
+	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1000 |
+	awk -f print_1.awk |
+	sed "s/~//" |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify blob:limit=1001' '
-	git -C r2 ls-files -s large.10000 \
-		| awk -f print_2.awk \
-		| sort >expected &&
-	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1001 \
-		| awk -f print_1.awk \
-		| sed "s/~//" \
-		| sort >observed &&
+	git -C r2 ls-files -s large.10000 |
+	awk -f print_2.awk |
+	sort >expected &&
+
+	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1001 |
+	awk -f print_1.awk |
+	sed "s/~//" |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify blob:limit=1k' '
-	git -C r2 ls-files -s large.10000 \
-		| awk -f print_2.awk \
-		| sort >expected &&
-	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1k \
-		| awk -f print_1.awk \
-		| sed "s/~//" \
-		| sort >observed &&
+	git -C r2 ls-files -s large.10000 |
+	awk -f print_2.awk |
+	sort >expected &&
+
+	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1k |
+	awk -f print_1.awk |
+	sed "s/~//" |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify blob:limit=1m' '
-	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1m \
-		| awk -f print_1.awk \
-		| sed "s/~//" \
-		| sort >observed &&
+	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1m |
+	awk -f print_1.awk |
+	sed "s/~//" |
+	sort >observed &&
+
 	test_must_be_empty observed
 '
 
@@ -141,24 +156,28 @@ test_expect_success 'setup r3' '
 '
 
 test_expect_success 'verify sparse:path=pattern1 omits top-level files' '
-	git -C r3 ls-files -s sparse1 sparse2 \
-		| awk -f print_2.awk \
-		| sort >expected &&
-	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:path=../pattern1 \
-		| awk -f print_1.awk \
-		| sed "s/~//" \
-		| sort >observed &&
+	git -C r3 ls-files -s sparse1 sparse2 |
+	awk -f print_2.awk |
+	sort >expected &&
+
+	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:path=../pattern1 |
+	awk -f print_1.awk |
+	sed "s/~//" |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify sparse:path=pattern2 omits both sparse2 files' '
-	git -C r3 ls-files -s sparse2 dir1/sparse2 \
-		| awk -f print_2.awk \
-		| sort >expected &&
-	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:path=../pattern2 \
-		| awk -f print_1.awk \
-		| sed "s/~//" \
-		| sort >observed &&
+	git -C r3 ls-files -s sparse2 dir1/sparse2 |
+	awk -f print_2.awk |
+	sort >expected &&
+
+	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:path=../pattern2 |
+	awk -f print_1.awk |
+	sed "s/~//" |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
@@ -173,25 +192,30 @@ test_expect_success 'setup r3 part 2' '
 '
 
 test_expect_success 'verify sparse:oid=OID omits top-level files' '
-	git -C r3 ls-files -s pattern sparse1 sparse2 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r3 ls-files -s pattern sparse1 sparse2 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	oid=$(git -C r3 ls-files -s pattern | awk -f print_2.awk) &&
-	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:oid=$oid \
-		| awk -f print_1.awk \
-		| sed "s/~//" \
-		| sort >observed &&
+
+	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:oid=$oid |
+	awk -f print_1.awk |
+	sed "s/~//" |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify sparse:oid=oid-ish omits top-level files' '
-	git -C r3 ls-files -s pattern sparse1 sparse2 \
-		| awk -f print_2.awk \
-		| sort >expected &&
-	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:oid=master:pattern \
-		| awk -f print_1.awk \
-		| sed "s/~//" \
-		| sort >observed &&
+	git -C r3 ls-files -s pattern sparse1 sparse2 |
+	awk -f print_2.awk |
+	sort >expected &&
+
+	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:oid=master:pattern |
+	awk -f print_1.awk |
+	sed "s/~//" |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
@@ -199,17 +223,20 @@ test_expect_success 'verify sparse:oid=oid-ish omits top-level files' '
 # This models previously omitted objects that we did not receive.
 
 test_expect_success 'rev-list W/ --missing=print' '
-	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	for id in `cat expected | sed "s|..|&/|"`
 	do
 		rm r1/.git/objects/$id
 	done &&
-	git -C r1 rev-list --quiet HEAD --missing=print --objects \
-		| awk -f print_1.awk \
-		| sed "s/?//" \
-		| sort >observed &&
+
+	git -C r1 rev-list --quiet HEAD --missing=print --objects |
+	awk -f print_1.awk |
+	sed "s/?//" |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
-- 
2.19.0.444.g18242da7ef-goog


^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [PATCH v3 3/5] t/*: fix ordering of expected/observed arguments
  2018-09-21  1:43 ` [PATCH v3 0/5] Clean up tests for test_cmp arg ordering and pipe placement Matthew DeVore
  2018-09-21  1:43   ` [PATCH v3 1/5] CodingGuidelines: add shell piping guidelines Matthew DeVore
  2018-09-21  1:43   ` [PATCH v3 2/5] tests: standardize pipe placement Matthew DeVore
@ 2018-09-21  1:43   ` Matthew DeVore
  2018-09-21  1:43   ` [PATCH v3 4/5] tests: don't swallow Git errors upstream of pipes Matthew DeVore
  2018-09-21  1:43   ` [PATCH v3 5/5] t9109: " Matthew DeVore
  4 siblings, 0 replies; 66+ messages in thread
From: Matthew DeVore @ 2018-09-21  1:43 UTC (permalink / raw)
  To: git; +Cc: Matthew DeVore, peff, jonathantanmy, gitster, jrn, sunshine

Fix various places where the ordering was obviously wrong, meaning it
was easy to find with grep.

Signed-off-by: Matthew DeVore <matvore@google.com>
---
 t/t0000-basic.sh                       |  2 +-
 t/t0021-conversion.sh                  |  4 +--
 t/t1300-config.sh                      |  4 +--
 t/t1303-wacky-config.sh                |  4 +--
 t/t2101-update-index-reupdate.sh       |  2 +-
 t/t3200-branch.sh                      |  2 +-
 t/t3320-notes-merge-worktrees.sh       |  4 +--
 t/t3400-rebase.sh                      |  8 +++---
 t/t3417-rebase-whitespace-fix.sh       |  6 ++---
 t/t3702-add-edit.sh                    |  4 +--
 t/t3903-stash.sh                       |  8 +++---
 t/t3905-stash-include-untracked.sh     |  2 +-
 t/t4025-hunk-header.sh                 |  2 +-
 t/t4117-apply-reject.sh                |  6 ++---
 t/t4124-apply-ws-rule.sh               | 30 +++++++++++------------
 t/t4138-apply-ws-expansion.sh          |  2 +-
 t/t5317-pack-objects-filter-objects.sh | 34 +++++++++++++-------------
 t/t5318-commit-graph.sh                |  2 +-
 t/t5701-git-serve.sh                   | 14 +++++------
 t/t5702-protocol-v2.sh                 | 10 ++++----
 t/t6023-merge-file.sh                  | 12 ++++-----
 t/t6027-merge-binary.sh                |  4 +--
 t/t6031-merge-filemode.sh              |  2 +-
 t/t6112-rev-list-filters-objects.sh    | 24 +++++++++---------
 t/t7201-co.sh                          |  4 +--
 t/t7406-submodule-update.sh            |  8 +++---
 t/t7800-difftool.sh                    |  2 +-
 t/t9100-git-svn-basic.sh               |  2 +-
 t/t9133-git-svn-nested-git-repo.sh     |  6 ++---
 t/t9600-cvsimport.sh                   |  2 +-
 t/t9603-cvsimport-patchsets.sh         |  4 +--
 t/t9604-cvsimport-timestamps.sh        |  4 +--
 32 files changed, 112 insertions(+), 112 deletions(-)

diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh
index 850f651e4..224c098a8 100755
--- a/t/t0000-basic.sh
+++ b/t/t0000-basic.sh
@@ -1018,7 +1018,7 @@ test_expect_success SHA1 'validate git diff-files output for a know cache/work t
 :120000 120000 6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c 0000000000000000000000000000000000000000 M	path3/subp3/file3sym
 EOF
 	git diff-files >current &&
-	test_cmp current expected
+	test_cmp expected current
 '
 
 test_expect_success 'git update-index --refresh should succeed' '
diff --git a/t/t0021-conversion.sh b/t/t0021-conversion.sh
index 308cd28f3..fd5f1ac64 100755
--- a/t/t0021-conversion.sh
+++ b/t/t0021-conversion.sh
@@ -166,10 +166,10 @@ test_expect_success expanded_in_repo '
 	rm -f expanded-keywords expanded-keywords-crlf &&
 
 	git checkout -- expanded-keywords &&
-	test_cmp expanded-keywords expected-output &&
+	test_cmp expected-output expanded-keywords &&
 
 	git checkout -- expanded-keywords-crlf &&
-	test_cmp expanded-keywords-crlf expected-output-crlf
+	test_cmp expected-output-crlf expanded-keywords-crlf
 '
 
 # The use of %f in a filter definition is expanded to the path to
diff --git a/t/t1300-config.sh b/t/t1300-config.sh
index 5869d6cb6..e2cd50ecf 100755
--- a/t/t1300-config.sh
+++ b/t/t1300-config.sh
@@ -1001,7 +1001,7 @@ EOF
 
 test_expect_success 'value continued on next line' '
 	git config --list > result &&
-	test_cmp result expect
+	test_cmp expect result
 '
 
 cat > .git/config <<\EOF
@@ -1882,7 +1882,7 @@ test_expect_success '--replace-all does not invent newlines' '
 	Qkey = b
 	EOF
 	git config --replace-all abc.key b &&
-	test_cmp .git/config expect
+	test_cmp expect .git/config
 '
 
 test_done
diff --git a/t/t1303-wacky-config.sh b/t/t1303-wacky-config.sh
index 3b92083e1..0000e664e 100755
--- a/t/t1303-wacky-config.sh
+++ b/t/t1303-wacky-config.sh
@@ -14,7 +14,7 @@ setup() {
 check() {
 	echo "$2" >expected
 	git config --get "$1" >actual 2>&1
-	test_cmp actual expected
+	test_cmp expected actual
 }
 
 # 'check section.key regex value' verifies that the entry for
@@ -22,7 +22,7 @@ check() {
 check_regex() {
 	echo "$3" >expected
 	git config --get "$1" "$2" >actual 2>&1
-	test_cmp actual expected
+	test_cmp expected actual
 }
 
 test_expect_success 'modify same key' '
diff --git a/t/t2101-update-index-reupdate.sh b/t/t2101-update-index-reupdate.sh
index 685ec4563..6c32d42c8 100755
--- a/t/t2101-update-index-reupdate.sh
+++ b/t/t2101-update-index-reupdate.sh
@@ -73,7 +73,7 @@ test_expect_success 'update-index --update from subdir' '
 	100644 $(git hash-object dir1/file3) 0	dir1/file3
 	100644 $file2 0	file2
 	EOF
-	test_cmp current expected
+	test_cmp expected current
 '
 
 test_expect_success 'update-index --update with pathspec' '
diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index 93f21ab07..478b82cf9 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -1221,7 +1221,7 @@ test_expect_success 'use --edit-description' '
 	EOF
 	EDITOR=./editor git branch --edit-description &&
 	echo "New contents" >expect &&
-	test_cmp EDITOR_OUTPUT expect
+	test_cmp expect EDITOR_OUTPUT
 '
 
 test_expect_success 'detect typo in branch name when using --edit-description' '
diff --git a/t/t3320-notes-merge-worktrees.sh b/t/t3320-notes-merge-worktrees.sh
index 10bfc8b94..823fdbda1 100755
--- a/t/t3320-notes-merge-worktrees.sh
+++ b/t/t3320-notes-merge-worktrees.sh
@@ -44,7 +44,7 @@ test_expect_success 'merge z into y fails and sets NOTES_MERGE_REF' '
 	git config core.notesRef refs/notes/y &&
 	test_must_fail git notes merge z &&
 	echo "ref: refs/notes/y" >expect &&
-	test_cmp .git/NOTES_MERGE_REF expect
+	test_cmp expect .git/NOTES_MERGE_REF
 '
 
 test_expect_success 'merge z into y while mid-merge in another workdir fails' '
@@ -66,7 +66,7 @@ test_expect_success 'merge z into x while mid-merge on y succeeds' '
 		grep -v "A notes merge into refs/notes/x is already in-progress in" out
 	) &&
 	echo "ref: refs/notes/x" >expect &&
-	test_cmp .git/worktrees/worktree2/NOTES_MERGE_REF expect
+	test_cmp expect .git/worktrees/worktree2/NOTES_MERGE_REF
 '
 
 test_done
diff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh
index 3996ee013..3e73f7584 100755
--- a/t/t3400-rebase.sh
+++ b/t/t3400-rebase.sh
@@ -183,13 +183,13 @@ test_expect_success 'cherry-picked commits and fork-point work together' '
 	test_commit final_B B "Final B" &&
 	git rebase &&
 	echo Amended >expect &&
-	test_cmp A expect &&
+	test_cmp expect A &&
 	echo "Final B" >expect &&
-	test_cmp B expect &&
+	test_cmp expect B &&
 	echo C >expect &&
-	test_cmp C expect &&
+	test_cmp expect C &&
 	echo D >expect &&
-	test_cmp D expect
+	test_cmp expect D
 '
 
 test_expect_success 'rebase -q is quiet' '
diff --git a/t/t3417-rebase-whitespace-fix.sh b/t/t3417-rebase-whitespace-fix.sh
index 1fb3e499b..e85cdc703 100755
--- a/t/t3417-rebase-whitespace-fix.sh
+++ b/t/t3417-rebase-whitespace-fix.sh
@@ -55,7 +55,7 @@ test_expect_success 'blank line at end of file; extend at end of file' '
 	git add file &&	git commit -m second &&
 	git rebase --whitespace=fix HEAD^^ &&
 	git diff --exit-code HEAD^:file expect-first &&
-	test_cmp file expect-second
+	test_cmp expect-second file
 '
 
 # prepare third revision of "file"
@@ -82,7 +82,7 @@ test_expect_success 'two blanks line at end of file; extend at end of file' '
 	cp third file && git add file && git commit -m third &&
 	git rebase --whitespace=fix HEAD^^ &&
 	git diff --exit-code HEAD^:file expect-second &&
-	test_cmp file expect-third
+	test_cmp expect-third file
 '
 
 test_expect_success 'same, but do not remove trailing spaces' '
@@ -120,7 +120,7 @@ test_expect_success 'at beginning of file' '
 	done >> file &&
 	git commit -m more file	&&
 	git rebase --whitespace=fix HEAD^^ &&
-	test_cmp file expect-beginning
+	test_cmp expect-beginning file
 '
 
 test_done
diff --git a/t/t3702-add-edit.sh b/t/t3702-add-edit.sh
index c6af7f82b..6c676645d 100755
--- a/t/t3702-add-edit.sh
+++ b/t/t3702-add-edit.sh
@@ -110,10 +110,10 @@ test_expect_success 'add -e' '
 	cp second-part file &&
 	git add -e &&
 	test_cmp second-part file &&
-	test_cmp orig-patch expected-patch &&
+	test_cmp expected-patch orig-patch &&
 	git diff --cached >actual &&
 	grep -v index actual >out &&
-	test_cmp out expected
+	test_cmp expected out
 
 '
 
diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh
index 6450bc669..cd216655b 100755
--- a/t/t3903-stash.sh
+++ b/t/t3903-stash.sh
@@ -36,7 +36,7 @@ EOF
 test_expect_success 'parents of stash' '
 	test $(git rev-parse stash^) = $(git rev-parse HEAD) &&
 	git diff stash^2..stash > output &&
-	test_cmp output expect
+	test_cmp expect output
 '
 
 test_expect_success 'applying bogus stash does nothing' '
@@ -210,9 +210,9 @@ test_expect_success 'stash branch' '
 	test refs/heads/stashbranch = $(git symbolic-ref HEAD) &&
 	test $(git rev-parse HEAD) = $(git rev-parse master^) &&
 	git diff --cached > output &&
-	test_cmp output expect &&
+	test_cmp expect output &&
 	git diff > output &&
-	test_cmp output expect1 &&
+	test_cmp expect1 output &&
 	git add file &&
 	git commit -m alternate\ second &&
 	git diff master..stashbranch > output &&
@@ -710,7 +710,7 @@ test_expect_success 'stash where working directory contains "HEAD" file' '
 	git diff-index --cached --quiet HEAD &&
 	test "$(git rev-parse stash^)" = "$(git rev-parse HEAD)" &&
 	git diff stash^..stash > output &&
-	test_cmp output expect
+	test_cmp expect output
 '
 
 test_expect_success 'store called with invalid commit' '
diff --git a/t/t3905-stash-include-untracked.sh b/t/t3905-stash-include-untracked.sh
index 597b0637d..cc1c8a7bb 100755
--- a/t/t3905-stash-include-untracked.sh
+++ b/t/t3905-stash-include-untracked.sh
@@ -142,7 +142,7 @@ test_expect_success 'stash save --include-untracked removed files' '
 	rm -f file &&
 	git stash save --include-untracked &&
 	echo 1 > expect &&
-	test_cmp file expect
+	test_cmp expect file
 '
 
 rm -f expect
diff --git a/t/t4025-hunk-header.sh b/t/t4025-hunk-header.sh
index fa44e7886..35578f2bb 100755
--- a/t/t4025-hunk-header.sh
+++ b/t/t4025-hunk-header.sh
@@ -37,7 +37,7 @@ test_expect_success 'hunk header truncation with an overly long line' '
 		echo " A $N$N$N$N$N$N$N$N$N2" &&
 		echo " L  $N$N$N$N$N$N$N$N$N1"
 	) >expected &&
-	test_cmp actual expected
+	test_cmp expected actual
 
 '
 
diff --git a/t/t4117-apply-reject.sh b/t/t4117-apply-reject.sh
index d80187de9..f7de6f077 100755
--- a/t/t4117-apply-reject.sh
+++ b/t/t4117-apply-reject.sh
@@ -72,7 +72,7 @@ test_expect_success 'apply with --reject should fail but update the file' '
 	rm -f file1.rej file2.rej &&
 
 	test_must_fail git apply --reject patch.1 &&
-	test_cmp file1 expected &&
+	test_cmp expected file1 &&
 
 	cat file1.rej &&
 	test_path_is_missing file2.rej
@@ -85,7 +85,7 @@ test_expect_success 'apply with --reject should fail but update the file' '
 
 	test_must_fail git apply --reject patch.2 >rejects &&
 	test_path_is_missing file1 &&
-	test_cmp file2 expected &&
+	test_cmp expected file2 &&
 
 	cat file2.rej &&
 	test_path_is_missing file1.rej
@@ -99,7 +99,7 @@ test_expect_success 'the same test with --verbose' '
 
 	test_must_fail git apply --reject --verbose patch.2 >rejects &&
 	test_path_is_missing file1 &&
-	test_cmp file2 expected &&
+	test_cmp expected file2 &&
 
 	cat file2.rej &&
 	test_path_is_missing file1.rej
diff --git a/t/t4124-apply-ws-rule.sh b/t/t4124-apply-ws-rule.sh
index 7e32237a2..ff51e9e78 100755
--- a/t/t4124-apply-ws-rule.sh
+++ b/t/t4124-apply-ws-rule.sh
@@ -313,9 +313,9 @@ test_expect_success 'applying beyond EOF requires one non-blank context line' '
 	{ echo a; echo; } >one &&
 	cp one expect &&
 	test_must_fail git apply --whitespace=fix patch &&
-	test_cmp one expect &&
+	test_cmp expect one &&
 	test_must_fail git apply --ignore-space-change --whitespace=fix patch &&
-	test_cmp one expect
+	test_cmp expect one
 '
 
 test_expect_success 'tons of blanks at EOF should not apply' '
@@ -342,10 +342,10 @@ test_expect_success 'missing blank line at end with --whitespace=fix' '
 	cp one saved-one &&
 	test_must_fail git apply patch &&
 	git apply --whitespace=fix patch &&
-	test_cmp one expect &&
+	test_cmp expect one &&
 	mv saved-one one &&
 	git apply --ignore-space-change --whitespace=fix patch &&
-	test_cmp one expect
+	test_cmp expect one
 '
 
 test_expect_success 'two missing blank lines at end with --whitespace=fix' '
@@ -360,11 +360,11 @@ test_expect_success 'two missing blank lines at end with --whitespace=fix' '
 	cp no-blank-lines one &&
 	test_must_fail git apply patch &&
 	git apply --whitespace=fix patch &&
-	test_cmp one expect &&
+	test_cmp expect one &&
 	mv no-blank-lines one &&
 	test_must_fail git apply patch &&
 	git apply --ignore-space-change --whitespace=fix patch &&
-	test_cmp one expect
+	test_cmp expect one
 '
 
 test_expect_success 'missing blank line at end, insert before end, --whitespace=fix' '
@@ -376,7 +376,7 @@ test_expect_success 'missing blank line at end, insert before end, --whitespace=
 	echo a >one &&
 	test_must_fail git apply patch &&
 	git apply --whitespace=fix patch &&
-	test_cmp one expect
+	test_cmp expect one
 '
 
 test_expect_success 'shrink file with tons of missing blanks at end of file' '
@@ -392,10 +392,10 @@ test_expect_success 'shrink file with tons of missing blanks at end of file' '
 	cp no-blank-lines one &&
 	test_must_fail git apply patch &&
 	git apply --whitespace=fix patch &&
-	test_cmp one expect &&
+	test_cmp expect one &&
 	mv no-blank-lines one &&
 	git apply --ignore-space-change --whitespace=fix patch &&
-	test_cmp one expect
+	test_cmp expect one
 '
 
 test_expect_success 'missing blanks at EOF must only match blank lines' '
@@ -427,7 +427,7 @@ test_expect_success 'missing blank line should match context line with spaces' '
 	git add one &&
 
 	git apply --whitespace=fix patch &&
-	test_cmp one expect
+	test_cmp expect one
 '
 
 sed -e's/Z//' >one <<EOF
@@ -447,7 +447,7 @@ test_expect_success 'same, but with the --ignore-space-option' '
 
 	git checkout-index -f one &&
 	git apply --ignore-space-change --whitespace=fix patch &&
-	test_cmp one expect
+	test_cmp expect one
 '
 
 test_expect_success 'same, but with CR-LF line endings && cr-at-eol set' '
@@ -464,7 +464,7 @@ test_expect_success 'same, but with CR-LF line endings && cr-at-eol set' '
 	mv save-one one &&
 
 	git apply --ignore-space-change --whitespace=fix patch &&
-	test_cmp one expect
+	test_cmp expect one
 '
 
 test_expect_success 'CR-LF line endings && add line && text=auto' '
@@ -478,7 +478,7 @@ test_expect_success 'CR-LF line endings && add line && text=auto' '
 	mv save-one one &&
 	echo "one text=auto" >.gitattributes &&
 	git apply patch &&
-	test_cmp one expect
+	test_cmp expect one
 '
 
 test_expect_success 'CR-LF line endings && change line && text=auto' '
@@ -491,7 +491,7 @@ test_expect_success 'CR-LF line endings && change line && text=auto' '
 	mv save-one one &&
 	echo "one text=auto" >.gitattributes &&
 	git apply patch &&
-	test_cmp one expect
+	test_cmp expect one
 '
 
 test_expect_success 'LF in repo, CRLF in worktree && change line && text=auto' '
@@ -503,7 +503,7 @@ test_expect_success 'LF in repo, CRLF in worktree && change line && text=auto' '
 	echo "one text=auto" >.gitattributes &&
 	git -c core.eol=CRLF apply patch &&
 	printf "b\r\n" >expect &&
-	test_cmp one expect
+	test_cmp expect one
 '
 
 test_expect_success 'whitespace=fix to expand' '
diff --git a/t/t4138-apply-ws-expansion.sh b/t/t4138-apply-ws-expansion.sh
index 0ffe33fbe..3b636a63a 100755
--- a/t/t4138-apply-ws-expansion.sh
+++ b/t/t4138-apply-ws-expansion.sh
@@ -114,7 +114,7 @@ for t in 1 2 3 4
 do
 	test_expect_success 'apply with ws expansion (t=$t)' '
 		git apply patch$t.patch &&
-		test_cmp test-$t expect-$t
+		test_cmp expect-$t test-$t
 	'
 done
 
diff --git a/t/t5317-pack-objects-filter-objects.sh b/t/t5317-pack-objects-filter-objects.sh
index ce69148ec..c093eb891 100755
--- a/t/t5317-pack-objects-filter-objects.sh
+++ b/t/t5317-pack-objects-filter-objects.sh
@@ -34,7 +34,7 @@ test_expect_success 'verify blob count in normal packfile' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify blob:none packfile has no blobs' '
@@ -63,7 +63,7 @@ test_expect_success 'verify normal and blob:none packfiles have same commits/tre
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 # Test blob:limit=<n>[kmg] filter.
@@ -96,7 +96,7 @@ test_expect_success 'verify blob count in normal packfile' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify blob:limit=500 omits all blobs' '
@@ -144,7 +144,7 @@ test_expect_success 'verify blob:limit=1001' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify blob:limit=10001' '
@@ -162,7 +162,7 @@ test_expect_success 'verify blob:limit=10001' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify blob:limit=1k' '
@@ -180,7 +180,7 @@ test_expect_success 'verify blob:limit=1k' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify explicitly specifying oversized blob in input' '
@@ -199,7 +199,7 @@ test_expect_success 'verify explicitly specifying oversized blob in input' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify blob:limit=1m' '
@@ -217,7 +217,7 @@ test_expect_success 'verify blob:limit=1m' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify normal and blob:limit packfiles have same commits/trees' '
@@ -231,7 +231,7 @@ test_expect_success 'verify normal and blob:limit packfiles have same commits/tr
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 # Test sparse:path=<path> filter.
@@ -269,7 +269,7 @@ test_expect_success 'verify blob count in normal packfile' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify sparse:path=pattern1' '
@@ -287,7 +287,7 @@ test_expect_success 'verify sparse:path=pattern1' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify normal and sparse:path=pattern1 packfiles have same commits/trees' '
@@ -301,7 +301,7 @@ test_expect_success 'verify normal and sparse:path=pattern1 packfiles have same
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify sparse:path=pattern2' '
@@ -319,7 +319,7 @@ test_expect_success 'verify sparse:path=pattern2' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify normal and sparse:path=pattern2 packfiles have same commits/trees' '
@@ -333,7 +333,7 @@ test_expect_success 'verify normal and sparse:path=pattern2 packfiles have same
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 # Test sparse:oid=<oid-ish> filter.
@@ -370,7 +370,7 @@ test_expect_success 'verify blob count in normal packfile' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify sparse:oid=OID' '
@@ -389,7 +389,7 @@ test_expect_success 'verify sparse:oid=OID' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify sparse:oid=oid-ish' '
@@ -407,7 +407,7 @@ test_expect_success 'verify sparse:oid=oid-ish' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 # Delete some loose objects and use pack-objects, but WITHOUT any filtering.
diff --git a/t/t5318-commit-graph.sh b/t/t5318-commit-graph.sh
index 0c500f7ca..d6da3ce4e 100755
--- a/t/t5318-commit-graph.sh
+++ b/t/t5318-commit-graph.sh
@@ -35,7 +35,7 @@ test_expect_success 'create commits and repack' '
 graph_git_two_modes() {
 	git -c core.commitGraph=true $1 >output
 	git -c core.commitGraph=false $1 >expect
-	test_cmp output expect
+	test_cmp expect output
 }
 
 graph_git_behavior() {
diff --git a/t/t5701-git-serve.sh b/t/t5701-git-serve.sh
index 75ec79e6c..bf139e245 100755
--- a/t/t5701-git-serve.sh
+++ b/t/t5701-git-serve.sh
@@ -16,7 +16,7 @@ test_expect_success 'test capability advertisement' '
 
 	git serve --advertise-capabilities >out &&
 	test-pkt-line unpack <out >actual &&
-	test_cmp actual expect
+	test_cmp expect actual
 '
 
 test_expect_success 'stateless-rpc flag does not list capabilities' '
@@ -89,7 +89,7 @@ test_expect_success 'basics of ls-refs' '
 
 	git serve --stateless-rpc <in >out &&
 	test-pkt-line unpack <out >actual &&
-	test_cmp actual expect
+	test_cmp expect actual
 '
 
 test_expect_success 'basic ref-prefixes' '
@@ -109,7 +109,7 @@ test_expect_success 'basic ref-prefixes' '
 
 	git serve --stateless-rpc <in >out &&
 	test-pkt-line unpack <out >actual &&
-	test_cmp actual expect
+	test_cmp expect actual
 '
 
 test_expect_success 'refs/heads prefix' '
@@ -129,7 +129,7 @@ test_expect_success 'refs/heads prefix' '
 
 	git serve --stateless-rpc <in >out &&
 	test-pkt-line unpack <out >actual &&
-	test_cmp actual expect
+	test_cmp expect actual
 '
 
 test_expect_success 'peel parameter' '
@@ -150,7 +150,7 @@ test_expect_success 'peel parameter' '
 
 	git serve --stateless-rpc <in >out &&
 	test-pkt-line unpack <out >actual &&
-	test_cmp actual expect
+	test_cmp expect actual
 '
 
 test_expect_success 'symrefs parameter' '
@@ -171,7 +171,7 @@ test_expect_success 'symrefs parameter' '
 
 	git serve --stateless-rpc <in >out &&
 	test-pkt-line unpack <out >actual &&
-	test_cmp actual expect
+	test_cmp expect actual
 '
 
 test_expect_success 'sending server-options' '
@@ -191,7 +191,7 @@ test_expect_success 'sending server-options' '
 
 	git serve --stateless-rpc <in >out &&
 	test-pkt-line unpack <out >actual &&
-	test_cmp actual expect
+	test_cmp expect actual
 '
 
 test_expect_success 'unexpected lines are not allowed in fetch request' '
diff --git a/t/t5702-protocol-v2.sh b/t/t5702-protocol-v2.sh
index 3beeed454..54727450b 100755
--- a/t/t5702-protocol-v2.sh
+++ b/t/t5702-protocol-v2.sh
@@ -29,7 +29,7 @@ test_expect_success 'list refs with git:// using protocol v2' '
 	grep "git< version 2" log &&
 
 	git ls-remote --symref "$GIT_DAEMON_URL/parent" >expect &&
-	test_cmp actual expect
+	test_cmp expect actual
 '
 
 test_expect_success 'ref advertisment is filtered with ls-remote using protocol v2' '
@@ -42,7 +42,7 @@ test_expect_success 'ref advertisment is filtered with ls-remote using protocol
 	$(git -C "$daemon_parent" rev-parse refs/heads/master)$(printf "\t")refs/heads/master
 	EOF
 
-	test_cmp actual expect
+	test_cmp expect actual
 '
 
 test_expect_success 'clone with git:// using protocol v2' '
@@ -138,7 +138,7 @@ test_expect_success 'list refs with file:// using protocol v2' '
 	grep "git< version 2" log &&
 
 	git ls-remote --symref "file://$(pwd)/file_parent" >expect &&
-	test_cmp actual expect
+	test_cmp expect actual
 '
 
 test_expect_success 'ref advertisment is filtered with ls-remote using protocol v2' '
@@ -151,7 +151,7 @@ test_expect_success 'ref advertisment is filtered with ls-remote using protocol
 	$(git -C file_parent rev-parse refs/heads/master)$(printf "\t")refs/heads/master
 	EOF
 
-	test_cmp actual expect
+	test_cmp expect actual
 '
 
 test_expect_success 'server-options are sent when using ls-remote' '
@@ -164,7 +164,7 @@ test_expect_success 'server-options are sent when using ls-remote' '
 	$(git -C file_parent rev-parse refs/heads/master)$(printf "\t")refs/heads/master
 	EOF
 
-	test_cmp actual expect &&
+	test_cmp expect actual &&
 	grep "server-option=hello" log &&
 	grep "server-option=world" log
 '
diff --git a/t/t6023-merge-file.sh b/t/t6023-merge-file.sh
index 20aee43f9..51ee887a7 100755
--- a/t/t6023-merge-file.sh
+++ b/t/t6023-merge-file.sh
@@ -99,7 +99,7 @@ EOF
 printf "propter nomen suum." >> expect.txt
 
 test_expect_success "merge does not add LF away of change" \
-	"test_cmp test3.txt expect.txt"
+	"test_cmp expect.txt test3.txt"
 
 cp test.txt backup.txt
 test_expect_success "merge with conflicts" \
@@ -122,7 +122,7 @@ non timebo mala, quoniam tu mecum es:
 virga tua et baculus tuus ipsa me consolata sunt.
 EOF
 
-test_expect_success "expected conflict markers" "test_cmp test.txt expect.txt"
+test_expect_success "expected conflict markers" "test_cmp expect.txt test.txt"
 
 cp backup.txt test.txt
 
@@ -138,7 +138,7 @@ non timebo mala, quoniam tu mecum es:
 virga tua et baculus tuus ipsa me consolata sunt.
 EOF
 test_expect_success "merge conflicting with --ours" \
-	"git merge-file --ours test.txt orig.txt new3.txt && test_cmp test.txt expect.txt"
+	"git merge-file --ours test.txt orig.txt new3.txt && test_cmp expect.txt test.txt"
 cp backup.txt test.txt
 
 cat > expect.txt << EOF
@@ -154,7 +154,7 @@ non timebo mala, quoniam tu mecum es:
 virga tua et baculus tuus ipsa me consolata sunt.
 EOF
 test_expect_success "merge conflicting with --theirs" \
-	"git merge-file --theirs test.txt orig.txt new3.txt && test_cmp test.txt expect.txt"
+	"git merge-file --theirs test.txt orig.txt new3.txt && test_cmp expect.txt test.txt"
 cp backup.txt test.txt
 
 cat > expect.txt << EOF
@@ -171,7 +171,7 @@ non timebo mala, quoniam tu mecum es:
 virga tua et baculus tuus ipsa me consolata sunt.
 EOF
 test_expect_success "merge conflicting with --union" \
-	"git merge-file --union test.txt orig.txt new3.txt && test_cmp test.txt expect.txt"
+	"git merge-file --union test.txt orig.txt new3.txt && test_cmp expect.txt test.txt"
 cp backup.txt test.txt
 
 test_expect_success "merge with conflicts, using -L" \
@@ -195,7 +195,7 @@ virga tua et baculus tuus ipsa me consolata sunt.
 EOF
 
 test_expect_success "expected conflict markers, with -L" \
-	"test_cmp test.txt expect.txt"
+	"test_cmp expect.txt test.txt"
 
 sed "s/ tu / TU /" < new1.txt > new5.txt
 test_expect_success "conflict in removed tail" \
diff --git a/t/t6027-merge-binary.sh b/t/t6027-merge-binary.sh
index 07735410b..4e6c7cb77 100755
--- a/t/t6027-merge-binary.sh
+++ b/t/t6027-merge-binary.sh
@@ -45,7 +45,7 @@ test_expect_success resolve '
 		false
 	else
 		git ls-files -s >current
-		test_cmp current expect
+		test_cmp expect current
 	fi
 '
 
@@ -60,7 +60,7 @@ test_expect_success recursive '
 		false
 	else
 		git ls-files -s >current
-		test_cmp current expect
+		test_cmp expect current
 	fi
 '
 
diff --git a/t/t6031-merge-filemode.sh b/t/t6031-merge-filemode.sh
index 7d06461f1..87741efad 100755
--- a/t/t6031-merge-filemode.sh
+++ b/t/t6031-merge-filemode.sh
@@ -61,7 +61,7 @@ do_both_modes () {
 		git checkout -f a2 &&
 		test_must_fail git merge -s $strategy b2 &&
 		git ls-files -u >actual &&
-		test_cmp actual expect &&
+		test_cmp expect actual &&
 		git ls-files -s file2 | grep ^100755
 	'
 
diff --git a/t/t6112-rev-list-filters-objects.sh b/t/t6112-rev-list-filters-objects.sh
index 0f6b569e1..ae4402226 100755
--- a/t/t6112-rev-list-filters-objects.sh
+++ b/t/t6112-rev-list-filters-objects.sh
@@ -29,7 +29,7 @@ test_expect_success 'verify blob:none omits all 5 blobs' '
 	sed "s/~//" |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify emitted+omitted == all' '
@@ -42,7 +42,7 @@ test_expect_success 'verify emitted+omitted == all' '
 	sed "s/~//" |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 
@@ -71,7 +71,7 @@ test_expect_success 'verify blob:limit=500 omits all blobs' '
 	sed "s/~//" |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify emitted+omitted == all' '
@@ -84,7 +84,7 @@ test_expect_success 'verify emitted+omitted == all' '
 	sed "s/~//" |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify blob:limit=1000' '
@@ -97,7 +97,7 @@ test_expect_success 'verify blob:limit=1000' '
 	sed "s/~//" |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify blob:limit=1001' '
@@ -110,7 +110,7 @@ test_expect_success 'verify blob:limit=1001' '
 	sed "s/~//" |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify blob:limit=1k' '
@@ -123,7 +123,7 @@ test_expect_success 'verify blob:limit=1k' '
 	sed "s/~//" |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify blob:limit=1m' '
@@ -165,7 +165,7 @@ test_expect_success 'verify sparse:path=pattern1 omits top-level files' '
 	sed "s/~//" |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify sparse:path=pattern2 omits both sparse2 files' '
@@ -178,7 +178,7 @@ test_expect_success 'verify sparse:path=pattern2 omits both sparse2 files' '
 	sed "s/~//" |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 # Test sparse:oid=<oid-ish> filter.
@@ -203,7 +203,7 @@ test_expect_success 'verify sparse:oid=OID omits top-level files' '
 	sed "s/~//" |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify sparse:oid=oid-ish omits top-level files' '
@@ -216,7 +216,7 @@ test_expect_success 'verify sparse:oid=oid-ish omits top-level files' '
 	sed "s/~//" |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 # Delete some loose objects and use rev-list, but WITHOUT any filtering.
@@ -237,7 +237,7 @@ test_expect_success 'rev-list W/ --missing=print' '
 	sed "s/?//" |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'rev-list W/O --missing fails' '
diff --git a/t/t7201-co.sh b/t/t7201-co.sh
index 324933acf..826987ca8 100755
--- a/t/t7201-co.sh
+++ b/t/t7201-co.sh
@@ -160,7 +160,7 @@ test_expect_success 'checkout -m with merge conflict' '
 	git diff master:one :3:uno |
 	sed -e "1,/^@@/d" -e "/^ /d" -e "s/^-/d/" -e "s/^+/a/" >current &&
 	fill d2 aT d7 aS >expect &&
-	test_cmp current expect &&
+	test_cmp expect current &&
 	git diff --cached two >current &&
 	test_must_be_empty current
 '
@@ -174,7 +174,7 @@ test_expect_success 'format of merge conflict from checkout -m' '
 
 	git ls-files >current &&
 	fill same two two two >expect &&
-	test_cmp current expect &&
+	test_cmp expect current &&
 
 	cat <<-EOF >expect &&
 	<<<<<<< simple
diff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh
index 10dc91620..e87164aa8 100755
--- a/t/t7406-submodule-update.sh
+++ b/t/t7406-submodule-update.sh
@@ -789,7 +789,7 @@ test_expect_success 'submodule add places git-dir in superprojects git-dir' '
 	 (cd .git/modules/deeper/submodule &&
 	  git log > ../../../../actual
 	 ) &&
-	 test_cmp actual expected
+	 test_cmp expected actual
 	)
 '
 
@@ -807,7 +807,7 @@ test_expect_success 'submodule update places git-dir in superprojects git-dir' '
 	 (cd .git/modules/deeper/submodule &&
 	  git log > ../../../../actual
 	 ) &&
-	 test_cmp actual expected
+	 test_cmp expected actual
 	)
 '
 
@@ -827,7 +827,7 @@ test_expect_success 'submodule add places git-dir in superprojects git-dir recur
 	 git add deeper/submodule &&
 	 git commit -m "update submodule" &&
 	 git push origin : &&
-	 test_cmp actual expected
+	 test_cmp expected actual
 	)
 '
 
@@ -874,7 +874,7 @@ test_expect_success 'submodule update places git-dir in superprojects git-dir re
 	 (cd .git/modules/submodule/modules/subsubmodule &&
 	  git log > ../../../../../actual
 	 ) &&
-	 test_cmp actual expected
+	 test_cmp expected actual
 	)
 '
 
diff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh
index 668bbee73..562bd215a 100755
--- a/t/t7800-difftool.sh
+++ b/t/t7800-difftool.sh
@@ -557,7 +557,7 @@ test_expect_success SYMLINKS 'difftool --dir-diff --symlink without unstaged cha
 	EOF
 	git difftool --dir-diff --symlink \
 		--extcmd "./.git/CHECK_SYMLINKS" branch HEAD &&
-	test_cmp actual expect
+	test_cmp expect actual
 '
 
 write_script modify-right-file <<\EOF
diff --git a/t/t9100-git-svn-basic.sh b/t/t9100-git-svn-basic.sh
index 9af607884..2c309a57d 100755
--- a/t/t9100-git-svn-basic.sh
+++ b/t/t9100-git-svn-basic.sh
@@ -221,7 +221,7 @@ tree d667270a1f7b109f5eb3aaea21ede14b56bfdd6e
 tree 8f51f74cf0163afc9ad68a4b1537288c4558b5a4
 EOF
 
-test_expect_success POSIXPERM,SYMLINKS "$name" "test_cmp a expected"
+test_expect_success POSIXPERM,SYMLINKS "$name" "test_cmp expected a"
 
 test_expect_success 'exit if remote refs are ambigious' '
         git config --add svn-remote.svn.fetch \
diff --git a/t/t9133-git-svn-nested-git-repo.sh b/t/t9133-git-svn-nested-git-repo.sh
index f3c30e63b..f89486086 100755
--- a/t/t9133-git-svn-nested-git-repo.sh
+++ b/t/t9133-git-svn-nested-git-repo.sh
@@ -45,7 +45,7 @@ test_expect_success 'update git svn-cloned repo' '
 		git svn rebase &&
 		echo a > expect &&
 		echo b >> expect &&
-		test_cmp a expect &&
+		test_cmp expect a &&
 		rm expect
 	)
 '
@@ -69,7 +69,7 @@ test_expect_success 'update git svn-cloned repo' '
 		git svn rebase &&
 		echo a > expect &&
 		echo b >> expect &&
-		test_cmp a expect &&
+		test_cmp expect a &&
 		rm expect
 	)
 '
@@ -93,7 +93,7 @@ test_expect_success 'update git svn-cloned repo again' '
 		echo a > expect &&
 		echo b >> expect &&
 		echo c >> expect &&
-		test_cmp a expect &&
+		test_cmp expect a &&
 		rm expect
 	)
 '
diff --git a/t/t9600-cvsimport.sh b/t/t9600-cvsimport.sh
index 5dfee07d9..251fdd66c 100755
--- a/t/t9600-cvsimport.sh
+++ b/t/t9600-cvsimport.sh
@@ -148,7 +148,7 @@ test_expect_success PERL 'import from a CVS working tree' '
 		git cvsimport -a -z0 &&
 		echo 1 >expect &&
 		git log -1 --pretty=format:%s%n >actual &&
-		test_cmp actual expect
+		test_cmp expect actual
 	)
 
 '
diff --git a/t/t9603-cvsimport-patchsets.sh b/t/t9603-cvsimport-patchsets.sh
index c4c3c4954..3e64b11ea 100755
--- a/t/t9603-cvsimport-patchsets.sh
+++ b/t/t9603-cvsimport-patchsets.sh
@@ -29,11 +29,11 @@ test_expect_failure PERL 'import with criss cross times on revisions' '
 Rev 3
 Rev 2
 Rev 1" > expect-master &&
-    test_cmp actual-master expect-master &&
+    test_cmp expect-master actual-master &&
 
     echo "Rev 5 Branch A Wed Mar 11 19:09:10 2009 +0000
 Rev 4 Branch A Wed Mar 11 19:03:52 2009 +0000" > expect-A &&
-    test_cmp actual-A expect-A
+    test_cmp expect-A actual-A
 '
 
 test_done
diff --git a/t/t9604-cvsimport-timestamps.sh b/t/t9604-cvsimport-timestamps.sh
index a4b3db24b..2ff4aa932 100755
--- a/t/t9604-cvsimport-timestamps.sh
+++ b/t/t9604-cvsimport-timestamps.sh
@@ -31,7 +31,7 @@ test_expect_success PERL 'check timestamps are UTC (TZ=CST6CDT)' '
 	Rev  2 2005-02-01 00:00:00 +0000
 	Rev  1 2005-01-01 00:00:00 +0000
 	EOF
-	test_cmp actual-1 expect-1
+	test_cmp expect-1 actual-1
 '
 
 test_expect_success PERL 'check timestamps with author-specific timezones' '
@@ -65,7 +65,7 @@ test_expect_success PERL 'check timestamps with author-specific timezones' '
 	Rev  2 2005-01-31 18:00:00 -0600 User Two
 	Rev  1 2005-01-01 00:00:00 +0000 User One
 	EOF
-	test_cmp actual-2 expect-2
+	test_cmp expect-2 actual-2
 '
 
 test_done
-- 
2.19.0.444.g18242da7ef-goog


^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [PATCH v3 4/5] tests: don't swallow Git errors upstream of pipes
  2018-09-21  1:43 ` [PATCH v3 0/5] Clean up tests for test_cmp arg ordering and pipe placement Matthew DeVore
                     ` (2 preceding siblings ...)
  2018-09-21  1:43   ` [PATCH v3 3/5] t/*: fix ordering of expected/observed arguments Matthew DeVore
@ 2018-09-21  1:43   ` Matthew DeVore
  2018-09-21  1:43   ` [PATCH v3 5/5] t9109: " Matthew DeVore
  4 siblings, 0 replies; 66+ messages in thread
From: Matthew DeVore @ 2018-09-21  1:43 UTC (permalink / raw)
  To: git; +Cc: Matthew DeVore, peff, jonathantanmy, gitster, jrn, sunshine

Some pipes in tests lose the exit code of git processes, which can mask
unexpected behavior like crashes. Split these pipes up so that git
commands are only at the end of pipes rather than the beginning or
middle.

The violations fixed in this patch were found in the process of fixing
pipe placement in a prior patch.

Signed-off-by: Matthew DeVore <matvore@google.com>
---
 t/t5317-pack-objects-filter-objects.sh | 156 +++++++++++++------------
 t/t5616-partial-clone.sh               |  14 ++-
 t/t6112-rev-list-filters-objects.sh    | 103 ++++++++--------
 t/t9101-git-svn-props.sh               |   3 +-
 4 files changed, 143 insertions(+), 133 deletions(-)

diff --git a/t/t5317-pack-objects-filter-objects.sh b/t/t5317-pack-objects-filter-objects.sh
index c093eb891..2e718f0bd 100755
--- a/t/t5317-pack-objects-filter-objects.sh
+++ b/t/t5317-pack-objects-filter-objects.sh
@@ -20,8 +20,9 @@ test_expect_success 'setup r1' '
 '
 
 test_expect_success 'verify blob count in normal packfile' '
-	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 |
-	awk -f print_2.awk |
+	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 \
+		>ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	git -C r1 pack-objects --rev --stdout >all.pack <<-EOF &&
@@ -29,8 +30,8 @@ test_expect_success 'verify blob count in normal packfile' '
 	EOF
 	git -C r1 index-pack ../all.pack &&
 
-	git -C r1 verify-pack -v ../all.pack |
-	grep blob |
+	git -C r1 verify-pack -v ../all.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -43,8 +44,8 @@ test_expect_success 'verify blob:none packfile has no blobs' '
 	EOF
 	git -C r1 index-pack ../filter.pack &&
 
-	git -C r1 verify-pack -v ../filter.pack |
-	grep blob |
+	git -C r1 verify-pack -v ../filter.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -53,13 +54,13 @@ test_expect_success 'verify blob:none packfile has no blobs' '
 '
 
 test_expect_success 'verify normal and blob:none packfiles have same commits/trees' '
-	git -C r1 verify-pack -v ../all.pack |
-	grep -E "commit|tree" |
+	git -C r1 verify-pack -v ../all.pack >verify_result &&
+	grep -E "commit|tree" verify_result |
 	awk -f print_1.awk |
 	sort >expected &&
 
-	git -C r1 verify-pack -v ../filter.pack |
-	grep -E "commit|tree" |
+	git -C r1 verify-pack -v ../filter.pack >verify_result &&
+	grep -E "commit|tree" verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -82,8 +83,8 @@ test_expect_success 'setup r2' '
 '
 
 test_expect_success 'verify blob count in normal packfile' '
-	git -C r2 ls-files -s large.1000 large.10000 |
-	awk -f print_2.awk |
+	git -C r2 ls-files -s large.1000 large.10000 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	git -C r2 pack-objects --rev --stdout >all.pack <<-EOF &&
@@ -91,8 +92,8 @@ test_expect_success 'verify blob count in normal packfile' '
 	EOF
 	git -C r2 index-pack ../all.pack &&
 
-	git -C r2 verify-pack -v ../all.pack |
-	grep blob |
+	git -C r2 verify-pack -v ../all.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -105,8 +106,8 @@ test_expect_success 'verify blob:limit=500 omits all blobs' '
 	EOF
 	git -C r2 index-pack ../filter.pack &&
 
-	git -C r2 verify-pack -v ../filter.pack |
-	grep blob |
+	git -C r2 verify-pack -v ../filter.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -120,8 +121,8 @@ test_expect_success 'verify blob:limit=1000' '
 	EOF
 	git -C r2 index-pack ../filter.pack &&
 
-	git -C r2 verify-pack -v ../filter.pack |
-	grep blob |
+	git -C r2 verify-pack -v ../filter.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -130,8 +131,8 @@ test_expect_success 'verify blob:limit=1000' '
 '
 
 test_expect_success 'verify blob:limit=1001' '
-	git -C r2 ls-files -s large.1000 |
-	awk -f print_2.awk |
+	git -C r2 ls-files -s large.1000 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	git -C r2 pack-objects --rev --stdout --filter=blob:limit=1001 >filter.pack <<-EOF &&
@@ -139,8 +140,8 @@ test_expect_success 'verify blob:limit=1001' '
 	EOF
 	git -C r2 index-pack ../filter.pack &&
 
-	git -C r2 verify-pack -v ../filter.pack |
-	grep blob |
+	git -C r2 verify-pack -v ../filter.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -148,8 +149,8 @@ test_expect_success 'verify blob:limit=1001' '
 '
 
 test_expect_success 'verify blob:limit=10001' '
-	git -C r2 ls-files -s large.1000 large.10000 |
-	awk -f print_2.awk |
+	git -C r2 ls-files -s large.1000 large.10000 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	git -C r2 pack-objects --rev --stdout --filter=blob:limit=10001 >filter.pack <<-EOF &&
@@ -157,8 +158,8 @@ test_expect_success 'verify blob:limit=10001' '
 	EOF
 	git -C r2 index-pack ../filter.pack &&
 
-	git -C r2 verify-pack -v ../filter.pack |
-	grep blob |
+	git -C r2 verify-pack -v ../filter.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -166,8 +167,8 @@ test_expect_success 'verify blob:limit=10001' '
 '
 
 test_expect_success 'verify blob:limit=1k' '
-	git -C r2 ls-files -s large.1000 |
-	awk -f print_2.awk |
+	git -C r2 ls-files -s large.1000 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	git -C r2 pack-objects --rev --stdout --filter=blob:limit=1k >filter.pack <<-EOF &&
@@ -175,8 +176,8 @@ test_expect_success 'verify blob:limit=1k' '
 	EOF
 	git -C r2 index-pack ../filter.pack &&
 
-	git -C r2 verify-pack -v ../filter.pack |
-	grep blob |
+	git -C r2 verify-pack -v ../filter.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -184,8 +185,8 @@ test_expect_success 'verify blob:limit=1k' '
 '
 
 test_expect_success 'verify explicitly specifying oversized blob in input' '
-	git -C r2 ls-files -s large.1000 large.10000 |
-	awk -f print_2.awk |
+	git -C r2 ls-files -s large.1000 large.10000 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	git -C r2 pack-objects --rev --stdout --filter=blob:limit=1k >filter.pack <<-EOF &&
@@ -194,8 +195,8 @@ test_expect_success 'verify explicitly specifying oversized blob in input' '
 	EOF
 	git -C r2 index-pack ../filter.pack &&
 
-	git -C r2 verify-pack -v ../filter.pack |
-	grep blob |
+	git -C r2 verify-pack -v ../filter.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -203,8 +204,8 @@ test_expect_success 'verify explicitly specifying oversized blob in input' '
 '
 
 test_expect_success 'verify blob:limit=1m' '
-	git -C r2 ls-files -s large.1000 large.10000 |
-	awk -f print_2.awk |
+	git -C r2 ls-files -s large.1000 large.10000 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	git -C r2 pack-objects --rev --stdout --filter=blob:limit=1m >filter.pack <<-EOF &&
@@ -212,8 +213,8 @@ test_expect_success 'verify blob:limit=1m' '
 	EOF
 	git -C r2 index-pack ../filter.pack &&
 
-	git -C r2 verify-pack -v ../filter.pack |
-	grep blob |
+	git -C r2 verify-pack -v ../filter.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -221,13 +222,13 @@ test_expect_success 'verify blob:limit=1m' '
 '
 
 test_expect_success 'verify normal and blob:limit packfiles have same commits/trees' '
-	git -C r2 verify-pack -v ../all.pack |
-	grep -E "commit|tree" |
+	git -C r2 verify-pack -v ../all.pack >verify_result &&
+	grep -E "commit|tree" verify_result |
 	awk -f print_1.awk |
 	sort >expected &&
 
-	git -C r2 verify-pack -v ../filter.pack |
-	grep -E "commit|tree" |
+	git -C r2 verify-pack -v ../filter.pack >verify_result &&
+	grep -E "commit|tree" verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -255,8 +256,9 @@ test_expect_success 'setup r3' '
 '
 
 test_expect_success 'verify blob count in normal packfile' '
-	git -C r3 ls-files -s sparse1 sparse2 dir1/sparse1 dir1/sparse2 |
-	awk -f print_2.awk |
+	git -C r3 ls-files -s sparse1 sparse2 dir1/sparse1 dir1/sparse2 \
+		>ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	git -C r3 pack-objects --rev --stdout >all.pack <<-EOF &&
@@ -264,8 +266,8 @@ test_expect_success 'verify blob count in normal packfile' '
 	EOF
 	git -C r3 index-pack ../all.pack &&
 
-	git -C r3 verify-pack -v ../all.pack |
-	grep blob |
+	git -C r3 verify-pack -v ../all.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -273,8 +275,8 @@ test_expect_success 'verify blob count in normal packfile' '
 '
 
 test_expect_success 'verify sparse:path=pattern1' '
-	git -C r3 ls-files -s dir1/sparse1 dir1/sparse2 |
-	awk -f print_2.awk |
+	git -C r3 ls-files -s dir1/sparse1 dir1/sparse2 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	git -C r3 pack-objects --rev --stdout --filter=sparse:path=../pattern1 >filter.pack <<-EOF &&
@@ -282,8 +284,8 @@ test_expect_success 'verify sparse:path=pattern1' '
 	EOF
 	git -C r3 index-pack ../filter.pack &&
 
-	git -C r3 verify-pack -v ../filter.pack |
-	grep blob |
+	git -C r3 verify-pack -v ../filter.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -291,13 +293,13 @@ test_expect_success 'verify sparse:path=pattern1' '
 '
 
 test_expect_success 'verify normal and sparse:path=pattern1 packfiles have same commits/trees' '
-	git -C r3 verify-pack -v ../all.pack |
-	grep -E "commit|tree" |
+	git -C r3 verify-pack -v ../all.pack >verify_result &&
+	grep -E "commit|tree" verify_result |
 	awk -f print_1.awk |
 	sort >expected &&
 
-	git -C r3 verify-pack -v ../filter.pack |
-	grep -E "commit|tree" |
+	git -C r3 verify-pack -v ../filter.pack >verify_result &&
+	grep -E "commit|tree" verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -305,8 +307,8 @@ test_expect_success 'verify normal and sparse:path=pattern1 packfiles have same
 '
 
 test_expect_success 'verify sparse:path=pattern2' '
-	git -C r3 ls-files -s sparse1 dir1/sparse1 |
-	awk -f print_2.awk |
+	git -C r3 ls-files -s sparse1 dir1/sparse1 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	git -C r3 pack-objects --rev --stdout --filter=sparse:path=../pattern2 >filter.pack <<-EOF &&
@@ -314,8 +316,8 @@ test_expect_success 'verify sparse:path=pattern2' '
 	EOF
 	git -C r3 index-pack ../filter.pack &&
 
-	git -C r3 verify-pack -v ../filter.pack |
-	grep blob |
+	git -C r3 verify-pack -v ../filter.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -323,13 +325,13 @@ test_expect_success 'verify sparse:path=pattern2' '
 '
 
 test_expect_success 'verify normal and sparse:path=pattern2 packfiles have same commits/trees' '
-	git -C r3 verify-pack -v ../all.pack |
-	grep -E "commit|tree" |
+	git -C r3 verify-pack -v ../all.pack >verify_result &&
+	grep -E "commit|tree" verify_result |
 	awk -f print_1.awk |
 	sort >expected &&
 
-	git -C r3 verify-pack -v ../filter.pack |
-	grep -E "commit|tree" |
+	git -C r3 verify-pack -v ../filter.pack >verify_result &&
+	grep -E "commit|tree" verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -356,8 +358,9 @@ test_expect_success 'setup r4' '
 '
 
 test_expect_success 'verify blob count in normal packfile' '
-	git -C r4 ls-files -s pattern sparse1 sparse2 dir1/sparse1 dir1/sparse2 |
-	awk -f print_2.awk |
+	git -C r4 ls-files -s pattern sparse1 sparse2 dir1/sparse1 dir1/sparse2 \
+		>ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	git -C r4 pack-objects --rev --stdout >all.pack <<-EOF &&
@@ -365,8 +368,8 @@ test_expect_success 'verify blob count in normal packfile' '
 	EOF
 	git -C r4 index-pack ../all.pack &&
 
-	git -C r4 verify-pack -v ../all.pack |
-	grep blob |
+	git -C r4 verify-pack -v ../all.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -374,8 +377,8 @@ test_expect_success 'verify blob count in normal packfile' '
 '
 
 test_expect_success 'verify sparse:oid=OID' '
-	git -C r4 ls-files -s dir1/sparse1 dir1/sparse2 |
-	awk -f print_2.awk |
+	git -C r4 ls-files -s dir1/sparse1 dir1/sparse2 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	oid=$(git -C r4 ls-files -s pattern | awk -f print_2.awk) &&
@@ -384,8 +387,8 @@ test_expect_success 'verify sparse:oid=OID' '
 	EOF
 	git -C r4 index-pack ../filter.pack &&
 
-	git -C r4 verify-pack -v ../filter.pack |
-	grep blob |
+	git -C r4 verify-pack -v ../filter.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -393,8 +396,8 @@ test_expect_success 'verify sparse:oid=OID' '
 '
 
 test_expect_success 'verify sparse:oid=oid-ish' '
-	git -C r4 ls-files -s dir1/sparse1 dir1/sparse2 |
-	awk -f print_2.awk |
+	git -C r4 ls-files -s dir1/sparse1 dir1/sparse2 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	git -C r4 pack-objects --rev --stdout --filter=sparse:oid=master:pattern >filter.pack <<-EOF &&
@@ -402,8 +405,8 @@ test_expect_success 'verify sparse:oid=oid-ish' '
 	EOF
 	git -C r4 index-pack ../filter.pack &&
 
-	git -C r4 verify-pack -v ../filter.pack |
-	grep blob |
+	git -C r4 verify-pack -v ../filter.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -414,8 +417,9 @@ test_expect_success 'verify sparse:oid=oid-ish' '
 # This models previously omitted objects that we did not receive.
 
 test_expect_success 'setup r1 - delete loose blobs' '
-	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 |
-	awk -f print_2.awk |
+	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 \
+		>ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	for id in `cat expected | sed "s|..|&/|"`
diff --git a/t/t5616-partial-clone.sh b/t/t5616-partial-clone.sh
index e4d032c9d..fc7aeb1ab 100755
--- a/t/t5616-partial-clone.sh
+++ b/t/t5616-partial-clone.sh
@@ -35,8 +35,8 @@ test_expect_success 'setup bare clone for server' '
 test_expect_success 'do partial clone 1' '
 	git clone --no-checkout --filter=blob:none "file://$(pwd)/srv.bare" pc1 &&
 
-	git -C pc1 rev-list HEAD --quiet --objects --missing=print |
-	awk -f print_1.awk |
+	git -C pc1 rev-list HEAD --quiet --objects --missing=print >revs &&
+	awk -f print_1.awk revs |
 	sed "s/?//" |
 	sort >observed.oids &&
 
@@ -133,16 +133,18 @@ test_expect_success 'push new commits to server for file.3.txt' '
 test_expect_success 'manual prefetch of missing objects' '
 	git -C pc1 fetch --filter=blob:none origin &&
 
-	git -C pc1 rev-list master..origin/master --quiet --objects --missing=print |
-	awk -f print_1.awk |
+	git -C pc1 rev-list master..origin/master --quiet --objects --missing=print \
+		>revs &&
+	awk -f print_1.awk revs |
 	sed "s/?//" |
 	sort >observed.oids &&
 
 	test_line_count = 6 observed.oids &&
 	git -C pc1 fetch-pack --stdin "file://$(pwd)/srv.bare" <observed.oids &&
 
-	git -C pc1 rev-list master..origin/master --quiet --objects --missing=print |
-	awk -f print_1.awk |
+	git -C pc1 rev-list master..origin/master --quiet --objects --missing=print \
+		>revs &&
+	awk -f print_1.awk revs |
 	sed "s/?//" |
 	sort >observed.oids &&
 
diff --git a/t/t6112-rev-list-filters-objects.sh b/t/t6112-rev-list-filters-objects.sh
index ae4402226..b00cf6fa8 100755
--- a/t/t6112-rev-list-filters-objects.sh
+++ b/t/t6112-rev-list-filters-objects.sh
@@ -20,12 +20,13 @@ test_expect_success 'setup r1' '
 '
 
 test_expect_success 'verify blob:none omits all 5 blobs' '
-	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 |
-	awk -f print_2.awk |
+	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 \
+		>ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
-	git -C r1 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:none |
-	awk -f print_1.awk |
+	git -C r1 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:none >revs &&
+	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
 
@@ -33,12 +34,13 @@ test_expect_success 'verify blob:none omits all 5 blobs' '
 '
 
 test_expect_success 'verify emitted+omitted == all' '
-	git -C r1 rev-list HEAD --objects |
-	awk -f print_1.awk |
+	git -C r1 rev-list HEAD --objects >revs &&
+	awk -f print_1.awk revs |
 	sort >expected &&
 
-	git -C r1 rev-list HEAD --objects --filter-print-omitted --filter=blob:none |
-	awk -f print_1.awk |
+	git -C r1 rev-list HEAD --objects --filter-print-omitted --filter=blob:none \
+		>revs &&
+	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
 
@@ -62,12 +64,12 @@ test_expect_success 'setup r2' '
 '
 
 test_expect_success 'verify blob:limit=500 omits all blobs' '
-	git -C r2 ls-files -s large.1000 large.10000 |
-	awk -f print_2.awk |
+	git -C r2 ls-files -s large.1000 large.10000 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
-	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=500 |
-	awk -f print_1.awk |
+	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=500 >revs &&
+	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
 
@@ -75,12 +77,12 @@ test_expect_success 'verify blob:limit=500 omits all blobs' '
 '
 
 test_expect_success 'verify emitted+omitted == all' '
-	git -C r2 rev-list HEAD --objects |
-	awk -f print_1.awk |
+	git -C r2 rev-list HEAD --objects >revs &&
+	awk -f print_1.awk revs |
 	sort >expected &&
 
-	git -C r2 rev-list HEAD --objects --filter-print-omitted --filter=blob:limit=500 |
-	awk -f print_1.awk |
+	git -C r2 rev-list HEAD --objects --filter-print-omitted --filter=blob:limit=500 >revs &&
+	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
 
@@ -88,12 +90,12 @@ test_expect_success 'verify emitted+omitted == all' '
 '
 
 test_expect_success 'verify blob:limit=1000' '
-	git -C r2 ls-files -s large.1000 large.10000 |
-	awk -f print_2.awk |
+	git -C r2 ls-files -s large.1000 large.10000 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
-	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1000 |
-	awk -f print_1.awk |
+	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1000 >revs &&
+	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
 
@@ -101,12 +103,12 @@ test_expect_success 'verify blob:limit=1000' '
 '
 
 test_expect_success 'verify blob:limit=1001' '
-	git -C r2 ls-files -s large.10000 |
-	awk -f print_2.awk |
+	git -C r2 ls-files -s large.10000 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
-	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1001 |
-	awk -f print_1.awk |
+	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1001 >revs &&
+	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
 
@@ -114,12 +116,12 @@ test_expect_success 'verify blob:limit=1001' '
 '
 
 test_expect_success 'verify blob:limit=1k' '
-	git -C r2 ls-files -s large.10000 |
-	awk -f print_2.awk |
+	git -C r2 ls-files -s large.10000 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
-	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1k |
-	awk -f print_1.awk |
+	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1k >revs &&
+	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
 
@@ -127,8 +129,8 @@ test_expect_success 'verify blob:limit=1k' '
 '
 
 test_expect_success 'verify blob:limit=1m' '
-	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1m |
-	awk -f print_1.awk |
+	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1m >revs &&
+	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
 
@@ -156,12 +158,12 @@ test_expect_success 'setup r3' '
 '
 
 test_expect_success 'verify sparse:path=pattern1 omits top-level files' '
-	git -C r3 ls-files -s sparse1 sparse2 |
-	awk -f print_2.awk |
+	git -C r3 ls-files -s sparse1 sparse2 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
-	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:path=../pattern1 |
-	awk -f print_1.awk |
+	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:path=../pattern1 >revs &&
+	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
 
@@ -169,12 +171,12 @@ test_expect_success 'verify sparse:path=pattern1 omits top-level files' '
 '
 
 test_expect_success 'verify sparse:path=pattern2 omits both sparse2 files' '
-	git -C r3 ls-files -s sparse2 dir1/sparse2 |
-	awk -f print_2.awk |
+	git -C r3 ls-files -s sparse2 dir1/sparse2 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
-	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:path=../pattern2 |
-	awk -f print_1.awk |
+	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:path=../pattern2 >revs &&
+	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
 
@@ -192,14 +194,14 @@ test_expect_success 'setup r3 part 2' '
 '
 
 test_expect_success 'verify sparse:oid=OID omits top-level files' '
-	git -C r3 ls-files -s pattern sparse1 sparse2 |
-	awk -f print_2.awk |
+	git -C r3 ls-files -s pattern sparse1 sparse2 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	oid=$(git -C r3 ls-files -s pattern | awk -f print_2.awk) &&
 
-	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:oid=$oid |
-	awk -f print_1.awk |
+	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:oid=$oid >revs &&
+	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
 
@@ -207,12 +209,12 @@ test_expect_success 'verify sparse:oid=OID omits top-level files' '
 '
 
 test_expect_success 'verify sparse:oid=oid-ish omits top-level files' '
-	git -C r3 ls-files -s pattern sparse1 sparse2 |
-	awk -f print_2.awk |
+	git -C r3 ls-files -s pattern sparse1 sparse2 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
-	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:oid=master:pattern |
-	awk -f print_1.awk |
+	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:oid=master:pattern >revs &&
+	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
 
@@ -223,8 +225,9 @@ test_expect_success 'verify sparse:oid=oid-ish omits top-level files' '
 # This models previously omitted objects that we did not receive.
 
 test_expect_success 'rev-list W/ --missing=print' '
-	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 |
-	awk -f print_2.awk |
+	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 \
+		>ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	for id in `cat expected | sed "s|..|&/|"`
@@ -232,8 +235,8 @@ test_expect_success 'rev-list W/ --missing=print' '
 		rm r1/.git/objects/$id
 	done &&
 
-	git -C r1 rev-list --quiet HEAD --missing=print --objects |
-	awk -f print_1.awk |
+	git -C r1 rev-list --quiet HEAD --missing=print --objects >revs &&
+	awk -f print_1.awk revs |
 	sed "s/?//" |
 	sort >observed &&
 
diff --git a/t/t9101-git-svn-props.sh b/t/t9101-git-svn-props.sh
index 8a5c8dc1a..8cba331fc 100755
--- a/t/t9101-git-svn-props.sh
+++ b/t/t9101-git-svn-props.sh
@@ -174,7 +174,8 @@ test_expect_success 'test create-ignore' "
 	cmp ./deeply/.gitignore create-ignore.expect &&
 	cmp ./deeply/nested/.gitignore create-ignore.expect &&
 	cmp ./deeply/nested/directory/.gitignore create-ignore.expect &&
-	git ls-files -s | grep gitignore | cmp - create-ignore-index.expect
+	git ls-files -s >ls_files_result &&
+	grep gitignore ls_files_result | cmp - create-ignore-index.expect
 	"
 
 cat >prop.expect <<\EOF
-- 
2.19.0.444.g18242da7ef-goog


^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [PATCH v3 5/5] t9109: don't swallow Git errors upstream of pipes
  2018-09-21  1:43 ` [PATCH v3 0/5] Clean up tests for test_cmp arg ordering and pipe placement Matthew DeVore
                     ` (3 preceding siblings ...)
  2018-09-21  1:43   ` [PATCH v3 4/5] tests: don't swallow Git errors upstream of pipes Matthew DeVore
@ 2018-09-21  1:43   ` Matthew DeVore
  4 siblings, 0 replies; 66+ messages in thread
From: Matthew DeVore @ 2018-09-21  1:43 UTC (permalink / raw)
  To: git; +Cc: Matthew DeVore, peff, jonathantanmy, gitster, jrn, sunshine

'git ... | foo' will mask any errors or crashes in git, so split up such
pipes in this file.

One testcase uses several separate pipe sequences in a row which are
awkward to split up. Wrap the split-up pipe in a function so the
awkwardness is not repeated. Also change that testcase's surrounding
quotes from double to single to avoid premature string interpolation.

Signed-off-by: Matthew DeVore <matvore@google.com>
---
 t/t9101-git-svn-props.sh | 31 +++++++++++++++++++------------
 1 file changed, 19 insertions(+), 12 deletions(-)

diff --git a/t/t9101-git-svn-props.sh b/t/t9101-git-svn-props.sh
index 8cba331fc..c26c4b092 100755
--- a/t/t9101-git-svn-props.sh
+++ b/t/t9101-git-svn-props.sh
@@ -190,17 +190,21 @@ EOF
 # This test can be improved: since all the svn:ignore contain the same
 # pattern, it can pass even though the propget did not execute on the
 # right directory.
-test_expect_success 'test propget' "
-	git svn propget svn:ignore . | cmp - prop.expect &&
+test_expect_success 'test propget' '
+	test_propget () {
+		git svn propget $1 $2 >actual &&
+		cmp $3 actual
+	} &&
+	test_propget svn:ignore . prop.expect &&
 	cd deeply &&
-	git svn propget svn:ignore . | cmp - ../prop.expect &&
-	git svn propget svn:entry:committed-rev nested/directory/.keep \
-	  | cmp - ../prop2.expect &&
-	git svn propget svn:ignore .. | cmp - ../prop.expect &&
-	git svn propget svn:ignore nested/ | cmp - ../prop.expect &&
-	git svn propget svn:ignore ./nested | cmp - ../prop.expect &&
-	git svn propget svn:ignore .././deeply/nested | cmp - ../prop.expect
-	"
+	test_propget svn:ignore . ../prop.expect &&
+	test_propget svn:entry:committed-rev nested/directory/.keep \
+		../prop2.expect &&
+	test_propget svn:ignore .. ../prop.expect &&
+	test_propget svn:ignore nested/ ../prop.expect &&
+	test_propget svn:ignore ./nested ../prop.expect &&
+	test_propget svn:ignore .././deeply/nested ../prop.expect
+	'
 
 cat >prop.expect <<\EOF
 Properties on '.':
@@ -219,8 +223,11 @@ Properties on 'nested/directory/.keep':
 EOF
 
 test_expect_success 'test proplist' "
-	git svn proplist . | cmp - prop.expect &&
-	git svn proplist nested/directory/.keep | cmp - prop2.expect
+	git svn proplist . >actual &&
+	cmp prop.expect actual &&
+
+	git svn proplist nested/directory/.keep >actual &&
+	cmp prop2.expect actual
 	"
 
 test_done
-- 
2.19.0.444.g18242da7ef-goog


^ permalink raw reply related	[flat|nested] 66+ messages in thread

* Re: [PATCH v3 1/5] CodingGuidelines: add shell piping guidelines
  2018-09-21  1:43   ` [PATCH v3 1/5] CodingGuidelines: add shell piping guidelines Matthew DeVore
@ 2018-09-21  2:06     ` Eric Sunshine
  2018-09-21 21:03       ` Matthew DeVore
  2018-09-24 21:03     ` SZEDER Gábor
  1 sibling, 1 reply; 66+ messages in thread
From: Eric Sunshine @ 2018-09-21  2:06 UTC (permalink / raw)
  To: Matthew DeVore
  Cc: Git List, Jeff King, Jonathan Tan, Junio C Hamano,
	Jonathan Nieder

On Thu, Sep 20, 2018 at 9:43 PM Matthew DeVore <matvore@google.com> wrote:
> Add two guidelines:

Probably s/two/three/ or s/two/several/ since the patch now adds three
guidelines.

>  - pipe characters should appear at the end of lines, and not cause
>    indentation

The "not cause indentation" bit is outdated since the added guideline
no longer says this.

>  - pipes should be avoided when they swallow exit codes that can
>    potentially fail

And:

    - $(git ...) should be avoided ...

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v3 1/5] CodingGuidelines: add shell piping guidelines
  2018-09-21  2:06     ` Eric Sunshine
@ 2018-09-21 21:03       ` Matthew DeVore
  0 siblings, 0 replies; 66+ messages in thread
From: Matthew DeVore @ 2018-09-21 21:03 UTC (permalink / raw)
  To: Eric Sunshine
  Cc: git, Jeff King, Jonathan Tan, Junio C Hamano, Jonathan Nieder

On Thu, Sep 20, 2018 at 7:06 PM Eric Sunshine <sunshine@sunshineco.com> wrote:
>
> On Thu, Sep 20, 2018 at 9:43 PM Matthew DeVore <matvore@google.com> wrote:
> > Add two guidelines:
>
> Probably s/two/three/ or s/two/several/ since the patch now adds three
> guidelines.
>
> >  - pipe characters should appear at the end of lines, and not cause
> >    indentation
>
> The "not cause indentation" bit is outdated since the added guideline
> no longer says this.
>
> >  - pipes should be avoided when they swallow exit codes that can
> >    potentially fail
>
> And:
>
>     - $(git ...) should be avoided ...

Thank you for pointing this out - I obviously forgot to update the
commit message. Here is the revised message:

CodingGuidelines: add shell piping guidelines

Add the following guidelines:

 - pipe characters should appear at the end of lines, not the beginning,
   and the \ line continuation character should be omitted
 - pipes and $(git ...) should be avoided when they swallow exit codes
   of processes that can potentially fail

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v3 1/5] CodingGuidelines: add shell piping guidelines
  2018-09-21  1:43   ` [PATCH v3 1/5] CodingGuidelines: add shell piping guidelines Matthew DeVore
  2018-09-21  2:06     ` Eric Sunshine
@ 2018-09-24 21:03     ` SZEDER Gábor
  2018-09-25 21:58       ` Matthew DeVore
  1 sibling, 1 reply; 66+ messages in thread
From: SZEDER Gábor @ 2018-09-24 21:03 UTC (permalink / raw)
  To: Matthew DeVore; +Cc: git, peff, jonathantanmy, gitster, jrn, sunshine

On Thu, Sep 20, 2018 at 06:43:27PM -0700, Matthew DeVore wrote:
> Add two guidelines:
> 
>  - pipe characters should appear at the end of lines, and not cause
>    indentation
>  - pipes should be avoided when they swallow exit codes that can
>    potentially fail
> ---
>  Documentation/CodingGuidelines | 27 +++++++++++++++++++++++++++
>  1 file changed, 27 insertions(+)
> 
> diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines
> index 48aa4edfb..6d265327c 100644
> --- a/Documentation/CodingGuidelines
> +++ b/Documentation/CodingGuidelines
> @@ -118,6 +118,24 @@ For shell scripts specifically (not exhaustive):
>  		do this
>  	fi
>  
> + - If a command sequence joined with && or || or | spans multiple
> +   lines, put each command on a separate line and put && and || and |
> +   operators at the end of each line, rather than the start. This
> +   means you don't need to use \ to join lines, since the above
> +   operators imply the sequence isn't finished.
> +
> +	(incorrect)
> +	grep blob verify_pack_result \
> +	| awk -f print_1.awk \
> +	| sort >actual &&
> +	...
> +
> +	(correct)
> +	grep blob verify_pack_result |
> +	awk -f print_1.awk |
> +	sort >actual &&
> +	...
> +

The above are general shell coding style guidelines, so it makes sense
to include them in 'Documentation/CodingGuidelines'.


>   - We prefer "test" over "[ ... ]".
>  
>   - We do not write the noiseword "function" in front of shell
> @@ -163,6 +181,15 @@ For shell scripts specifically (not exhaustive):
>  
>     does not have such a problem.
>  
> + - In a piped chain such as "grep blob objects | sort", the exit codes

Let's make an example with git in it, e.g. something like this:

  git cmd | grep important | sort

since just two lines below the new text mentions git crashing.

> +   returned by processes besides the last are ignored. This means that
> +   if git crashes at the beginning or middle of a chain, it may go
> +   undetected. Prefer writing the output of that command to a
> +   temporary file with '>' rather than pipe it.
> +
> + - The $(git ...) construct also discards git's exit code, so if the

This contruct is called command substitution, and it does preserve the
command's exit code, when the expanded text is assigned to a variable:

  $ var=$(exit 42) ; echo $?
  42

Note, however, that even in that case only the exit code of the last
command substitution is preserved:

  $ var=$(exit 1)foo$(exit 2)bar$(exit 3) ; echo $?
  3

> +   goal is to test that particular command, redirect its output to a
> +   temporary file rather than wrap it with $( ).

I find this a bit vague, and to me it implies that ignoring the exit
code of a git command that is not the main focus of the given test is
acceptable, e.g. (made up pseudo example):

  test_expect_success 'fetch gets what it should' '
    git fetch $remote &&
    test "$(git rev-parse just-fetched)" = $expected_oid
  '

In my opinion no tests should ignore the exit code of any git
command, ever.


These last two points, however, are specific to test scripts,
therefore I think they would be better placed in 't/README', where the
rest of the test-specific guidelines are.

>  For C programs:
>  
> -- 
> 2.19.0.444.g18242da7ef-goog
> 

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v3 1/5] CodingGuidelines: add shell piping guidelines
  2018-09-24 21:03     ` SZEDER Gábor
@ 2018-09-25 21:58       ` Matthew DeVore
  2018-09-27 21:18         ` SZEDER Gábor
  0 siblings, 1 reply; 66+ messages in thread
From: Matthew DeVore @ 2018-09-25 21:58 UTC (permalink / raw)
  To: szeder.dev
  Cc: git, Jeff King, Jonathan Tan, Junio C Hamano, Jonathan Nieder,
	Eric Sunshine

On Mon, Sep 24, 2018 at 2:03 PM SZEDER Gábor <szeder.dev@gmail.com> wrote:
> > + - In a piped chain such as "grep blob objects | sort", the exit codes
>
> Let's make an example with git in it, e.g. something like this:
>
>   git cmd | grep important | sort
>
> since just two lines below the new text mentions git crashing.
Done.

> > + - The $(git ...) construct also discards git's exit code, so if the
>
> This contruct is called command substitution, and it does preserve the
> command's exit code, when the expanded text is assigned to a variable:
>
>   $ var=$(exit 42) ; echo $?
>   42
>
> Note, however, that even in that case only the exit code of the last
> command substitution is preserved:
>
>   $ var=$(exit 1)foo$(exit 2)bar$(exit 3) ; echo $?
>   3
>
OK, I've changed this guideline to allow for setting a variable with
command substitution, but not in other contexts. It's worded
sufficiently openly such that your latter example will be forbidden.

> > +   goal is to test that particular command, redirect its output to a
> > +   temporary file rather than wrap it with $( ).
>
> I find this a bit vague, and to me it implies that ignoring the exit
> code of a git command that is not the main focus of the given test is
> acceptable, e.g. (made up pseudo example):
>
>   test_expect_success 'fetch gets what it should' '
>     git fetch $remote &&
>     test "$(git rev-parse just-fetched)" = $expected_oid
>   '
>
> In my opinion no tests should ignore the exit code of any git
> command, ever.

This seems like a pretty strong assertion, but something very similar
is written in t/README (in the "don't" section):

 - use '! git cmd' when you want to make sure the git command exits
   with failure in a controlled way by calling "die()".  Instead,
   use 'test_must_fail git cmd'.  This will signal a failure if git
   dies in an unexpected way (e.g. segfault).

So I've changed this to basically say you should never ignore git's exit code.

Here is the new commit with updated message (I will wait for a day or
two before I send a reroll):

    Documentation: add shell guidelines

    Add the following guideline to Documentation/CodingGuidelines:

            &&, ||, and | should appear at the end of lines, not the
            beginning, and the \ line continuation character should be
            omitted

    And the following to t/README (since it is specific to writing tests):

            pipes and $(git ...) should be avoided when they swallow exit
            codes of Git processes

    Signed-off-by: Matthew DeVore <matvore@google.com>

diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines
index 48aa4edfb..3d2cfea9b 100644
--- a/Documentation/CodingGuidelines
+++ b/Documentation/CodingGuidelines
@@ -118,6 +118,24 @@ For shell scripts specifically (not exhaustive):
                 do this
         fi

+ - If a command sequence joined with && or || or | spans multiple
+   lines, put each command on a separate line and put && and || and |
+   operators at the end of each line, rather than the start. This
+   means you don't need to use \ to join lines, since the above
+   operators imply the sequence isn't finished.
+
+        (incorrect)
+        grep blob verify_pack_result \
+        | awk -f print_1.awk \
+        | sort >actual &&
+        ...
+
+        (correct)
+        grep blob verify_pack_result |
+        awk -f print_1.awk |
+        sort >actual &&
+        ...
+
  - We prefer "test" over "[ ... ]".

  - We do not write the noiseword "function" in front of shell
@@ -163,7 +181,6 @@ For shell scripts specifically (not exhaustive):

    does not have such a problem.

-
 For C programs:

  - We use tabs to indent, and interpret tabs as taking up to
diff --git a/t/README b/t/README
index 9028b47d9..3e28b72c4 100644
--- a/t/README
+++ b/t/README
@@ -461,6 +461,32 @@ Don't:
    platform commands; just use '! cmd'.  We are not in the business
    of verifying that the world given to us sanely works.

+ - Use Git upstream in the non-final position in a piped chain, as in:
+
+     git -C repo ls-files |
+     xargs -n 1 basename |
+     grep foo
+
+   which will discard git's exit code and may mask a crash. In the
+   above example, all exit codes are ignored except grep's.
+
+   Instead, write the output of that command to a temporary
+   file with ">" or assign it to a variable with "x=$(git ...)" rather
+   than pipe it.
+
+ - Use command substitution in a way that discards git's exit code.
+   When assigning to a variable, the exit code is not discarded, e.g.:
+
+     x=$(git cat-file -p $sha) &&
+     ...
+
+   is OK because a crash in "git cat-file" will cause the "&&" chain
+   to fail, but:
+
+     test_cmp expect $(git cat-file -p $sha)
+
+   is not OK and a crash in git could go undetected.
+
  - use perl without spelling it as "$PERL_PATH". This is to help our
    friends on Windows where the platform Perl often adds CR before
    the end of line, and they bundle Git with a version of Perl that


>
>
> These last two points, however, are specific to test scripts,
> therefore I think they would be better placed in 't/README', where the
> rest of the test-specific guidelines are.
>
> >  For C programs:
> >
> > --
> > 2.19.0.444.g18242da7ef-goog
> >

^ permalink raw reply related	[flat|nested] 66+ messages in thread

* Re: [PATCH v3 1/5] CodingGuidelines: add shell piping guidelines
  2018-09-25 21:58       ` Matthew DeVore
@ 2018-09-27 21:18         ` SZEDER Gábor
  2018-10-01 23:07           ` Matthew DeVore
  0 siblings, 1 reply; 66+ messages in thread
From: SZEDER Gábor @ 2018-09-27 21:18 UTC (permalink / raw)
  To: Matthew DeVore
  Cc: git, Jeff King, Jonathan Tan, Junio C Hamano, Jonathan Nieder,
	Eric Sunshine

On Tue, Sep 25, 2018 at 02:58:08PM -0700, Matthew DeVore wrote:
> Here is the new commit with updated message (I will wait for a day or
> two before I send a reroll):
> 
>     Documentation: add shell guidelines
> 
>     Add the following guideline to Documentation/CodingGuidelines:
> 
>             &&, ||, and | should appear at the end of lines, not the
>             beginning, and the \ line continuation character should be
>             omitted
> 
>     And the following to t/README (since it is specific to writing tests):
> 
>             pipes and $(git ...) should be avoided when they swallow exit
>             codes of Git processes
> 
>     Signed-off-by: Matthew DeVore <matvore@google.com>
> 
> diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines
> index 48aa4edfb..3d2cfea9b 100644
> --- a/Documentation/CodingGuidelines
> +++ b/Documentation/CodingGuidelines
> @@ -118,6 +118,24 @@ For shell scripts specifically (not exhaustive):
>                  do this
>          fi
> 
> + - If a command sequence joined with && or || or | spans multiple
> +   lines, put each command on a separate line and put && and || and |
> +   operators at the end of each line, rather than the start. This
> +   means you don't need to use \ to join lines, since the above
> +   operators imply the sequence isn't finished.
> +
> +        (incorrect)
> +        grep blob verify_pack_result \
> +        | awk -f print_1.awk \
> +        | sort >actual &&
> +        ...
> +
> +        (correct)
> +        grep blob verify_pack_result |
> +        awk -f print_1.awk |
> +        sort >actual &&
> +        ...
> +
>   - We prefer "test" over "[ ... ]".
> 
>   - We do not write the noiseword "function" in front of shell
> @@ -163,7 +181,6 @@ For shell scripts specifically (not exhaustive):
> 
>     does not have such a problem.
> 
> -
>  For C programs:
> 
>   - We use tabs to indent, and interpret tabs as taking up to
> diff --git a/t/README b/t/README
> index 9028b47d9..3e28b72c4 100644
> --- a/t/README
> +++ b/t/README
> @@ -461,6 +461,32 @@ Don't:
>     platform commands; just use '! cmd'.  We are not in the business
>     of verifying that the world given to us sanely works.
> 
> + - Use Git upstream in the non-final position in a piped chain, as in:

Note the starting upper case 'U'.

> +
> +     git -C repo ls-files |
> +     xargs -n 1 basename |
> +     grep foo
> +
> +   which will discard git's exit code and may mask a crash. In the
> +   above example, all exit codes are ignored except grep's.
> +
> +   Instead, write the output of that command to a temporary
> +   file with ">" or assign it to a variable with "x=$(git ...)" rather
> +   than pipe it.
> +
> + - Use command substitution in a way that discards git's exit code.

'U' again.

> +   When assigning to a variable, the exit code is not discarded, e.g.:
> +
> +     x=$(git cat-file -p $sha) &&
> +     ...
> +
> +   is OK because a crash in "git cat-file" will cause the "&&" chain
> +   to fail, but:
> +
> +     test_cmp expect $(git cat-file -p $sha)
> +
> +   is not OK and a crash in git could go undetected.

Well, this is not OK indeed, because it doesn't make any sense in the
first place :)  'test_cmp' requires two paths as argumens, but the
output of 'git cat-file -p' is the whole _content_ of the given object.

>   - use perl without spelling it as "$PERL_PATH". This is to help our

Note the starting lower case 'u'.

This is because these are the continuation of the "Don't:" some lines
earlier, so your new points should start with a lower case 'u' as
well.


Sidenote: I think we should consider reformatting this whole section
as:

  - Don't do this.
  - Don't do that.

because it grew so much that when I look at the last points, then that
starting "Don't:" has already scrolled out of my screen.

>     friends on Windows where the platform Perl often adds CR before
>     the end of line, and they bundle Git with a version of Perl that
> 
> 
> >
> >
> > These last two points, however, are specific to test scripts,
> > therefore I think they would be better placed in 't/README', where the
> > rest of the test-specific guidelines are.
> >
> > >  For C programs:
> > >
> > > --
> > > 2.19.0.444.g18242da7ef-goog
> > >

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v3 1/5] CodingGuidelines: add shell piping guidelines
  2018-09-27 21:18         ` SZEDER Gábor
@ 2018-10-01 23:07           ` Matthew DeVore
  0 siblings, 0 replies; 66+ messages in thread
From: Matthew DeVore @ 2018-10-01 23:07 UTC (permalink / raw)
  To: szeder.dev
  Cc: git, Jeff King, Jonathan Tan, Junio C Hamano, Jonathan Nieder,
	Eric Sunshine

On Thu, Sep 27, 2018 at 2:18 PM SZEDER Gábor <szeder.dev@gmail.com> wrote:
>
> On Tue, Sep 25, 2018 at 02:58:08PM -0700, Matthew DeVore wrote:
> > + - Use Git upstream in the non-final position in a piped chain, as in:
>
> Note the starting upper case 'U'.
>
> > + - Use command substitution in a way that discards git's exit code.
>
> 'U' again.
>
...
> > +
> > +     test_cmp expect $(git cat-file -p $sha)
> > +
> > +   is not OK and a crash in git could go undetected.
>
> Well, this is not OK indeed, because it doesn't make any sense in the
> first place :)  'test_cmp' requires two paths as argumens, but the
> output of 'git cat-file -p' is the whole _content_ of the given object.

I've replaced the example and added "Don't" in front of each new item
(explanation for this below). Here is a new diff for this file - the
rest of the commit is the same:

    platform commands; just use '! cmd'.  We are not in the business
    of verifying that the world given to us sanely works.

+ - Don't use Git upstream in the non-final position in a piped chain, as
+   in:
+
+     git -C repo ls-files |
+     xargs -n 1 basename |
+     grep foo
+
+   which will discard git's exit code and may mask a crash. In the
+   above example, all exit codes are ignored except grep's.
+
+   Instead, write the output of that command to a temporary
+   file with ">" or assign it to a variable with "x=$(git ...)" rather
+   than pipe it.
+
+ - Don't use command substitution in a way that discards git's exit
+   code. When assigning to a variable, the exit code is not discarded,
+   e.g.:
+
+     x=$(git cat-file -p $sha) &&
+     ...
+
+   is OK because a crash in "git cat-file" will cause the "&&" chain
+   to fail, but:
+
+     test "refs/heads/foo" = "$(git symbolic-ref HEAD)"
+
+   is not OK and a crash in git could go undetected.
+
  - Don't use perl without spelling it as "$PERL_PATH". This is to help
    our friends on Windows where the platform Perl often adds CR before
    the end of line, and they bundle Git with a version of Perl that


>
> >   - use perl without spelling it as "$PERL_PATH". This is to help our
>
> Note the starting lower case 'u'.
>
> This is because these are the continuation of the "Don't:" some lines
> earlier, so your new points should start with a lower case 'u' as
> well.
>
>
> Sidenote: I think we should consider reformatting this whole section
> as:
>
>   - Don't do this.
>   - Don't do that.
>
> because it grew so much that when I look at the last points, then that
> starting "Don't:" has already scrolled out of my screen.
>
I didn't like how easy it was to mistake a "Don't" item for a "Do"
(although temporarily until you read the first sentence, but it's
still confusing). So I added a new commit to clean this section up.
Here it is:

Author: Matthew DeVore <matvore@google.com>
Date:   Mon Oct 1 15:30:49 2018 -0700

    t/README: reformat Do, Don't, Keep in mind lists

    The list of Don'ts for test writing has grown large such that it is hard
    to see at a glance which section an item is in. In other words, if I
    ignore a little bit of surrounding context, the "don'ts" look like
    "do's."

    To make the list more readable, prefix "Don't" in front of every first
    sentence in the items.

    Also, the "Keep in mind" list is out of place and awkward, because it
    was a very short "list" beneath two very long ones, and it seemed easy
    to miss under the list of "don'ts," and it only had one item. So move
    this item to the list of "do's" and phrase as "Remember..."

    Signed-off-by: Matthew DeVore <matvore@google.com>

diff --git a/t/README b/t/README
index 9028b47d9..85024aba6 100644
--- a/t/README
+++ b/t/README
@@ -393,13 +393,13 @@ This test harness library does the following things:
    consistently when command line arguments --verbose (or -v),
    --debug (or -d), and --immediate (or -i) is given.

-Do's, don'ts & things to keep in mind
+Do's & don'ts
 -------------------------------------

 Here are a few examples of things you probably should and shouldn't do
 when writing tests.

-Do:
+Here are the "do's:"

  - Put all code inside test_expect_success and other assertions.

@@ -444,16 +444,21 @@ Do:
    Windows, where the shell (MSYS bash) mangles absolute path names.
    For details, see the commit message of 4114156ae9.

-Don't:
+ - Remember that inside the <script> part, the standard output and
+   standard error streams are discarded, and the test harness only
+   reports "ok" or "not ok" to the end user running the tests. Under
+   --verbose, they are shown to help debug the tests.

- - exit() within a <script> part.
+And here are the "don'ts:"
+
+ - Don't exit() within a <script> part.

    The harness will catch this as a programming error of the test.
    Use test_done instead if you need to stop the tests early (see
    "Skipping tests" below).

- - use '! git cmd' when you want to make sure the git command exits
-   with failure in a controlled way by calling "die()".  Instead,
+ - Don't use '! git cmd' when you want to make sure the git command
+   exits with failure in a controlled way by calling "die()".  Instead,
    use 'test_must_fail git cmd'.  This will signal a failure if git
    dies in an unexpected way (e.g. segfault).

@@ -461,8 +466,8 @@ Don't:
    platform commands; just use '! cmd'.  We are not in the business
    of verifying that the world given to us sanely works.

- - use perl without spelling it as "$PERL_PATH". This is to help our
-   friends on Windows where the platform Perl often adds CR before
+ - Don't use perl without spelling it as "$PERL_PATH". This is to help
+   our friends on Windows where the platform Perl often adds CR before
    the end of line, and they bundle Git with a version of Perl that
    does not do so, whose path is specified with $PERL_PATH. Note that we
    provide a "perl" function which uses $PERL_PATH under the hood, so
@@ -470,17 +475,17 @@ Don't:
    (but you do, for example, on a shebang line or in a sub script
    created via "write_script").

- - use sh without spelling it as "$SHELL_PATH", when the script can
-   be misinterpreted by broken platform shell (e.g. Solaris).
+ - Don't use sh without spelling it as "$SHELL_PATH", when the script
+   can be misinterpreted by broken platform shell (e.g. Solaris).

- - chdir around in tests.  It is not sufficient to chdir to
+ - Don't chdir around in tests.  It is not sufficient to chdir to
    somewhere and then chdir back to the original location later in
    the test, as any intermediate step can fail and abort the test,
    causing the next test to start in an unexpected directory.  Do so
    inside a subshell if necessary.

- - save and verify the standard error of compound commands, i.e. group
-   commands, subshells, and shell functions (except test helper
+ - Don't save and verify the standard error of compound commands, i.e.
+   group commands, subshells, and shell functions (except test helper
    functions like 'test_must_fail') like this:

      ( cd dir && git cmd ) 2>error &&
@@ -495,7 +500,7 @@ Don't:
      ( cd dir && git cmd 2>../error ) &&
      test_cmp expect error

- - Break the TAP output
+ - Don't break the TAP output

    The raw output from your test may be interpreted by a TAP harness. TAP
    harnesses will ignore everything they don't know about, but don't step
@@ -515,13 +520,6 @@ Don't:
    but the best indication is to just run the tests with prove(1),
    it'll complain if anything is amiss.

-Keep in mind:
-
- - Inside the <script> part, the standard output and standard error
-   streams are discarded, and the test harness only reports "ok" or
-   "not ok" to the end user running the tests. Under --verbose, they
-   are shown to help debugging the tests.
-

 Skipping tests
 --------------

^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [PATCH v4 0/7] Clean up tests for test_cmp arg ordering and pipe placement
  2018-09-15  0:02 [PATCH v1 0/2] Cleanup tests for test_cmp argument ordering and "|" placement Matthew DeVore
                   ` (5 preceding siblings ...)
  2018-09-21  1:43 ` [PATCH v3 0/5] Clean up tests for test_cmp arg ordering and pipe placement Matthew DeVore
@ 2018-10-03 16:25 ` Matthew DeVore
  2018-10-03 16:25   ` [PATCH v4 1/7] t/README: reformat Do, Don't, Keep in mind lists Matthew DeVore
                     ` (6 more replies)
  2018-10-05 21:54 ` [PATCH v5 0/7] subject: Clean up tests for test_cmp arg ordering and pipe placement Matthew DeVore
  7 siblings, 7 replies; 66+ messages in thread
From: Matthew DeVore @ 2018-10-03 16:25 UTC (permalink / raw)
  To: git; +Cc: Matthew DeVore, peff, jonathantanmy, gitster, jrn, sunshine,
	szeder.dev

Apply suggestions by Szeder and Eric from last version of the patch,
namely:
 - Use a sensible example for how one can unknowingly drop a Git exit
   code in tests.
 - Fixed the message for the second commit.
 - Move the test-specific coding guidelines to t/README from
   Documentation/CodingGuidelines.
 - Particularly forbid invoking Git in ways that will mask crashes, but
   don't say this for non-Git commands, since validating them isn't or
   job.
 - Including a guideline about dropping exit codes for command
   substitution.
 - Reformat Do/Don't lists in Documentation/CodingGuidelines, and make my
   added points have consistent format. This is a new commit.

There may be other changes I didn't list above, but I would have
mentioned them in prior mails.

I created a new commit which cleans up invocations of git-rev-list so
that positional arguments are last, since my other patchset modifies the
tests where most of these mistakes are present, and I want the tests
added in the other patchset to be consistent with the code around it.

Thank you,

Matthew DeVore (7):
  t/README: reformat Do, Don't, Keep in mind lists
  Documentation: add shell guidelines
  tests: standardize pipe placement
  t/*: fix ordering of expected/observed arguments
  tests: don't swallow Git errors upstream of pipes
  t9109: don't swallow Git errors upstream of pipes
  tests: order arguments to git-rev-list properly

 Documentation/CodingGuidelines         |  18 ++
 t/README                               |  68 +++--
 t/lib-gpg.sh                           |   9 +-
 t/t0000-basic.sh                       |   2 +-
 t/t0021-conversion.sh                  |   4 +-
 t/t1006-cat-file.sh                    |   8 +-
 t/t1300-config.sh                      |   9 +-
 t/t1303-wacky-config.sh                |   4 +-
 t/t2101-update-index-reupdate.sh       |   2 +-
 t/t3200-branch.sh                      |   2 +-
 t/t3320-notes-merge-worktrees.sh       |   4 +-
 t/t3400-rebase.sh                      |   8 +-
 t/t3417-rebase-whitespace-fix.sh       |   6 +-
 t/t3702-add-edit.sh                    |   4 +-
 t/t3903-stash.sh                       |   8 +-
 t/t3905-stash-include-untracked.sh     |   2 +-
 t/t4025-hunk-header.sh                 |   2 +-
 t/t4117-apply-reject.sh                |   6 +-
 t/t4124-apply-ws-rule.sh               |  30 +--
 t/t4138-apply-ws-expansion.sh          |   2 +-
 t/t5317-pack-objects-filter-objects.sh | 360 ++++++++++++++-----------
 t/t5318-commit-graph.sh                |   2 +-
 t/t5500-fetch-pack.sh                  |   7 +-
 t/t5616-partial-clone.sh               |  50 ++--
 t/t5701-git-serve.sh                   |  14 +-
 t/t5702-protocol-v2.sh                 |  14 +-
 t/t6023-merge-file.sh                  |  12 +-
 t/t6027-merge-binary.sh                |   4 +-
 t/t6031-merge-filemode.sh              |   2 +-
 t/t6112-rev-list-filters-objects.sh    | 237 +++++++++-------
 t/t7201-co.sh                          |   4 +-
 t/t7406-submodule-update.sh            |   8 +-
 t/t7800-difftool.sh                    |   2 +-
 t/t9100-git-svn-basic.sh               |   2 +-
 t/t9101-git-svn-props.sh               |  34 ++-
 t/t9133-git-svn-nested-git-repo.sh     |   6 +-
 t/t9600-cvsimport.sh                   |   2 +-
 t/t9603-cvsimport-patchsets.sh         |   4 +-
 t/t9604-cvsimport-timestamps.sh        |   4 +-
 39 files changed, 568 insertions(+), 398 deletions(-)

-- 
2.19.0.605.g01d371f741-goog


^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v4 1/7] t/README: reformat Do, Don't, Keep in mind lists
  2018-10-03 16:25 ` [PATCH v4 0/7] Clean up tests for test_cmp arg ordering and pipe placement Matthew DeVore
@ 2018-10-03 16:25   ` Matthew DeVore
  2018-10-05  6:15     ` Junio C Hamano
  2018-10-03 16:26   ` [PATCH v4 2/7] Documentation: add shell guidelines Matthew DeVore
                     ` (5 subsequent siblings)
  6 siblings, 1 reply; 66+ messages in thread
From: Matthew DeVore @ 2018-10-03 16:25 UTC (permalink / raw)
  To: git; +Cc: Matthew DeVore, peff, jonathantanmy, gitster, jrn, sunshine,
	szeder.dev

The list of Don'ts for test writing has grown large such that it is hard
to see at a glance which section an item is in. In other words, if I
ignore a little bit of surrounding context, the "don'ts" look like
"do's."

To make the list more readable, prefix "Don't" in front of every first
sentence in the items.

Also, the "Keep in mind" list is out of place and awkward, because it
was a very short "list" beneath two very long ones, and it seemed easy
to miss under the list of "don'ts," and it only had one item. So move
this item to the list of "do's" and phrase as "Remember..."

Signed-off-by: Matthew DeVore <matvore@google.com>
---
 t/README | 40 +++++++++++++++++++---------------------
 1 file changed, 19 insertions(+), 21 deletions(-)

diff --git a/t/README b/t/README
index 9028b47d9..85024aba6 100644
--- a/t/README
+++ b/t/README
@@ -393,13 +393,13 @@ This test harness library does the following things:
    consistently when command line arguments --verbose (or -v),
    --debug (or -d), and --immediate (or -i) is given.
 
-Do's, don'ts & things to keep in mind
+Do's & don'ts
 -------------------------------------
 
 Here are a few examples of things you probably should and shouldn't do
 when writing tests.
 
-Do:
+Here are the "do's:"
 
  - Put all code inside test_expect_success and other assertions.
 
@@ -444,16 +444,21 @@ Do:
    Windows, where the shell (MSYS bash) mangles absolute path names.
    For details, see the commit message of 4114156ae9.
 
-Don't:
+ - Remember that inside the <script> part, the standard output and
+   standard error streams are discarded, and the test harness only
+   reports "ok" or "not ok" to the end user running the tests. Under
+   --verbose, they are shown to help debug the tests.
 
- - exit() within a <script> part.
+And here are the "don'ts:"
+
+ - Don't exit() within a <script> part.
 
    The harness will catch this as a programming error of the test.
    Use test_done instead if you need to stop the tests early (see
    "Skipping tests" below).
 
- - use '! git cmd' when you want to make sure the git command exits
-   with failure in a controlled way by calling "die()".  Instead,
+ - Don't use '! git cmd' when you want to make sure the git command
+   exits with failure in a controlled way by calling "die()".  Instead,
    use 'test_must_fail git cmd'.  This will signal a failure if git
    dies in an unexpected way (e.g. segfault).
 
@@ -461,8 +466,8 @@ Don't:
    platform commands; just use '! cmd'.  We are not in the business
    of verifying that the world given to us sanely works.
 
- - use perl without spelling it as "$PERL_PATH". This is to help our
-   friends on Windows where the platform Perl often adds CR before
+ - Don't use perl without spelling it as "$PERL_PATH". This is to help
+   our friends on Windows where the platform Perl often adds CR before
    the end of line, and they bundle Git with a version of Perl that
    does not do so, whose path is specified with $PERL_PATH. Note that we
    provide a "perl" function which uses $PERL_PATH under the hood, so
@@ -470,17 +475,17 @@ Don't:
    (but you do, for example, on a shebang line or in a sub script
    created via "write_script").
 
- - use sh without spelling it as "$SHELL_PATH", when the script can
-   be misinterpreted by broken platform shell (e.g. Solaris).
+ - Don't use sh without spelling it as "$SHELL_PATH", when the script
+   can be misinterpreted by broken platform shell (e.g. Solaris).
 
- - chdir around in tests.  It is not sufficient to chdir to
+ - Don't chdir around in tests.  It is not sufficient to chdir to
    somewhere and then chdir back to the original location later in
    the test, as any intermediate step can fail and abort the test,
    causing the next test to start in an unexpected directory.  Do so
    inside a subshell if necessary.
 
- - save and verify the standard error of compound commands, i.e. group
-   commands, subshells, and shell functions (except test helper
+ - Don't save and verify the standard error of compound commands, i.e.
+   group commands, subshells, and shell functions (except test helper
    functions like 'test_must_fail') like this:
 
      ( cd dir && git cmd ) 2>error &&
@@ -495,7 +500,7 @@ Don't:
      ( cd dir && git cmd 2>../error ) &&
      test_cmp expect error
 
- - Break the TAP output
+ - Don't break the TAP output
 
    The raw output from your test may be interpreted by a TAP harness. TAP
    harnesses will ignore everything they don't know about, but don't step
@@ -515,13 +520,6 @@ Don't:
    but the best indication is to just run the tests with prove(1),
    it'll complain if anything is amiss.
 
-Keep in mind:
-
- - Inside the <script> part, the standard output and standard error
-   streams are discarded, and the test harness only reports "ok" or
-   "not ok" to the end user running the tests. Under --verbose, they
-   are shown to help debugging the tests.
-
 
 Skipping tests
 --------------
-- 
2.19.0.605.g01d371f741-goog


^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [PATCH v4 2/7] Documentation: add shell guidelines
  2018-10-03 16:25 ` [PATCH v4 0/7] Clean up tests for test_cmp arg ordering and pipe placement Matthew DeVore
  2018-10-03 16:25   ` [PATCH v4 1/7] t/README: reformat Do, Don't, Keep in mind lists Matthew DeVore
@ 2018-10-03 16:26   ` Matthew DeVore
  2018-10-05 16:48     ` Junio C Hamano
  2018-10-03 16:26   ` [PATCH v4 3/7] tests: standardize pipe placement Matthew DeVore
                     ` (4 subsequent siblings)
  6 siblings, 1 reply; 66+ messages in thread
From: Matthew DeVore @ 2018-10-03 16:26 UTC (permalink / raw)
  To: git; +Cc: Matthew DeVore, peff, jonathantanmy, gitster, jrn, sunshine,
	szeder.dev

Add the following guideline to Documentation/CodingGuidelines:

	&&, ||, and | should appear at the end of lines, not the
	beginning, and the \ line continuation character should be
	omitted

And the following to t/README (since it is specific to writing tests):

	pipes and $(git ...) should be avoided when they swallow exit
	codes of Git processes

Signed-off-by: Matthew DeVore <matvore@google.com>
---
 Documentation/CodingGuidelines | 18 ++++++++++++++++++
 t/README                       | 28 ++++++++++++++++++++++++++++
 2 files changed, 46 insertions(+)

diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines
index 48aa4edfb..72967deb7 100644
--- a/Documentation/CodingGuidelines
+++ b/Documentation/CodingGuidelines
@@ -118,6 +118,24 @@ For shell scripts specifically (not exhaustive):
 		do this
 	fi
 
+ - If a command sequence joined with && or || or | spans multiple
+   lines, put each command on a separate line and put && and || and |
+   operators at the end of each line, rather than the start. This
+   means you don't need to use \ to join lines, since the above
+   operators imply the sequence isn't finished.
+
+	(incorrect)
+	grep blob verify_pack_result \
+	| awk -f print_1.awk \
+	| sort >actual &&
+	...
+
+	(correct)
+	grep blob verify_pack_result |
+	awk -f print_1.awk |
+	sort >actual &&
+	...
+
  - We prefer "test" over "[ ... ]".
 
  - We do not write the noiseword "function" in front of shell
diff --git a/t/README b/t/README
index 85024aba6..9a71d5732 100644
--- a/t/README
+++ b/t/README
@@ -466,6 +466,34 @@ And here are the "don'ts:"
    platform commands; just use '! cmd'.  We are not in the business
    of verifying that the world given to us sanely works.
 
+ - Don't use Git upstream in the non-final position in a piped chain, as
+   in:
+
+     git -C repo ls-files |
+     xargs -n 1 basename |
+     grep foo
+
+   which will discard git's exit code and may mask a crash. In the
+   above example, all exit codes are ignored except grep's.
+
+   Instead, write the output of that command to a temporary
+   file with ">" or assign it to a variable with "x=$(git ...)" rather
+   than pipe it.
+
+ - Don't use command substitution in a way that discards git's exit
+   code. When assigning to a variable, the exit code is not discarded,
+   e.g.:
+
+     x=$(git cat-file -p $sha) &&
+     ...
+
+   is OK because a crash in "git cat-file" will cause the "&&" chain
+   to fail, but:
+
+     test "refs/heads/foo" = "$(git symbolic-ref HEAD)"
+
+   is not OK and a crash in git could go undetected.
+
  - Don't use perl without spelling it as "$PERL_PATH". This is to help
    our friends on Windows where the platform Perl often adds CR before
    the end of line, and they bundle Git with a version of Perl that
-- 
2.19.0.605.g01d371f741-goog


^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [PATCH v4 3/7] tests: standardize pipe placement
  2018-10-03 16:25 ` [PATCH v4 0/7] Clean up tests for test_cmp arg ordering and pipe placement Matthew DeVore
  2018-10-03 16:25   ` [PATCH v4 1/7] t/README: reformat Do, Don't, Keep in mind lists Matthew DeVore
  2018-10-03 16:26   ` [PATCH v4 2/7] Documentation: add shell guidelines Matthew DeVore
@ 2018-10-03 16:26   ` Matthew DeVore
  2018-10-03 16:26   ` [PATCH v4 4/7] t/*: fix ordering of expected/observed arguments Matthew DeVore
                     ` (3 subsequent siblings)
  6 siblings, 0 replies; 66+ messages in thread
From: Matthew DeVore @ 2018-10-03 16:26 UTC (permalink / raw)
  To: git; +Cc: Matthew DeVore, peff, jonathantanmy, gitster, jrn, sunshine,
	szeder.dev

Instead of using a line-continuation and pipe on the second line, take
advantage of the shell's implicit line continuation after a pipe
character.  So for example, instead of

	some long line \
		| next line

use

	some long line |
	next line

And add a blank line before and after the pipe where it aids readability
(it usually does).

This better matches the coding style documented in
Documentation/CodingGuidelines and used in shell scripts elsewhere in
the tree.

Signed-off-by: Matthew DeVore <matvore@google.com>
---
 t/lib-gpg.sh                           |   9 +-
 t/t1006-cat-file.sh                    |   8 +-
 t/t1300-config.sh                      |   5 +-
 t/t5317-pack-objects-filter-objects.sh | 330 ++++++++++++++-----------
 t/t5500-fetch-pack.sh                  |   7 +-
 t/t5616-partial-clone.sh               |  32 ++-
 t/t6112-rev-list-filters-objects.sh    | 203 ++++++++-------
 7 files changed, 344 insertions(+), 250 deletions(-)

diff --git a/t/lib-gpg.sh b/t/lib-gpg.sh
index 3fe02876c..f1277bef4 100755
--- a/t/lib-gpg.sh
+++ b/t/lib-gpg.sh
@@ -57,9 +57,12 @@ then
 		echo | gpgsm --homedir "${GNUPGHOME}" 2>/dev/null \
 			--passphrase-fd 0 --pinentry-mode loopback \
 			--import "$TEST_DIRECTORY"/lib-gpg/gpgsm_cert.p12 &&
-		gpgsm --homedir "${GNUPGHOME}" 2>/dev/null -K \
-			| grep fingerprint: | cut -d" " -f4 | tr -d '\n' > \
-			${GNUPGHOME}/trustlist.txt &&
+
+		gpgsm --homedir "${GNUPGHOME}" 2>/dev/null -K |
+		grep fingerprint: |
+		cut -d" " -f4 |
+		tr -d '\n' >"${GNUPGHOME}/trustlist.txt" &&
+
 		echo " S relax" >> ${GNUPGHOME}/trustlist.txt &&
 		(gpgconf --kill gpg-agent >/dev/null 2>&1 || : ) &&
 		echo hello | gpgsm --homedir "${GNUPGHOME}" >/dev/null \
diff --git a/t/t1006-cat-file.sh b/t/t1006-cat-file.sh
index 7f19d591f..a0fa926d3 100755
--- a/t/t1006-cat-file.sh
+++ b/t/t1006-cat-file.sh
@@ -218,8 +218,8 @@ test_expect_success "--batch-check for a non-existent hash" '
     test "0000000000000000000000000000000000000042 missing
 0000000000000000000000000000000000000084 missing" = \
     "$( ( echo 0000000000000000000000000000000000000042;
-         echo_without_newline 0000000000000000000000000000000000000084; ) \
-       | git cat-file --batch-check)"
+         echo_without_newline 0000000000000000000000000000000000000084; ) |
+       git cat-file --batch-check)"
 '
 
 test_expect_success "--batch for an existent and a non-existent hash" '
@@ -227,8 +227,8 @@ test_expect_success "--batch for an existent and a non-existent hash" '
 $tag_content
 0000000000000000000000000000000000000000 missing" = \
     "$( ( echo $tag_sha1;
-         echo_without_newline 0000000000000000000000000000000000000000; ) \
-       | git cat-file --batch)"
+         echo_without_newline 0000000000000000000000000000000000000000; ) |
+       git cat-file --batch)"
 '
 
 test_expect_success "--batch-check for an empty line" '
diff --git a/t/t1300-config.sh b/t/t1300-config.sh
index cdf1fed5d..5869d6cb6 100755
--- a/t/t1300-config.sh
+++ b/t/t1300-config.sh
@@ -1770,8 +1770,9 @@ test_expect_success '--show-origin stdin with file include' '
 	cat >expect <<-EOF &&
 		file:$INCLUDE_DIR/stdin.include	include
 	EOF
-	echo "[include]path=\"$INCLUDE_DIR\"/stdin.include" \
-		| git config --show-origin --includes --file - user.stdin >output &&
+	echo "[include]path=\"$INCLUDE_DIR\"/stdin.include" |
+	git config --show-origin --includes --file - user.stdin >output &&
+
 	test_cmp expect output
 '
 
diff --git a/t/t5317-pack-objects-filter-objects.sh b/t/t5317-pack-objects-filter-objects.sh
index 6710c8bc8..ce69148ec 100755
--- a/t/t5317-pack-objects-filter-objects.sh
+++ b/t/t5317-pack-objects-filter-objects.sh
@@ -20,17 +20,20 @@ test_expect_success 'setup r1' '
 '
 
 test_expect_success 'verify blob count in normal packfile' '
-	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	git -C r1 pack-objects --rev --stdout >all.pack <<-EOF &&
 	HEAD
 	EOF
 	git -C r1 index-pack ../all.pack &&
-	git -C r1 verify-pack -v ../all.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r1 verify-pack -v ../all.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
@@ -39,23 +42,27 @@ test_expect_success 'verify blob:none packfile has no blobs' '
 	HEAD
 	EOF
 	git -C r1 index-pack ../filter.pack &&
-	git -C r1 verify-pack -v ../filter.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r1 verify-pack -v ../filter.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	nr=$(wc -l <observed) &&
 	test 0 -eq $nr
 '
 
 test_expect_success 'verify normal and blob:none packfiles have same commits/trees' '
-	git -C r1 verify-pack -v ../all.pack \
-		| grep -E "commit|tree" \
-		| awk -f print_1.awk \
-		| sort >expected &&
-	git -C r1 verify-pack -v ../filter.pack \
-		| grep -E "commit|tree" \
-		| awk -f print_1.awk \
-		| sort >observed &&
+	git -C r1 verify-pack -v ../all.pack |
+	grep -E "commit|tree" |
+	awk -f print_1.awk |
+	sort >expected &&
+
+	git -C r1 verify-pack -v ../filter.pack |
+	grep -E "commit|tree" |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
@@ -75,17 +82,20 @@ test_expect_success 'setup r2' '
 '
 
 test_expect_success 'verify blob count in normal packfile' '
-	git -C r2 ls-files -s large.1000 large.10000 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r2 ls-files -s large.1000 large.10000 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	git -C r2 pack-objects --rev --stdout >all.pack <<-EOF &&
 	HEAD
 	EOF
 	git -C r2 index-pack ../all.pack &&
-	git -C r2 verify-pack -v ../all.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r2 verify-pack -v ../all.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
@@ -94,10 +104,12 @@ test_expect_success 'verify blob:limit=500 omits all blobs' '
 	HEAD
 	EOF
 	git -C r2 index-pack ../filter.pack &&
-	git -C r2 verify-pack -v ../filter.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r2 verify-pack -v ../filter.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	nr=$(wc -l <observed) &&
 	test 0 -eq $nr
 '
@@ -107,99 +119,118 @@ test_expect_success 'verify blob:limit=1000' '
 	HEAD
 	EOF
 	git -C r2 index-pack ../filter.pack &&
-	git -C r2 verify-pack -v ../filter.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r2 verify-pack -v ../filter.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	nr=$(wc -l <observed) &&
 	test 0 -eq $nr
 '
 
 test_expect_success 'verify blob:limit=1001' '
-	git -C r2 ls-files -s large.1000 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r2 ls-files -s large.1000 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	git -C r2 pack-objects --rev --stdout --filter=blob:limit=1001 >filter.pack <<-EOF &&
 	HEAD
 	EOF
 	git -C r2 index-pack ../filter.pack &&
-	git -C r2 verify-pack -v ../filter.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r2 verify-pack -v ../filter.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify blob:limit=10001' '
-	git -C r2 ls-files -s large.1000 large.10000 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r2 ls-files -s large.1000 large.10000 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	git -C r2 pack-objects --rev --stdout --filter=blob:limit=10001 >filter.pack <<-EOF &&
 	HEAD
 	EOF
 	git -C r2 index-pack ../filter.pack &&
-	git -C r2 verify-pack -v ../filter.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r2 verify-pack -v ../filter.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify blob:limit=1k' '
-	git -C r2 ls-files -s large.1000 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r2 ls-files -s large.1000 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	git -C r2 pack-objects --rev --stdout --filter=blob:limit=1k >filter.pack <<-EOF &&
 	HEAD
 	EOF
 	git -C r2 index-pack ../filter.pack &&
-	git -C r2 verify-pack -v ../filter.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r2 verify-pack -v ../filter.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify explicitly specifying oversized blob in input' '
-	git -C r2 ls-files -s large.1000 large.10000 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r2 ls-files -s large.1000 large.10000 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	git -C r2 pack-objects --rev --stdout --filter=blob:limit=1k >filter.pack <<-EOF &&
 	HEAD
 	$(git -C r2 rev-parse HEAD:large.10000)
 	EOF
 	git -C r2 index-pack ../filter.pack &&
-	git -C r2 verify-pack -v ../filter.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r2 verify-pack -v ../filter.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify blob:limit=1m' '
-	git -C r2 ls-files -s large.1000 large.10000 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r2 ls-files -s large.1000 large.10000 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	git -C r2 pack-objects --rev --stdout --filter=blob:limit=1m >filter.pack <<-EOF &&
 	HEAD
 	EOF
 	git -C r2 index-pack ../filter.pack &&
-	git -C r2 verify-pack -v ../filter.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r2 verify-pack -v ../filter.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify normal and blob:limit packfiles have same commits/trees' '
-	git -C r2 verify-pack -v ../all.pack \
-		| grep -E "commit|tree" \
-		| awk -f print_1.awk \
-		| sort >expected &&
-	git -C r2 verify-pack -v ../filter.pack \
-		| grep -E "commit|tree" \
-		| awk -f print_1.awk \
-		| sort >observed &&
+	git -C r2 verify-pack -v ../all.pack |
+	grep -E "commit|tree" |
+	awk -f print_1.awk |
+	sort >expected &&
+
+	git -C r2 verify-pack -v ../filter.pack |
+	grep -E "commit|tree" |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
@@ -224,71 +255,84 @@ test_expect_success 'setup r3' '
 '
 
 test_expect_success 'verify blob count in normal packfile' '
-	git -C r3 ls-files -s sparse1 sparse2 dir1/sparse1 dir1/sparse2 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r3 ls-files -s sparse1 sparse2 dir1/sparse1 dir1/sparse2 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	git -C r3 pack-objects --rev --stdout >all.pack <<-EOF &&
 	HEAD
 	EOF
 	git -C r3 index-pack ../all.pack &&
-	git -C r3 verify-pack -v ../all.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r3 verify-pack -v ../all.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify sparse:path=pattern1' '
-	git -C r3 ls-files -s dir1/sparse1 dir1/sparse2 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r3 ls-files -s dir1/sparse1 dir1/sparse2 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	git -C r3 pack-objects --rev --stdout --filter=sparse:path=../pattern1 >filter.pack <<-EOF &&
 	HEAD
 	EOF
 	git -C r3 index-pack ../filter.pack &&
-	git -C r3 verify-pack -v ../filter.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r3 verify-pack -v ../filter.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify normal and sparse:path=pattern1 packfiles have same commits/trees' '
-	git -C r3 verify-pack -v ../all.pack \
-		| grep -E "commit|tree" \
-		| awk -f print_1.awk \
-		| sort >expected &&
-	git -C r3 verify-pack -v ../filter.pack \
-		| grep -E "commit|tree" \
-		| awk -f print_1.awk \
-		| sort >observed &&
+	git -C r3 verify-pack -v ../all.pack |
+	grep -E "commit|tree" |
+	awk -f print_1.awk |
+	sort >expected &&
+
+	git -C r3 verify-pack -v ../filter.pack |
+	grep -E "commit|tree" |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify sparse:path=pattern2' '
-	git -C r3 ls-files -s sparse1 dir1/sparse1 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r3 ls-files -s sparse1 dir1/sparse1 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	git -C r3 pack-objects --rev --stdout --filter=sparse:path=../pattern2 >filter.pack <<-EOF &&
 	HEAD
 	EOF
 	git -C r3 index-pack ../filter.pack &&
-	git -C r3 verify-pack -v ../filter.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r3 verify-pack -v ../filter.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify normal and sparse:path=pattern2 packfiles have same commits/trees' '
-	git -C r3 verify-pack -v ../all.pack \
-		| grep -E "commit|tree" \
-		| awk -f print_1.awk \
-		| sort >expected &&
-	git -C r3 verify-pack -v ../filter.pack \
-		| grep -E "commit|tree" \
-		| awk -f print_1.awk \
-		| sort >observed &&
+	git -C r3 verify-pack -v ../all.pack |
+	grep -E "commit|tree" |
+	awk -f print_1.awk |
+	sort >expected &&
+
+	git -C r3 verify-pack -v ../filter.pack |
+	grep -E "commit|tree" |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
@@ -312,48 +356,57 @@ test_expect_success 'setup r4' '
 '
 
 test_expect_success 'verify blob count in normal packfile' '
-	git -C r4 ls-files -s pattern sparse1 sparse2 dir1/sparse1 dir1/sparse2 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r4 ls-files -s pattern sparse1 sparse2 dir1/sparse1 dir1/sparse2 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	git -C r4 pack-objects --rev --stdout >all.pack <<-EOF &&
 	HEAD
 	EOF
 	git -C r4 index-pack ../all.pack &&
-	git -C r4 verify-pack -v ../all.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r4 verify-pack -v ../all.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify sparse:oid=OID' '
-	git -C r4 ls-files -s dir1/sparse1 dir1/sparse2 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r4 ls-files -s dir1/sparse1 dir1/sparse2 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	oid=$(git -C r4 ls-files -s pattern | awk -f print_2.awk) &&
 	git -C r4 pack-objects --rev --stdout --filter=sparse:oid=$oid >filter.pack <<-EOF &&
 	HEAD
 	EOF
 	git -C r4 index-pack ../filter.pack &&
-	git -C r4 verify-pack -v ../filter.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r4 verify-pack -v ../filter.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify sparse:oid=oid-ish' '
-	git -C r4 ls-files -s dir1/sparse1 dir1/sparse2 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r4 ls-files -s dir1/sparse1 dir1/sparse2 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	git -C r4 pack-objects --rev --stdout --filter=sparse:oid=master:pattern >filter.pack <<-EOF &&
 	HEAD
 	EOF
 	git -C r4 index-pack ../filter.pack &&
-	git -C r4 verify-pack -v ../filter.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r4 verify-pack -v ../filter.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
@@ -361,9 +414,10 @@ test_expect_success 'verify sparse:oid=oid-ish' '
 # This models previously omitted objects that we did not receive.
 
 test_expect_success 'setup r1 - delete loose blobs' '
-	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	for id in `cat expected | sed "s|..|&/|"`
 	do
 		rm r1/.git/objects/$id
diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh
index 1b5a4a6d3..086f2c40f 100755
--- a/t/t5500-fetch-pack.sh
+++ b/t/t5500-fetch-pack.sh
@@ -50,8 +50,11 @@ pull_to_client () {
 			case "$heads" in *B*)
 			    git update-ref refs/heads/B "$BTIP";;
 			esac &&
-			git symbolic-ref HEAD refs/heads/$(echo $heads \
-				| sed -e "s/^\(.\).*$/\1/") &&
+
+			git symbolic-ref HEAD refs/heads/$(
+				echo $heads |
+				sed -e "s/^\(.\).*$/\1/"
+			) &&
 
 			git fsck --full &&
 
diff --git a/t/t5616-partial-clone.sh b/t/t5616-partial-clone.sh
index bbbe7537d..e4d032c9d 100755
--- a/t/t5616-partial-clone.sh
+++ b/t/t5616-partial-clone.sh
@@ -34,10 +34,12 @@ test_expect_success 'setup bare clone for server' '
 # confirm partial clone was registered in the local config.
 test_expect_success 'do partial clone 1' '
 	git clone --no-checkout --filter=blob:none "file://$(pwd)/srv.bare" pc1 &&
-	git -C pc1 rev-list HEAD --quiet --objects --missing=print \
-		| awk -f print_1.awk \
-		| sed "s/?//" \
-		| sort >observed.oids &&
+
+	git -C pc1 rev-list HEAD --quiet --objects --missing=print |
+	awk -f print_1.awk |
+	sed "s/?//" |
+	sort >observed.oids &&
+
 	test_cmp expect_1.oids observed.oids &&
 	test "$(git -C pc1 config --local core.repositoryformatversion)" = "1" &&
 	test "$(git -C pc1 config --local extensions.partialclone)" = "origin" &&
@@ -130,16 +132,20 @@ test_expect_success 'push new commits to server for file.3.txt' '
 # perhaps combined with a command in dry-run mode.
 test_expect_success 'manual prefetch of missing objects' '
 	git -C pc1 fetch --filter=blob:none origin &&
-	git -C pc1 rev-list master..origin/master --quiet --objects --missing=print \
-		| awk -f print_1.awk \
-		| sed "s/?//" \
-		| sort >observed.oids &&
+
+	git -C pc1 rev-list master..origin/master --quiet --objects --missing=print |
+	awk -f print_1.awk |
+	sed "s/?//" |
+	sort >observed.oids &&
+
 	test_line_count = 6 observed.oids &&
 	git -C pc1 fetch-pack --stdin "file://$(pwd)/srv.bare" <observed.oids &&
-	git -C pc1 rev-list master..origin/master --quiet --objects --missing=print \
-		| awk -f print_1.awk \
-		| sed "s/?//" \
-		| sort >observed.oids &&
+
+	git -C pc1 rev-list master..origin/master --quiet --objects --missing=print |
+	awk -f print_1.awk |
+	sed "s/?//" |
+	sort >observed.oids &&
+
 	test_line_count = 0 observed.oids
 '
 
@@ -194,7 +200,7 @@ test_expect_success 'upon cloning, check that all refs point to objects' '
 
 	# Craft a packfile not including that blob.
 	git -C "$SERVER" rev-parse HEAD |
-		git -C "$SERVER" pack-objects --stdout >incomplete.pack &&
+	git -C "$SERVER" pack-objects --stdout >incomplete.pack &&
 
 	# Replace the existing packfile with the crafted one. The protocol
 	# requires that the packfile be sent in sideband 1, hence the extra
diff --git a/t/t6112-rev-list-filters-objects.sh b/t/t6112-rev-list-filters-objects.sh
index d4ff0b3be..0f6b569e1 100755
--- a/t/t6112-rev-list-filters-objects.sh
+++ b/t/t6112-rev-list-filters-objects.sh
@@ -20,24 +20,28 @@ test_expect_success 'setup r1' '
 '
 
 test_expect_success 'verify blob:none omits all 5 blobs' '
-	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 \
-		| awk -f print_2.awk \
-		| sort >expected &&
-	git -C r1 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:none \
-		| awk -f print_1.awk \
-		| sed "s/~//" \
-		| sort >observed &&
+	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 |
+	awk -f print_2.awk |
+	sort >expected &&
+
+	git -C r1 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:none |
+	awk -f print_1.awk |
+	sed "s/~//" |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify emitted+omitted == all' '
-	git -C r1 rev-list HEAD --objects \
-		| awk -f print_1.awk \
-		| sort >expected &&
-	git -C r1 rev-list HEAD --objects --filter-print-omitted --filter=blob:none \
-		| awk -f print_1.awk \
-		| sed "s/~//" \
-		| sort >observed &&
+	git -C r1 rev-list HEAD --objects |
+	awk -f print_1.awk |
+	sort >expected &&
+
+	git -C r1 rev-list HEAD --objects --filter-print-omitted --filter=blob:none |
+	awk -f print_1.awk |
+	sed "s/~//" |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
@@ -58,65 +62,76 @@ test_expect_success 'setup r2' '
 '
 
 test_expect_success 'verify blob:limit=500 omits all blobs' '
-	git -C r2 ls-files -s large.1000 large.10000 \
-		| awk -f print_2.awk \
-		| sort >expected &&
-	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=500 \
-		| awk -f print_1.awk \
-		| sed "s/~//" \
-		| sort >observed &&
+	git -C r2 ls-files -s large.1000 large.10000 |
+	awk -f print_2.awk |
+	sort >expected &&
+
+	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=500 |
+	awk -f print_1.awk |
+	sed "s/~//" |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify emitted+omitted == all' '
-	git -C r2 rev-list HEAD --objects \
-		| awk -f print_1.awk \
-		| sort >expected &&
-	git -C r2 rev-list HEAD --objects --filter-print-omitted --filter=blob:limit=500 \
-		| awk -f print_1.awk \
-		| sed "s/~//" \
-		| sort >observed &&
+	git -C r2 rev-list HEAD --objects |
+	awk -f print_1.awk |
+	sort >expected &&
+
+	git -C r2 rev-list HEAD --objects --filter-print-omitted --filter=blob:limit=500 |
+	awk -f print_1.awk |
+	sed "s/~//" |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify blob:limit=1000' '
-	git -C r2 ls-files -s large.1000 large.10000 \
-		| awk -f print_2.awk \
-		| sort >expected &&
-	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1000 \
-		| awk -f print_1.awk \
-		| sed "s/~//" \
-		| sort >observed &&
+	git -C r2 ls-files -s large.1000 large.10000 |
+	awk -f print_2.awk |
+	sort >expected &&
+
+	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1000 |
+	awk -f print_1.awk |
+	sed "s/~//" |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify blob:limit=1001' '
-	git -C r2 ls-files -s large.10000 \
-		| awk -f print_2.awk \
-		| sort >expected &&
-	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1001 \
-		| awk -f print_1.awk \
-		| sed "s/~//" \
-		| sort >observed &&
+	git -C r2 ls-files -s large.10000 |
+	awk -f print_2.awk |
+	sort >expected &&
+
+	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1001 |
+	awk -f print_1.awk |
+	sed "s/~//" |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify blob:limit=1k' '
-	git -C r2 ls-files -s large.10000 \
-		| awk -f print_2.awk \
-		| sort >expected &&
-	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1k \
-		| awk -f print_1.awk \
-		| sed "s/~//" \
-		| sort >observed &&
+	git -C r2 ls-files -s large.10000 |
+	awk -f print_2.awk |
+	sort >expected &&
+
+	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1k |
+	awk -f print_1.awk |
+	sed "s/~//" |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify blob:limit=1m' '
-	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1m \
-		| awk -f print_1.awk \
-		| sed "s/~//" \
-		| sort >observed &&
+	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1m |
+	awk -f print_1.awk |
+	sed "s/~//" |
+	sort >observed &&
+
 	test_must_be_empty observed
 '
 
@@ -141,24 +156,28 @@ test_expect_success 'setup r3' '
 '
 
 test_expect_success 'verify sparse:path=pattern1 omits top-level files' '
-	git -C r3 ls-files -s sparse1 sparse2 \
-		| awk -f print_2.awk \
-		| sort >expected &&
-	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:path=../pattern1 \
-		| awk -f print_1.awk \
-		| sed "s/~//" \
-		| sort >observed &&
+	git -C r3 ls-files -s sparse1 sparse2 |
+	awk -f print_2.awk |
+	sort >expected &&
+
+	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:path=../pattern1 |
+	awk -f print_1.awk |
+	sed "s/~//" |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify sparse:path=pattern2 omits both sparse2 files' '
-	git -C r3 ls-files -s sparse2 dir1/sparse2 \
-		| awk -f print_2.awk \
-		| sort >expected &&
-	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:path=../pattern2 \
-		| awk -f print_1.awk \
-		| sed "s/~//" \
-		| sort >observed &&
+	git -C r3 ls-files -s sparse2 dir1/sparse2 |
+	awk -f print_2.awk |
+	sort >expected &&
+
+	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:path=../pattern2 |
+	awk -f print_1.awk |
+	sed "s/~//" |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
@@ -173,25 +192,30 @@ test_expect_success 'setup r3 part 2' '
 '
 
 test_expect_success 'verify sparse:oid=OID omits top-level files' '
-	git -C r3 ls-files -s pattern sparse1 sparse2 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r3 ls-files -s pattern sparse1 sparse2 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	oid=$(git -C r3 ls-files -s pattern | awk -f print_2.awk) &&
-	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:oid=$oid \
-		| awk -f print_1.awk \
-		| sed "s/~//" \
-		| sort >observed &&
+
+	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:oid=$oid |
+	awk -f print_1.awk |
+	sed "s/~//" |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify sparse:oid=oid-ish omits top-level files' '
-	git -C r3 ls-files -s pattern sparse1 sparse2 \
-		| awk -f print_2.awk \
-		| sort >expected &&
-	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:oid=master:pattern \
-		| awk -f print_1.awk \
-		| sed "s/~//" \
-		| sort >observed &&
+	git -C r3 ls-files -s pattern sparse1 sparse2 |
+	awk -f print_2.awk |
+	sort >expected &&
+
+	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:oid=master:pattern |
+	awk -f print_1.awk |
+	sed "s/~//" |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
@@ -199,17 +223,20 @@ test_expect_success 'verify sparse:oid=oid-ish omits top-level files' '
 # This models previously omitted objects that we did not receive.
 
 test_expect_success 'rev-list W/ --missing=print' '
-	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	for id in `cat expected | sed "s|..|&/|"`
 	do
 		rm r1/.git/objects/$id
 	done &&
-	git -C r1 rev-list --quiet HEAD --missing=print --objects \
-		| awk -f print_1.awk \
-		| sed "s/?//" \
-		| sort >observed &&
+
+	git -C r1 rev-list --quiet HEAD --missing=print --objects |
+	awk -f print_1.awk |
+	sed "s/?//" |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
-- 
2.19.0.605.g01d371f741-goog


^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [PATCH v4 4/7] t/*: fix ordering of expected/observed arguments
  2018-10-03 16:25 ` [PATCH v4 0/7] Clean up tests for test_cmp arg ordering and pipe placement Matthew DeVore
                     ` (2 preceding siblings ...)
  2018-10-03 16:26   ` [PATCH v4 3/7] tests: standardize pipe placement Matthew DeVore
@ 2018-10-03 16:26   ` Matthew DeVore
  2018-10-03 16:26   ` [PATCH v4 5/7] tests: don't swallow Git errors upstream of pipes Matthew DeVore
                     ` (2 subsequent siblings)
  6 siblings, 0 replies; 66+ messages in thread
From: Matthew DeVore @ 2018-10-03 16:26 UTC (permalink / raw)
  To: git; +Cc: Matthew DeVore, peff, jonathantanmy, gitster, jrn, sunshine,
	szeder.dev

Fix various places where the ordering was obviously wrong, meaning it
was easy to find with grep.

Signed-off-by: Matthew DeVore <matvore@google.com>
---
 t/t0000-basic.sh                       |  2 +-
 t/t0021-conversion.sh                  |  4 +--
 t/t1300-config.sh                      |  4 +--
 t/t1303-wacky-config.sh                |  4 +--
 t/t2101-update-index-reupdate.sh       |  2 +-
 t/t3200-branch.sh                      |  2 +-
 t/t3320-notes-merge-worktrees.sh       |  4 +--
 t/t3400-rebase.sh                      |  8 +++---
 t/t3417-rebase-whitespace-fix.sh       |  6 ++---
 t/t3702-add-edit.sh                    |  4 +--
 t/t3903-stash.sh                       |  8 +++---
 t/t3905-stash-include-untracked.sh     |  2 +-
 t/t4025-hunk-header.sh                 |  2 +-
 t/t4117-apply-reject.sh                |  6 ++---
 t/t4124-apply-ws-rule.sh               | 30 +++++++++++------------
 t/t4138-apply-ws-expansion.sh          |  2 +-
 t/t5317-pack-objects-filter-objects.sh | 34 +++++++++++++-------------
 t/t5318-commit-graph.sh                |  2 +-
 t/t5701-git-serve.sh                   | 14 +++++------
 t/t5702-protocol-v2.sh                 | 10 ++++----
 t/t6023-merge-file.sh                  | 12 ++++-----
 t/t6027-merge-binary.sh                |  4 +--
 t/t6031-merge-filemode.sh              |  2 +-
 t/t6112-rev-list-filters-objects.sh    | 24 +++++++++---------
 t/t7201-co.sh                          |  4 +--
 t/t7406-submodule-update.sh            |  8 +++---
 t/t7800-difftool.sh                    |  2 +-
 t/t9100-git-svn-basic.sh               |  2 +-
 t/t9133-git-svn-nested-git-repo.sh     |  6 ++---
 t/t9600-cvsimport.sh                   |  2 +-
 t/t9603-cvsimport-patchsets.sh         |  4 +--
 t/t9604-cvsimport-timestamps.sh        |  4 +--
 32 files changed, 112 insertions(+), 112 deletions(-)

diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh
index 850f651e4..224c098a8 100755
--- a/t/t0000-basic.sh
+++ b/t/t0000-basic.sh
@@ -1018,7 +1018,7 @@ test_expect_success SHA1 'validate git diff-files output for a know cache/work t
 :120000 120000 6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c 0000000000000000000000000000000000000000 M	path3/subp3/file3sym
 EOF
 	git diff-files >current &&
-	test_cmp current expected
+	test_cmp expected current
 '
 
 test_expect_success 'git update-index --refresh should succeed' '
diff --git a/t/t0021-conversion.sh b/t/t0021-conversion.sh
index 308cd28f3..fd5f1ac64 100755
--- a/t/t0021-conversion.sh
+++ b/t/t0021-conversion.sh
@@ -166,10 +166,10 @@ test_expect_success expanded_in_repo '
 	rm -f expanded-keywords expanded-keywords-crlf &&
 
 	git checkout -- expanded-keywords &&
-	test_cmp expanded-keywords expected-output &&
+	test_cmp expected-output expanded-keywords &&
 
 	git checkout -- expanded-keywords-crlf &&
-	test_cmp expanded-keywords-crlf expected-output-crlf
+	test_cmp expected-output-crlf expanded-keywords-crlf
 '
 
 # The use of %f in a filter definition is expanded to the path to
diff --git a/t/t1300-config.sh b/t/t1300-config.sh
index 5869d6cb6..e2cd50ecf 100755
--- a/t/t1300-config.sh
+++ b/t/t1300-config.sh
@@ -1001,7 +1001,7 @@ EOF
 
 test_expect_success 'value continued on next line' '
 	git config --list > result &&
-	test_cmp result expect
+	test_cmp expect result
 '
 
 cat > .git/config <<\EOF
@@ -1882,7 +1882,7 @@ test_expect_success '--replace-all does not invent newlines' '
 	Qkey = b
 	EOF
 	git config --replace-all abc.key b &&
-	test_cmp .git/config expect
+	test_cmp expect .git/config
 '
 
 test_done
diff --git a/t/t1303-wacky-config.sh b/t/t1303-wacky-config.sh
index 3b92083e1..0000e664e 100755
--- a/t/t1303-wacky-config.sh
+++ b/t/t1303-wacky-config.sh
@@ -14,7 +14,7 @@ setup() {
 check() {
 	echo "$2" >expected
 	git config --get "$1" >actual 2>&1
-	test_cmp actual expected
+	test_cmp expected actual
 }
 
 # 'check section.key regex value' verifies that the entry for
@@ -22,7 +22,7 @@ check() {
 check_regex() {
 	echo "$3" >expected
 	git config --get "$1" "$2" >actual 2>&1
-	test_cmp actual expected
+	test_cmp expected actual
 }
 
 test_expect_success 'modify same key' '
diff --git a/t/t2101-update-index-reupdate.sh b/t/t2101-update-index-reupdate.sh
index 685ec4563..6c32d42c8 100755
--- a/t/t2101-update-index-reupdate.sh
+++ b/t/t2101-update-index-reupdate.sh
@@ -73,7 +73,7 @@ test_expect_success 'update-index --update from subdir' '
 	100644 $(git hash-object dir1/file3) 0	dir1/file3
 	100644 $file2 0	file2
 	EOF
-	test_cmp current expected
+	test_cmp expected current
 '
 
 test_expect_success 'update-index --update with pathspec' '
diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index 93f21ab07..478b82cf9 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -1221,7 +1221,7 @@ test_expect_success 'use --edit-description' '
 	EOF
 	EDITOR=./editor git branch --edit-description &&
 	echo "New contents" >expect &&
-	test_cmp EDITOR_OUTPUT expect
+	test_cmp expect EDITOR_OUTPUT
 '
 
 test_expect_success 'detect typo in branch name when using --edit-description' '
diff --git a/t/t3320-notes-merge-worktrees.sh b/t/t3320-notes-merge-worktrees.sh
index 10bfc8b94..823fdbda1 100755
--- a/t/t3320-notes-merge-worktrees.sh
+++ b/t/t3320-notes-merge-worktrees.sh
@@ -44,7 +44,7 @@ test_expect_success 'merge z into y fails and sets NOTES_MERGE_REF' '
 	git config core.notesRef refs/notes/y &&
 	test_must_fail git notes merge z &&
 	echo "ref: refs/notes/y" >expect &&
-	test_cmp .git/NOTES_MERGE_REF expect
+	test_cmp expect .git/NOTES_MERGE_REF
 '
 
 test_expect_success 'merge z into y while mid-merge in another workdir fails' '
@@ -66,7 +66,7 @@ test_expect_success 'merge z into x while mid-merge on y succeeds' '
 		grep -v "A notes merge into refs/notes/x is already in-progress in" out
 	) &&
 	echo "ref: refs/notes/x" >expect &&
-	test_cmp .git/worktrees/worktree2/NOTES_MERGE_REF expect
+	test_cmp expect .git/worktrees/worktree2/NOTES_MERGE_REF
 '
 
 test_done
diff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh
index 3996ee013..3e73f7584 100755
--- a/t/t3400-rebase.sh
+++ b/t/t3400-rebase.sh
@@ -183,13 +183,13 @@ test_expect_success 'cherry-picked commits and fork-point work together' '
 	test_commit final_B B "Final B" &&
 	git rebase &&
 	echo Amended >expect &&
-	test_cmp A expect &&
+	test_cmp expect A &&
 	echo "Final B" >expect &&
-	test_cmp B expect &&
+	test_cmp expect B &&
 	echo C >expect &&
-	test_cmp C expect &&
+	test_cmp expect C &&
 	echo D >expect &&
-	test_cmp D expect
+	test_cmp expect D
 '
 
 test_expect_success 'rebase -q is quiet' '
diff --git a/t/t3417-rebase-whitespace-fix.sh b/t/t3417-rebase-whitespace-fix.sh
index 1fb3e499b..e85cdc703 100755
--- a/t/t3417-rebase-whitespace-fix.sh
+++ b/t/t3417-rebase-whitespace-fix.sh
@@ -55,7 +55,7 @@ test_expect_success 'blank line at end of file; extend at end of file' '
 	git add file &&	git commit -m second &&
 	git rebase --whitespace=fix HEAD^^ &&
 	git diff --exit-code HEAD^:file expect-first &&
-	test_cmp file expect-second
+	test_cmp expect-second file
 '
 
 # prepare third revision of "file"
@@ -82,7 +82,7 @@ test_expect_success 'two blanks line at end of file; extend at end of file' '
 	cp third file && git add file && git commit -m third &&
 	git rebase --whitespace=fix HEAD^^ &&
 	git diff --exit-code HEAD^:file expect-second &&
-	test_cmp file expect-third
+	test_cmp expect-third file
 '
 
 test_expect_success 'same, but do not remove trailing spaces' '
@@ -120,7 +120,7 @@ test_expect_success 'at beginning of file' '
 	done >> file &&
 	git commit -m more file	&&
 	git rebase --whitespace=fix HEAD^^ &&
-	test_cmp file expect-beginning
+	test_cmp expect-beginning file
 '
 
 test_done
diff --git a/t/t3702-add-edit.sh b/t/t3702-add-edit.sh
index c6af7f82b..6c676645d 100755
--- a/t/t3702-add-edit.sh
+++ b/t/t3702-add-edit.sh
@@ -110,10 +110,10 @@ test_expect_success 'add -e' '
 	cp second-part file &&
 	git add -e &&
 	test_cmp second-part file &&
-	test_cmp orig-patch expected-patch &&
+	test_cmp expected-patch orig-patch &&
 	git diff --cached >actual &&
 	grep -v index actual >out &&
-	test_cmp out expected
+	test_cmp expected out
 
 '
 
diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh
index 6450bc669..cd216655b 100755
--- a/t/t3903-stash.sh
+++ b/t/t3903-stash.sh
@@ -36,7 +36,7 @@ EOF
 test_expect_success 'parents of stash' '
 	test $(git rev-parse stash^) = $(git rev-parse HEAD) &&
 	git diff stash^2..stash > output &&
-	test_cmp output expect
+	test_cmp expect output
 '
 
 test_expect_success 'applying bogus stash does nothing' '
@@ -210,9 +210,9 @@ test_expect_success 'stash branch' '
 	test refs/heads/stashbranch = $(git symbolic-ref HEAD) &&
 	test $(git rev-parse HEAD) = $(git rev-parse master^) &&
 	git diff --cached > output &&
-	test_cmp output expect &&
+	test_cmp expect output &&
 	git diff > output &&
-	test_cmp output expect1 &&
+	test_cmp expect1 output &&
 	git add file &&
 	git commit -m alternate\ second &&
 	git diff master..stashbranch > output &&
@@ -710,7 +710,7 @@ test_expect_success 'stash where working directory contains "HEAD" file' '
 	git diff-index --cached --quiet HEAD &&
 	test "$(git rev-parse stash^)" = "$(git rev-parse HEAD)" &&
 	git diff stash^..stash > output &&
-	test_cmp output expect
+	test_cmp expect output
 '
 
 test_expect_success 'store called with invalid commit' '
diff --git a/t/t3905-stash-include-untracked.sh b/t/t3905-stash-include-untracked.sh
index 597b0637d..cc1c8a7bb 100755
--- a/t/t3905-stash-include-untracked.sh
+++ b/t/t3905-stash-include-untracked.sh
@@ -142,7 +142,7 @@ test_expect_success 'stash save --include-untracked removed files' '
 	rm -f file &&
 	git stash save --include-untracked &&
 	echo 1 > expect &&
-	test_cmp file expect
+	test_cmp expect file
 '
 
 rm -f expect
diff --git a/t/t4025-hunk-header.sh b/t/t4025-hunk-header.sh
index fa44e7886..35578f2bb 100755
--- a/t/t4025-hunk-header.sh
+++ b/t/t4025-hunk-header.sh
@@ -37,7 +37,7 @@ test_expect_success 'hunk header truncation with an overly long line' '
 		echo " A $N$N$N$N$N$N$N$N$N2" &&
 		echo " L  $N$N$N$N$N$N$N$N$N1"
 	) >expected &&
-	test_cmp actual expected
+	test_cmp expected actual
 
 '
 
diff --git a/t/t4117-apply-reject.sh b/t/t4117-apply-reject.sh
index d80187de9..f7de6f077 100755
--- a/t/t4117-apply-reject.sh
+++ b/t/t4117-apply-reject.sh
@@ -72,7 +72,7 @@ test_expect_success 'apply with --reject should fail but update the file' '
 	rm -f file1.rej file2.rej &&
 
 	test_must_fail git apply --reject patch.1 &&
-	test_cmp file1 expected &&
+	test_cmp expected file1 &&
 
 	cat file1.rej &&
 	test_path_is_missing file2.rej
@@ -85,7 +85,7 @@ test_expect_success 'apply with --reject should fail but update the file' '
 
 	test_must_fail git apply --reject patch.2 >rejects &&
 	test_path_is_missing file1 &&
-	test_cmp file2 expected &&
+	test_cmp expected file2 &&
 
 	cat file2.rej &&
 	test_path_is_missing file1.rej
@@ -99,7 +99,7 @@ test_expect_success 'the same test with --verbose' '
 
 	test_must_fail git apply --reject --verbose patch.2 >rejects &&
 	test_path_is_missing file1 &&
-	test_cmp file2 expected &&
+	test_cmp expected file2 &&
 
 	cat file2.rej &&
 	test_path_is_missing file1.rej
diff --git a/t/t4124-apply-ws-rule.sh b/t/t4124-apply-ws-rule.sh
index 7e32237a2..ff51e9e78 100755
--- a/t/t4124-apply-ws-rule.sh
+++ b/t/t4124-apply-ws-rule.sh
@@ -313,9 +313,9 @@ test_expect_success 'applying beyond EOF requires one non-blank context line' '
 	{ echo a; echo; } >one &&
 	cp one expect &&
 	test_must_fail git apply --whitespace=fix patch &&
-	test_cmp one expect &&
+	test_cmp expect one &&
 	test_must_fail git apply --ignore-space-change --whitespace=fix patch &&
-	test_cmp one expect
+	test_cmp expect one
 '
 
 test_expect_success 'tons of blanks at EOF should not apply' '
@@ -342,10 +342,10 @@ test_expect_success 'missing blank line at end with --whitespace=fix' '
 	cp one saved-one &&
 	test_must_fail git apply patch &&
 	git apply --whitespace=fix patch &&
-	test_cmp one expect &&
+	test_cmp expect one &&
 	mv saved-one one &&
 	git apply --ignore-space-change --whitespace=fix patch &&
-	test_cmp one expect
+	test_cmp expect one
 '
 
 test_expect_success 'two missing blank lines at end with --whitespace=fix' '
@@ -360,11 +360,11 @@ test_expect_success 'two missing blank lines at end with --whitespace=fix' '
 	cp no-blank-lines one &&
 	test_must_fail git apply patch &&
 	git apply --whitespace=fix patch &&
-	test_cmp one expect &&
+	test_cmp expect one &&
 	mv no-blank-lines one &&
 	test_must_fail git apply patch &&
 	git apply --ignore-space-change --whitespace=fix patch &&
-	test_cmp one expect
+	test_cmp expect one
 '
 
 test_expect_success 'missing blank line at end, insert before end, --whitespace=fix' '
@@ -376,7 +376,7 @@ test_expect_success 'missing blank line at end, insert before end, --whitespace=
 	echo a >one &&
 	test_must_fail git apply patch &&
 	git apply --whitespace=fix patch &&
-	test_cmp one expect
+	test_cmp expect one
 '
 
 test_expect_success 'shrink file with tons of missing blanks at end of file' '
@@ -392,10 +392,10 @@ test_expect_success 'shrink file with tons of missing blanks at end of file' '
 	cp no-blank-lines one &&
 	test_must_fail git apply patch &&
 	git apply --whitespace=fix patch &&
-	test_cmp one expect &&
+	test_cmp expect one &&
 	mv no-blank-lines one &&
 	git apply --ignore-space-change --whitespace=fix patch &&
-	test_cmp one expect
+	test_cmp expect one
 '
 
 test_expect_success 'missing blanks at EOF must only match blank lines' '
@@ -427,7 +427,7 @@ test_expect_success 'missing blank line should match context line with spaces' '
 	git add one &&
 
 	git apply --whitespace=fix patch &&
-	test_cmp one expect
+	test_cmp expect one
 '
 
 sed -e's/Z//' >one <<EOF
@@ -447,7 +447,7 @@ test_expect_success 'same, but with the --ignore-space-option' '
 
 	git checkout-index -f one &&
 	git apply --ignore-space-change --whitespace=fix patch &&
-	test_cmp one expect
+	test_cmp expect one
 '
 
 test_expect_success 'same, but with CR-LF line endings && cr-at-eol set' '
@@ -464,7 +464,7 @@ test_expect_success 'same, but with CR-LF line endings && cr-at-eol set' '
 	mv save-one one &&
 
 	git apply --ignore-space-change --whitespace=fix patch &&
-	test_cmp one expect
+	test_cmp expect one
 '
 
 test_expect_success 'CR-LF line endings && add line && text=auto' '
@@ -478,7 +478,7 @@ test_expect_success 'CR-LF line endings && add line && text=auto' '
 	mv save-one one &&
 	echo "one text=auto" >.gitattributes &&
 	git apply patch &&
-	test_cmp one expect
+	test_cmp expect one
 '
 
 test_expect_success 'CR-LF line endings && change line && text=auto' '
@@ -491,7 +491,7 @@ test_expect_success 'CR-LF line endings && change line && text=auto' '
 	mv save-one one &&
 	echo "one text=auto" >.gitattributes &&
 	git apply patch &&
-	test_cmp one expect
+	test_cmp expect one
 '
 
 test_expect_success 'LF in repo, CRLF in worktree && change line && text=auto' '
@@ -503,7 +503,7 @@ test_expect_success 'LF in repo, CRLF in worktree && change line && text=auto' '
 	echo "one text=auto" >.gitattributes &&
 	git -c core.eol=CRLF apply patch &&
 	printf "b\r\n" >expect &&
-	test_cmp one expect
+	test_cmp expect one
 '
 
 test_expect_success 'whitespace=fix to expand' '
diff --git a/t/t4138-apply-ws-expansion.sh b/t/t4138-apply-ws-expansion.sh
index 0ffe33fbe..3b636a63a 100755
--- a/t/t4138-apply-ws-expansion.sh
+++ b/t/t4138-apply-ws-expansion.sh
@@ -114,7 +114,7 @@ for t in 1 2 3 4
 do
 	test_expect_success 'apply with ws expansion (t=$t)' '
 		git apply patch$t.patch &&
-		test_cmp test-$t expect-$t
+		test_cmp expect-$t test-$t
 	'
 done
 
diff --git a/t/t5317-pack-objects-filter-objects.sh b/t/t5317-pack-objects-filter-objects.sh
index ce69148ec..c093eb891 100755
--- a/t/t5317-pack-objects-filter-objects.sh
+++ b/t/t5317-pack-objects-filter-objects.sh
@@ -34,7 +34,7 @@ test_expect_success 'verify blob count in normal packfile' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify blob:none packfile has no blobs' '
@@ -63,7 +63,7 @@ test_expect_success 'verify normal and blob:none packfiles have same commits/tre
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 # Test blob:limit=<n>[kmg] filter.
@@ -96,7 +96,7 @@ test_expect_success 'verify blob count in normal packfile' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify blob:limit=500 omits all blobs' '
@@ -144,7 +144,7 @@ test_expect_success 'verify blob:limit=1001' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify blob:limit=10001' '
@@ -162,7 +162,7 @@ test_expect_success 'verify blob:limit=10001' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify blob:limit=1k' '
@@ -180,7 +180,7 @@ test_expect_success 'verify blob:limit=1k' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify explicitly specifying oversized blob in input' '
@@ -199,7 +199,7 @@ test_expect_success 'verify explicitly specifying oversized blob in input' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify blob:limit=1m' '
@@ -217,7 +217,7 @@ test_expect_success 'verify blob:limit=1m' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify normal and blob:limit packfiles have same commits/trees' '
@@ -231,7 +231,7 @@ test_expect_success 'verify normal and blob:limit packfiles have same commits/tr
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 # Test sparse:path=<path> filter.
@@ -269,7 +269,7 @@ test_expect_success 'verify blob count in normal packfile' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify sparse:path=pattern1' '
@@ -287,7 +287,7 @@ test_expect_success 'verify sparse:path=pattern1' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify normal and sparse:path=pattern1 packfiles have same commits/trees' '
@@ -301,7 +301,7 @@ test_expect_success 'verify normal and sparse:path=pattern1 packfiles have same
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify sparse:path=pattern2' '
@@ -319,7 +319,7 @@ test_expect_success 'verify sparse:path=pattern2' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify normal and sparse:path=pattern2 packfiles have same commits/trees' '
@@ -333,7 +333,7 @@ test_expect_success 'verify normal and sparse:path=pattern2 packfiles have same
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 # Test sparse:oid=<oid-ish> filter.
@@ -370,7 +370,7 @@ test_expect_success 'verify blob count in normal packfile' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify sparse:oid=OID' '
@@ -389,7 +389,7 @@ test_expect_success 'verify sparse:oid=OID' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify sparse:oid=oid-ish' '
@@ -407,7 +407,7 @@ test_expect_success 'verify sparse:oid=oid-ish' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 # Delete some loose objects and use pack-objects, but WITHOUT any filtering.
diff --git a/t/t5318-commit-graph.sh b/t/t5318-commit-graph.sh
index 0c500f7ca..d6da3ce4e 100755
--- a/t/t5318-commit-graph.sh
+++ b/t/t5318-commit-graph.sh
@@ -35,7 +35,7 @@ test_expect_success 'create commits and repack' '
 graph_git_two_modes() {
 	git -c core.commitGraph=true $1 >output
 	git -c core.commitGraph=false $1 >expect
-	test_cmp output expect
+	test_cmp expect output
 }
 
 graph_git_behavior() {
diff --git a/t/t5701-git-serve.sh b/t/t5701-git-serve.sh
index 75ec79e6c..bf139e245 100755
--- a/t/t5701-git-serve.sh
+++ b/t/t5701-git-serve.sh
@@ -16,7 +16,7 @@ test_expect_success 'test capability advertisement' '
 
 	git serve --advertise-capabilities >out &&
 	test-pkt-line unpack <out >actual &&
-	test_cmp actual expect
+	test_cmp expect actual
 '
 
 test_expect_success 'stateless-rpc flag does not list capabilities' '
@@ -89,7 +89,7 @@ test_expect_success 'basics of ls-refs' '
 
 	git serve --stateless-rpc <in >out &&
 	test-pkt-line unpack <out >actual &&
-	test_cmp actual expect
+	test_cmp expect actual
 '
 
 test_expect_success 'basic ref-prefixes' '
@@ -109,7 +109,7 @@ test_expect_success 'basic ref-prefixes' '
 
 	git serve --stateless-rpc <in >out &&
 	test-pkt-line unpack <out >actual &&
-	test_cmp actual expect
+	test_cmp expect actual
 '
 
 test_expect_success 'refs/heads prefix' '
@@ -129,7 +129,7 @@ test_expect_success 'refs/heads prefix' '
 
 	git serve --stateless-rpc <in >out &&
 	test-pkt-line unpack <out >actual &&
-	test_cmp actual expect
+	test_cmp expect actual
 '
 
 test_expect_success 'peel parameter' '
@@ -150,7 +150,7 @@ test_expect_success 'peel parameter' '
 
 	git serve --stateless-rpc <in >out &&
 	test-pkt-line unpack <out >actual &&
-	test_cmp actual expect
+	test_cmp expect actual
 '
 
 test_expect_success 'symrefs parameter' '
@@ -171,7 +171,7 @@ test_expect_success 'symrefs parameter' '
 
 	git serve --stateless-rpc <in >out &&
 	test-pkt-line unpack <out >actual &&
-	test_cmp actual expect
+	test_cmp expect actual
 '
 
 test_expect_success 'sending server-options' '
@@ -191,7 +191,7 @@ test_expect_success 'sending server-options' '
 
 	git serve --stateless-rpc <in >out &&
 	test-pkt-line unpack <out >actual &&
-	test_cmp actual expect
+	test_cmp expect actual
 '
 
 test_expect_success 'unexpected lines are not allowed in fetch request' '
diff --git a/t/t5702-protocol-v2.sh b/t/t5702-protocol-v2.sh
index 3beeed454..54727450b 100755
--- a/t/t5702-protocol-v2.sh
+++ b/t/t5702-protocol-v2.sh
@@ -29,7 +29,7 @@ test_expect_success 'list refs with git:// using protocol v2' '
 	grep "git< version 2" log &&
 
 	git ls-remote --symref "$GIT_DAEMON_URL/parent" >expect &&
-	test_cmp actual expect
+	test_cmp expect actual
 '
 
 test_expect_success 'ref advertisment is filtered with ls-remote using protocol v2' '
@@ -42,7 +42,7 @@ test_expect_success 'ref advertisment is filtered with ls-remote using protocol
 	$(git -C "$daemon_parent" rev-parse refs/heads/master)$(printf "\t")refs/heads/master
 	EOF
 
-	test_cmp actual expect
+	test_cmp expect actual
 '
 
 test_expect_success 'clone with git:// using protocol v2' '
@@ -138,7 +138,7 @@ test_expect_success 'list refs with file:// using protocol v2' '
 	grep "git< version 2" log &&
 
 	git ls-remote --symref "file://$(pwd)/file_parent" >expect &&
-	test_cmp actual expect
+	test_cmp expect actual
 '
 
 test_expect_success 'ref advertisment is filtered with ls-remote using protocol v2' '
@@ -151,7 +151,7 @@ test_expect_success 'ref advertisment is filtered with ls-remote using protocol
 	$(git -C file_parent rev-parse refs/heads/master)$(printf "\t")refs/heads/master
 	EOF
 
-	test_cmp actual expect
+	test_cmp expect actual
 '
 
 test_expect_success 'server-options are sent when using ls-remote' '
@@ -164,7 +164,7 @@ test_expect_success 'server-options are sent when using ls-remote' '
 	$(git -C file_parent rev-parse refs/heads/master)$(printf "\t")refs/heads/master
 	EOF
 
-	test_cmp actual expect &&
+	test_cmp expect actual &&
 	grep "server-option=hello" log &&
 	grep "server-option=world" log
 '
diff --git a/t/t6023-merge-file.sh b/t/t6023-merge-file.sh
index 20aee43f9..51ee887a7 100755
--- a/t/t6023-merge-file.sh
+++ b/t/t6023-merge-file.sh
@@ -99,7 +99,7 @@ EOF
 printf "propter nomen suum." >> expect.txt
 
 test_expect_success "merge does not add LF away of change" \
-	"test_cmp test3.txt expect.txt"
+	"test_cmp expect.txt test3.txt"
 
 cp test.txt backup.txt
 test_expect_success "merge with conflicts" \
@@ -122,7 +122,7 @@ non timebo mala, quoniam tu mecum es:
 virga tua et baculus tuus ipsa me consolata sunt.
 EOF
 
-test_expect_success "expected conflict markers" "test_cmp test.txt expect.txt"
+test_expect_success "expected conflict markers" "test_cmp expect.txt test.txt"
 
 cp backup.txt test.txt
 
@@ -138,7 +138,7 @@ non timebo mala, quoniam tu mecum es:
 virga tua et baculus tuus ipsa me consolata sunt.
 EOF
 test_expect_success "merge conflicting with --ours" \
-	"git merge-file --ours test.txt orig.txt new3.txt && test_cmp test.txt expect.txt"
+	"git merge-file --ours test.txt orig.txt new3.txt && test_cmp expect.txt test.txt"
 cp backup.txt test.txt
 
 cat > expect.txt << EOF
@@ -154,7 +154,7 @@ non timebo mala, quoniam tu mecum es:
 virga tua et baculus tuus ipsa me consolata sunt.
 EOF
 test_expect_success "merge conflicting with --theirs" \
-	"git merge-file --theirs test.txt orig.txt new3.txt && test_cmp test.txt expect.txt"
+	"git merge-file --theirs test.txt orig.txt new3.txt && test_cmp expect.txt test.txt"
 cp backup.txt test.txt
 
 cat > expect.txt << EOF
@@ -171,7 +171,7 @@ non timebo mala, quoniam tu mecum es:
 virga tua et baculus tuus ipsa me consolata sunt.
 EOF
 test_expect_success "merge conflicting with --union" \
-	"git merge-file --union test.txt orig.txt new3.txt && test_cmp test.txt expect.txt"
+	"git merge-file --union test.txt orig.txt new3.txt && test_cmp expect.txt test.txt"
 cp backup.txt test.txt
 
 test_expect_success "merge with conflicts, using -L" \
@@ -195,7 +195,7 @@ virga tua et baculus tuus ipsa me consolata sunt.
 EOF
 
 test_expect_success "expected conflict markers, with -L" \
-	"test_cmp test.txt expect.txt"
+	"test_cmp expect.txt test.txt"
 
 sed "s/ tu / TU /" < new1.txt > new5.txt
 test_expect_success "conflict in removed tail" \
diff --git a/t/t6027-merge-binary.sh b/t/t6027-merge-binary.sh
index 07735410b..4e6c7cb77 100755
--- a/t/t6027-merge-binary.sh
+++ b/t/t6027-merge-binary.sh
@@ -45,7 +45,7 @@ test_expect_success resolve '
 		false
 	else
 		git ls-files -s >current
-		test_cmp current expect
+		test_cmp expect current
 	fi
 '
 
@@ -60,7 +60,7 @@ test_expect_success recursive '
 		false
 	else
 		git ls-files -s >current
-		test_cmp current expect
+		test_cmp expect current
 	fi
 '
 
diff --git a/t/t6031-merge-filemode.sh b/t/t6031-merge-filemode.sh
index 7d06461f1..87741efad 100755
--- a/t/t6031-merge-filemode.sh
+++ b/t/t6031-merge-filemode.sh
@@ -61,7 +61,7 @@ do_both_modes () {
 		git checkout -f a2 &&
 		test_must_fail git merge -s $strategy b2 &&
 		git ls-files -u >actual &&
-		test_cmp actual expect &&
+		test_cmp expect actual &&
 		git ls-files -s file2 | grep ^100755
 	'
 
diff --git a/t/t6112-rev-list-filters-objects.sh b/t/t6112-rev-list-filters-objects.sh
index 0f6b569e1..ae4402226 100755
--- a/t/t6112-rev-list-filters-objects.sh
+++ b/t/t6112-rev-list-filters-objects.sh
@@ -29,7 +29,7 @@ test_expect_success 'verify blob:none omits all 5 blobs' '
 	sed "s/~//" |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify emitted+omitted == all' '
@@ -42,7 +42,7 @@ test_expect_success 'verify emitted+omitted == all' '
 	sed "s/~//" |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 
@@ -71,7 +71,7 @@ test_expect_success 'verify blob:limit=500 omits all blobs' '
 	sed "s/~//" |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify emitted+omitted == all' '
@@ -84,7 +84,7 @@ test_expect_success 'verify emitted+omitted == all' '
 	sed "s/~//" |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify blob:limit=1000' '
@@ -97,7 +97,7 @@ test_expect_success 'verify blob:limit=1000' '
 	sed "s/~//" |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify blob:limit=1001' '
@@ -110,7 +110,7 @@ test_expect_success 'verify blob:limit=1001' '
 	sed "s/~//" |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify blob:limit=1k' '
@@ -123,7 +123,7 @@ test_expect_success 'verify blob:limit=1k' '
 	sed "s/~//" |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify blob:limit=1m' '
@@ -165,7 +165,7 @@ test_expect_success 'verify sparse:path=pattern1 omits top-level files' '
 	sed "s/~//" |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify sparse:path=pattern2 omits both sparse2 files' '
@@ -178,7 +178,7 @@ test_expect_success 'verify sparse:path=pattern2 omits both sparse2 files' '
 	sed "s/~//" |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 # Test sparse:oid=<oid-ish> filter.
@@ -203,7 +203,7 @@ test_expect_success 'verify sparse:oid=OID omits top-level files' '
 	sed "s/~//" |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify sparse:oid=oid-ish omits top-level files' '
@@ -216,7 +216,7 @@ test_expect_success 'verify sparse:oid=oid-ish omits top-level files' '
 	sed "s/~//" |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 # Delete some loose objects and use rev-list, but WITHOUT any filtering.
@@ -237,7 +237,7 @@ test_expect_success 'rev-list W/ --missing=print' '
 	sed "s/?//" |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'rev-list W/O --missing fails' '
diff --git a/t/t7201-co.sh b/t/t7201-co.sh
index 324933acf..826987ca8 100755
--- a/t/t7201-co.sh
+++ b/t/t7201-co.sh
@@ -160,7 +160,7 @@ test_expect_success 'checkout -m with merge conflict' '
 	git diff master:one :3:uno |
 	sed -e "1,/^@@/d" -e "/^ /d" -e "s/^-/d/" -e "s/^+/a/" >current &&
 	fill d2 aT d7 aS >expect &&
-	test_cmp current expect &&
+	test_cmp expect current &&
 	git diff --cached two >current &&
 	test_must_be_empty current
 '
@@ -174,7 +174,7 @@ test_expect_success 'format of merge conflict from checkout -m' '
 
 	git ls-files >current &&
 	fill same two two two >expect &&
-	test_cmp current expect &&
+	test_cmp expect current &&
 
 	cat <<-EOF >expect &&
 	<<<<<<< simple
diff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh
index 10dc91620..e87164aa8 100755
--- a/t/t7406-submodule-update.sh
+++ b/t/t7406-submodule-update.sh
@@ -789,7 +789,7 @@ test_expect_success 'submodule add places git-dir in superprojects git-dir' '
 	 (cd .git/modules/deeper/submodule &&
 	  git log > ../../../../actual
 	 ) &&
-	 test_cmp actual expected
+	 test_cmp expected actual
 	)
 '
 
@@ -807,7 +807,7 @@ test_expect_success 'submodule update places git-dir in superprojects git-dir' '
 	 (cd .git/modules/deeper/submodule &&
 	  git log > ../../../../actual
 	 ) &&
-	 test_cmp actual expected
+	 test_cmp expected actual
 	)
 '
 
@@ -827,7 +827,7 @@ test_expect_success 'submodule add places git-dir in superprojects git-dir recur
 	 git add deeper/submodule &&
 	 git commit -m "update submodule" &&
 	 git push origin : &&
-	 test_cmp actual expected
+	 test_cmp expected actual
 	)
 '
 
@@ -874,7 +874,7 @@ test_expect_success 'submodule update places git-dir in superprojects git-dir re
 	 (cd .git/modules/submodule/modules/subsubmodule &&
 	  git log > ../../../../../actual
 	 ) &&
-	 test_cmp actual expected
+	 test_cmp expected actual
 	)
 '
 
diff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh
index 668bbee73..562bd215a 100755
--- a/t/t7800-difftool.sh
+++ b/t/t7800-difftool.sh
@@ -557,7 +557,7 @@ test_expect_success SYMLINKS 'difftool --dir-diff --symlink without unstaged cha
 	EOF
 	git difftool --dir-diff --symlink \
 		--extcmd "./.git/CHECK_SYMLINKS" branch HEAD &&
-	test_cmp actual expect
+	test_cmp expect actual
 '
 
 write_script modify-right-file <<\EOF
diff --git a/t/t9100-git-svn-basic.sh b/t/t9100-git-svn-basic.sh
index 9af607884..2c309a57d 100755
--- a/t/t9100-git-svn-basic.sh
+++ b/t/t9100-git-svn-basic.sh
@@ -221,7 +221,7 @@ tree d667270a1f7b109f5eb3aaea21ede14b56bfdd6e
 tree 8f51f74cf0163afc9ad68a4b1537288c4558b5a4
 EOF
 
-test_expect_success POSIXPERM,SYMLINKS "$name" "test_cmp a expected"
+test_expect_success POSIXPERM,SYMLINKS "$name" "test_cmp expected a"
 
 test_expect_success 'exit if remote refs are ambigious' '
         git config --add svn-remote.svn.fetch \
diff --git a/t/t9133-git-svn-nested-git-repo.sh b/t/t9133-git-svn-nested-git-repo.sh
index f3c30e63b..f89486086 100755
--- a/t/t9133-git-svn-nested-git-repo.sh
+++ b/t/t9133-git-svn-nested-git-repo.sh
@@ -45,7 +45,7 @@ test_expect_success 'update git svn-cloned repo' '
 		git svn rebase &&
 		echo a > expect &&
 		echo b >> expect &&
-		test_cmp a expect &&
+		test_cmp expect a &&
 		rm expect
 	)
 '
@@ -69,7 +69,7 @@ test_expect_success 'update git svn-cloned repo' '
 		git svn rebase &&
 		echo a > expect &&
 		echo b >> expect &&
-		test_cmp a expect &&
+		test_cmp expect a &&
 		rm expect
 	)
 '
@@ -93,7 +93,7 @@ test_expect_success 'update git svn-cloned repo again' '
 		echo a > expect &&
 		echo b >> expect &&
 		echo c >> expect &&
-		test_cmp a expect &&
+		test_cmp expect a &&
 		rm expect
 	)
 '
diff --git a/t/t9600-cvsimport.sh b/t/t9600-cvsimport.sh
index 5dfee07d9..251fdd66c 100755
--- a/t/t9600-cvsimport.sh
+++ b/t/t9600-cvsimport.sh
@@ -148,7 +148,7 @@ test_expect_success PERL 'import from a CVS working tree' '
 		git cvsimport -a -z0 &&
 		echo 1 >expect &&
 		git log -1 --pretty=format:%s%n >actual &&
-		test_cmp actual expect
+		test_cmp expect actual
 	)
 
 '
diff --git a/t/t9603-cvsimport-patchsets.sh b/t/t9603-cvsimport-patchsets.sh
index c4c3c4954..3e64b11ea 100755
--- a/t/t9603-cvsimport-patchsets.sh
+++ b/t/t9603-cvsimport-patchsets.sh
@@ -29,11 +29,11 @@ test_expect_failure PERL 'import with criss cross times on revisions' '
 Rev 3
 Rev 2
 Rev 1" > expect-master &&
-    test_cmp actual-master expect-master &&
+    test_cmp expect-master actual-master &&
 
     echo "Rev 5 Branch A Wed Mar 11 19:09:10 2009 +0000
 Rev 4 Branch A Wed Mar 11 19:03:52 2009 +0000" > expect-A &&
-    test_cmp actual-A expect-A
+    test_cmp expect-A actual-A
 '
 
 test_done
diff --git a/t/t9604-cvsimport-timestamps.sh b/t/t9604-cvsimport-timestamps.sh
index a4b3db24b..2ff4aa932 100755
--- a/t/t9604-cvsimport-timestamps.sh
+++ b/t/t9604-cvsimport-timestamps.sh
@@ -31,7 +31,7 @@ test_expect_success PERL 'check timestamps are UTC (TZ=CST6CDT)' '
 	Rev  2 2005-02-01 00:00:00 +0000
 	Rev  1 2005-01-01 00:00:00 +0000
 	EOF
-	test_cmp actual-1 expect-1
+	test_cmp expect-1 actual-1
 '
 
 test_expect_success PERL 'check timestamps with author-specific timezones' '
@@ -65,7 +65,7 @@ test_expect_success PERL 'check timestamps with author-specific timezones' '
 	Rev  2 2005-01-31 18:00:00 -0600 User Two
 	Rev  1 2005-01-01 00:00:00 +0000 User One
 	EOF
-	test_cmp actual-2 expect-2
+	test_cmp expect-2 actual-2
 '
 
 test_done
-- 
2.19.0.605.g01d371f741-goog


^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [PATCH v4 5/7] tests: don't swallow Git errors upstream of pipes
  2018-10-03 16:25 ` [PATCH v4 0/7] Clean up tests for test_cmp arg ordering and pipe placement Matthew DeVore
                     ` (3 preceding siblings ...)
  2018-10-03 16:26   ` [PATCH v4 4/7] t/*: fix ordering of expected/observed arguments Matthew DeVore
@ 2018-10-03 16:26   ` Matthew DeVore
  2018-10-05 16:48     ` Junio C Hamano
  2018-10-03 16:26   ` [PATCH v4 6/7] t9109: " Matthew DeVore
  2018-10-03 16:26   ` [PATCH v4 7/7] tests: order arguments to git-rev-list properly Matthew DeVore
  6 siblings, 1 reply; 66+ messages in thread
From: Matthew DeVore @ 2018-10-03 16:26 UTC (permalink / raw)
  To: git; +Cc: Matthew DeVore, peff, jonathantanmy, gitster, jrn, sunshine,
	szeder.dev

Some pipes in tests lose the exit code of git processes, which can mask
unexpected behavior like crashes. Split these pipes up so that git
commands are only at the end of pipes rather than the beginning or
middle.

The violations fixed in this patch were found in the process of fixing
pipe placement in a prior patch.

Signed-off-by: Matthew DeVore <matvore@google.com>
---
 t/t5317-pack-objects-filter-objects.sh | 156 +++++++++++++------------
 t/t5616-partial-clone.sh               |  14 ++-
 t/t6112-rev-list-filters-objects.sh    | 103 ++++++++--------
 t/t9101-git-svn-props.sh               |   3 +-
 4 files changed, 143 insertions(+), 133 deletions(-)

diff --git a/t/t5317-pack-objects-filter-objects.sh b/t/t5317-pack-objects-filter-objects.sh
index c093eb891..2e718f0bd 100755
--- a/t/t5317-pack-objects-filter-objects.sh
+++ b/t/t5317-pack-objects-filter-objects.sh
@@ -20,8 +20,9 @@ test_expect_success 'setup r1' '
 '
 
 test_expect_success 'verify blob count in normal packfile' '
-	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 |
-	awk -f print_2.awk |
+	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 \
+		>ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	git -C r1 pack-objects --rev --stdout >all.pack <<-EOF &&
@@ -29,8 +30,8 @@ test_expect_success 'verify blob count in normal packfile' '
 	EOF
 	git -C r1 index-pack ../all.pack &&
 
-	git -C r1 verify-pack -v ../all.pack |
-	grep blob |
+	git -C r1 verify-pack -v ../all.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -43,8 +44,8 @@ test_expect_success 'verify blob:none packfile has no blobs' '
 	EOF
 	git -C r1 index-pack ../filter.pack &&
 
-	git -C r1 verify-pack -v ../filter.pack |
-	grep blob |
+	git -C r1 verify-pack -v ../filter.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -53,13 +54,13 @@ test_expect_success 'verify blob:none packfile has no blobs' '
 '
 
 test_expect_success 'verify normal and blob:none packfiles have same commits/trees' '
-	git -C r1 verify-pack -v ../all.pack |
-	grep -E "commit|tree" |
+	git -C r1 verify-pack -v ../all.pack >verify_result &&
+	grep -E "commit|tree" verify_result |
 	awk -f print_1.awk |
 	sort >expected &&
 
-	git -C r1 verify-pack -v ../filter.pack |
-	grep -E "commit|tree" |
+	git -C r1 verify-pack -v ../filter.pack >verify_result &&
+	grep -E "commit|tree" verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -82,8 +83,8 @@ test_expect_success 'setup r2' '
 '
 
 test_expect_success 'verify blob count in normal packfile' '
-	git -C r2 ls-files -s large.1000 large.10000 |
-	awk -f print_2.awk |
+	git -C r2 ls-files -s large.1000 large.10000 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	git -C r2 pack-objects --rev --stdout >all.pack <<-EOF &&
@@ -91,8 +92,8 @@ test_expect_success 'verify blob count in normal packfile' '
 	EOF
 	git -C r2 index-pack ../all.pack &&
 
-	git -C r2 verify-pack -v ../all.pack |
-	grep blob |
+	git -C r2 verify-pack -v ../all.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -105,8 +106,8 @@ test_expect_success 'verify blob:limit=500 omits all blobs' '
 	EOF
 	git -C r2 index-pack ../filter.pack &&
 
-	git -C r2 verify-pack -v ../filter.pack |
-	grep blob |
+	git -C r2 verify-pack -v ../filter.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -120,8 +121,8 @@ test_expect_success 'verify blob:limit=1000' '
 	EOF
 	git -C r2 index-pack ../filter.pack &&
 
-	git -C r2 verify-pack -v ../filter.pack |
-	grep blob |
+	git -C r2 verify-pack -v ../filter.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -130,8 +131,8 @@ test_expect_success 'verify blob:limit=1000' '
 '
 
 test_expect_success 'verify blob:limit=1001' '
-	git -C r2 ls-files -s large.1000 |
-	awk -f print_2.awk |
+	git -C r2 ls-files -s large.1000 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	git -C r2 pack-objects --rev --stdout --filter=blob:limit=1001 >filter.pack <<-EOF &&
@@ -139,8 +140,8 @@ test_expect_success 'verify blob:limit=1001' '
 	EOF
 	git -C r2 index-pack ../filter.pack &&
 
-	git -C r2 verify-pack -v ../filter.pack |
-	grep blob |
+	git -C r2 verify-pack -v ../filter.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -148,8 +149,8 @@ test_expect_success 'verify blob:limit=1001' '
 '
 
 test_expect_success 'verify blob:limit=10001' '
-	git -C r2 ls-files -s large.1000 large.10000 |
-	awk -f print_2.awk |
+	git -C r2 ls-files -s large.1000 large.10000 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	git -C r2 pack-objects --rev --stdout --filter=blob:limit=10001 >filter.pack <<-EOF &&
@@ -157,8 +158,8 @@ test_expect_success 'verify blob:limit=10001' '
 	EOF
 	git -C r2 index-pack ../filter.pack &&
 
-	git -C r2 verify-pack -v ../filter.pack |
-	grep blob |
+	git -C r2 verify-pack -v ../filter.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -166,8 +167,8 @@ test_expect_success 'verify blob:limit=10001' '
 '
 
 test_expect_success 'verify blob:limit=1k' '
-	git -C r2 ls-files -s large.1000 |
-	awk -f print_2.awk |
+	git -C r2 ls-files -s large.1000 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	git -C r2 pack-objects --rev --stdout --filter=blob:limit=1k >filter.pack <<-EOF &&
@@ -175,8 +176,8 @@ test_expect_success 'verify blob:limit=1k' '
 	EOF
 	git -C r2 index-pack ../filter.pack &&
 
-	git -C r2 verify-pack -v ../filter.pack |
-	grep blob |
+	git -C r2 verify-pack -v ../filter.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -184,8 +185,8 @@ test_expect_success 'verify blob:limit=1k' '
 '
 
 test_expect_success 'verify explicitly specifying oversized blob in input' '
-	git -C r2 ls-files -s large.1000 large.10000 |
-	awk -f print_2.awk |
+	git -C r2 ls-files -s large.1000 large.10000 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	git -C r2 pack-objects --rev --stdout --filter=blob:limit=1k >filter.pack <<-EOF &&
@@ -194,8 +195,8 @@ test_expect_success 'verify explicitly specifying oversized blob in input' '
 	EOF
 	git -C r2 index-pack ../filter.pack &&
 
-	git -C r2 verify-pack -v ../filter.pack |
-	grep blob |
+	git -C r2 verify-pack -v ../filter.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -203,8 +204,8 @@ test_expect_success 'verify explicitly specifying oversized blob in input' '
 '
 
 test_expect_success 'verify blob:limit=1m' '
-	git -C r2 ls-files -s large.1000 large.10000 |
-	awk -f print_2.awk |
+	git -C r2 ls-files -s large.1000 large.10000 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	git -C r2 pack-objects --rev --stdout --filter=blob:limit=1m >filter.pack <<-EOF &&
@@ -212,8 +213,8 @@ test_expect_success 'verify blob:limit=1m' '
 	EOF
 	git -C r2 index-pack ../filter.pack &&
 
-	git -C r2 verify-pack -v ../filter.pack |
-	grep blob |
+	git -C r2 verify-pack -v ../filter.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -221,13 +222,13 @@ test_expect_success 'verify blob:limit=1m' '
 '
 
 test_expect_success 'verify normal and blob:limit packfiles have same commits/trees' '
-	git -C r2 verify-pack -v ../all.pack |
-	grep -E "commit|tree" |
+	git -C r2 verify-pack -v ../all.pack >verify_result &&
+	grep -E "commit|tree" verify_result |
 	awk -f print_1.awk |
 	sort >expected &&
 
-	git -C r2 verify-pack -v ../filter.pack |
-	grep -E "commit|tree" |
+	git -C r2 verify-pack -v ../filter.pack >verify_result &&
+	grep -E "commit|tree" verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -255,8 +256,9 @@ test_expect_success 'setup r3' '
 '
 
 test_expect_success 'verify blob count in normal packfile' '
-	git -C r3 ls-files -s sparse1 sparse2 dir1/sparse1 dir1/sparse2 |
-	awk -f print_2.awk |
+	git -C r3 ls-files -s sparse1 sparse2 dir1/sparse1 dir1/sparse2 \
+		>ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	git -C r3 pack-objects --rev --stdout >all.pack <<-EOF &&
@@ -264,8 +266,8 @@ test_expect_success 'verify blob count in normal packfile' '
 	EOF
 	git -C r3 index-pack ../all.pack &&
 
-	git -C r3 verify-pack -v ../all.pack |
-	grep blob |
+	git -C r3 verify-pack -v ../all.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -273,8 +275,8 @@ test_expect_success 'verify blob count in normal packfile' '
 '
 
 test_expect_success 'verify sparse:path=pattern1' '
-	git -C r3 ls-files -s dir1/sparse1 dir1/sparse2 |
-	awk -f print_2.awk |
+	git -C r3 ls-files -s dir1/sparse1 dir1/sparse2 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	git -C r3 pack-objects --rev --stdout --filter=sparse:path=../pattern1 >filter.pack <<-EOF &&
@@ -282,8 +284,8 @@ test_expect_success 'verify sparse:path=pattern1' '
 	EOF
 	git -C r3 index-pack ../filter.pack &&
 
-	git -C r3 verify-pack -v ../filter.pack |
-	grep blob |
+	git -C r3 verify-pack -v ../filter.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -291,13 +293,13 @@ test_expect_success 'verify sparse:path=pattern1' '
 '
 
 test_expect_success 'verify normal and sparse:path=pattern1 packfiles have same commits/trees' '
-	git -C r3 verify-pack -v ../all.pack |
-	grep -E "commit|tree" |
+	git -C r3 verify-pack -v ../all.pack >verify_result &&
+	grep -E "commit|tree" verify_result |
 	awk -f print_1.awk |
 	sort >expected &&
 
-	git -C r3 verify-pack -v ../filter.pack |
-	grep -E "commit|tree" |
+	git -C r3 verify-pack -v ../filter.pack >verify_result &&
+	grep -E "commit|tree" verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -305,8 +307,8 @@ test_expect_success 'verify normal and sparse:path=pattern1 packfiles have same
 '
 
 test_expect_success 'verify sparse:path=pattern2' '
-	git -C r3 ls-files -s sparse1 dir1/sparse1 |
-	awk -f print_2.awk |
+	git -C r3 ls-files -s sparse1 dir1/sparse1 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	git -C r3 pack-objects --rev --stdout --filter=sparse:path=../pattern2 >filter.pack <<-EOF &&
@@ -314,8 +316,8 @@ test_expect_success 'verify sparse:path=pattern2' '
 	EOF
 	git -C r3 index-pack ../filter.pack &&
 
-	git -C r3 verify-pack -v ../filter.pack |
-	grep blob |
+	git -C r3 verify-pack -v ../filter.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -323,13 +325,13 @@ test_expect_success 'verify sparse:path=pattern2' '
 '
 
 test_expect_success 'verify normal and sparse:path=pattern2 packfiles have same commits/trees' '
-	git -C r3 verify-pack -v ../all.pack |
-	grep -E "commit|tree" |
+	git -C r3 verify-pack -v ../all.pack >verify_result &&
+	grep -E "commit|tree" verify_result |
 	awk -f print_1.awk |
 	sort >expected &&
 
-	git -C r3 verify-pack -v ../filter.pack |
-	grep -E "commit|tree" |
+	git -C r3 verify-pack -v ../filter.pack >verify_result &&
+	grep -E "commit|tree" verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -356,8 +358,9 @@ test_expect_success 'setup r4' '
 '
 
 test_expect_success 'verify blob count in normal packfile' '
-	git -C r4 ls-files -s pattern sparse1 sparse2 dir1/sparse1 dir1/sparse2 |
-	awk -f print_2.awk |
+	git -C r4 ls-files -s pattern sparse1 sparse2 dir1/sparse1 dir1/sparse2 \
+		>ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	git -C r4 pack-objects --rev --stdout >all.pack <<-EOF &&
@@ -365,8 +368,8 @@ test_expect_success 'verify blob count in normal packfile' '
 	EOF
 	git -C r4 index-pack ../all.pack &&
 
-	git -C r4 verify-pack -v ../all.pack |
-	grep blob |
+	git -C r4 verify-pack -v ../all.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -374,8 +377,8 @@ test_expect_success 'verify blob count in normal packfile' '
 '
 
 test_expect_success 'verify sparse:oid=OID' '
-	git -C r4 ls-files -s dir1/sparse1 dir1/sparse2 |
-	awk -f print_2.awk |
+	git -C r4 ls-files -s dir1/sparse1 dir1/sparse2 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	oid=$(git -C r4 ls-files -s pattern | awk -f print_2.awk) &&
@@ -384,8 +387,8 @@ test_expect_success 'verify sparse:oid=OID' '
 	EOF
 	git -C r4 index-pack ../filter.pack &&
 
-	git -C r4 verify-pack -v ../filter.pack |
-	grep blob |
+	git -C r4 verify-pack -v ../filter.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -393,8 +396,8 @@ test_expect_success 'verify sparse:oid=OID' '
 '
 
 test_expect_success 'verify sparse:oid=oid-ish' '
-	git -C r4 ls-files -s dir1/sparse1 dir1/sparse2 |
-	awk -f print_2.awk |
+	git -C r4 ls-files -s dir1/sparse1 dir1/sparse2 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	git -C r4 pack-objects --rev --stdout --filter=sparse:oid=master:pattern >filter.pack <<-EOF &&
@@ -402,8 +405,8 @@ test_expect_success 'verify sparse:oid=oid-ish' '
 	EOF
 	git -C r4 index-pack ../filter.pack &&
 
-	git -C r4 verify-pack -v ../filter.pack |
-	grep blob |
+	git -C r4 verify-pack -v ../filter.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -414,8 +417,9 @@ test_expect_success 'verify sparse:oid=oid-ish' '
 # This models previously omitted objects that we did not receive.
 
 test_expect_success 'setup r1 - delete loose blobs' '
-	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 |
-	awk -f print_2.awk |
+	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 \
+		>ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	for id in `cat expected | sed "s|..|&/|"`
diff --git a/t/t5616-partial-clone.sh b/t/t5616-partial-clone.sh
index e4d032c9d..fc7aeb1ab 100755
--- a/t/t5616-partial-clone.sh
+++ b/t/t5616-partial-clone.sh
@@ -35,8 +35,8 @@ test_expect_success 'setup bare clone for server' '
 test_expect_success 'do partial clone 1' '
 	git clone --no-checkout --filter=blob:none "file://$(pwd)/srv.bare" pc1 &&
 
-	git -C pc1 rev-list HEAD --quiet --objects --missing=print |
-	awk -f print_1.awk |
+	git -C pc1 rev-list HEAD --quiet --objects --missing=print >revs &&
+	awk -f print_1.awk revs |
 	sed "s/?//" |
 	sort >observed.oids &&
 
@@ -133,16 +133,18 @@ test_expect_success 'push new commits to server for file.3.txt' '
 test_expect_success 'manual prefetch of missing objects' '
 	git -C pc1 fetch --filter=blob:none origin &&
 
-	git -C pc1 rev-list master..origin/master --quiet --objects --missing=print |
-	awk -f print_1.awk |
+	git -C pc1 rev-list master..origin/master --quiet --objects --missing=print \
+		>revs &&
+	awk -f print_1.awk revs |
 	sed "s/?//" |
 	sort >observed.oids &&
 
 	test_line_count = 6 observed.oids &&
 	git -C pc1 fetch-pack --stdin "file://$(pwd)/srv.bare" <observed.oids &&
 
-	git -C pc1 rev-list master..origin/master --quiet --objects --missing=print |
-	awk -f print_1.awk |
+	git -C pc1 rev-list master..origin/master --quiet --objects --missing=print \
+		>revs &&
+	awk -f print_1.awk revs |
 	sed "s/?//" |
 	sort >observed.oids &&
 
diff --git a/t/t6112-rev-list-filters-objects.sh b/t/t6112-rev-list-filters-objects.sh
index ae4402226..b00cf6fa8 100755
--- a/t/t6112-rev-list-filters-objects.sh
+++ b/t/t6112-rev-list-filters-objects.sh
@@ -20,12 +20,13 @@ test_expect_success 'setup r1' '
 '
 
 test_expect_success 'verify blob:none omits all 5 blobs' '
-	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 |
-	awk -f print_2.awk |
+	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 \
+		>ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
-	git -C r1 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:none |
-	awk -f print_1.awk |
+	git -C r1 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:none >revs &&
+	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
 
@@ -33,12 +34,13 @@ test_expect_success 'verify blob:none omits all 5 blobs' '
 '
 
 test_expect_success 'verify emitted+omitted == all' '
-	git -C r1 rev-list HEAD --objects |
-	awk -f print_1.awk |
+	git -C r1 rev-list HEAD --objects >revs &&
+	awk -f print_1.awk revs |
 	sort >expected &&
 
-	git -C r1 rev-list HEAD --objects --filter-print-omitted --filter=blob:none |
-	awk -f print_1.awk |
+	git -C r1 rev-list HEAD --objects --filter-print-omitted --filter=blob:none \
+		>revs &&
+	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
 
@@ -62,12 +64,12 @@ test_expect_success 'setup r2' '
 '
 
 test_expect_success 'verify blob:limit=500 omits all blobs' '
-	git -C r2 ls-files -s large.1000 large.10000 |
-	awk -f print_2.awk |
+	git -C r2 ls-files -s large.1000 large.10000 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
-	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=500 |
-	awk -f print_1.awk |
+	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=500 >revs &&
+	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
 
@@ -75,12 +77,12 @@ test_expect_success 'verify blob:limit=500 omits all blobs' '
 '
 
 test_expect_success 'verify emitted+omitted == all' '
-	git -C r2 rev-list HEAD --objects |
-	awk -f print_1.awk |
+	git -C r2 rev-list HEAD --objects >revs &&
+	awk -f print_1.awk revs |
 	sort >expected &&
 
-	git -C r2 rev-list HEAD --objects --filter-print-omitted --filter=blob:limit=500 |
-	awk -f print_1.awk |
+	git -C r2 rev-list HEAD --objects --filter-print-omitted --filter=blob:limit=500 >revs &&
+	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
 
@@ -88,12 +90,12 @@ test_expect_success 'verify emitted+omitted == all' '
 '
 
 test_expect_success 'verify blob:limit=1000' '
-	git -C r2 ls-files -s large.1000 large.10000 |
-	awk -f print_2.awk |
+	git -C r2 ls-files -s large.1000 large.10000 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
-	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1000 |
-	awk -f print_1.awk |
+	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1000 >revs &&
+	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
 
@@ -101,12 +103,12 @@ test_expect_success 'verify blob:limit=1000' '
 '
 
 test_expect_success 'verify blob:limit=1001' '
-	git -C r2 ls-files -s large.10000 |
-	awk -f print_2.awk |
+	git -C r2 ls-files -s large.10000 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
-	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1001 |
-	awk -f print_1.awk |
+	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1001 >revs &&
+	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
 
@@ -114,12 +116,12 @@ test_expect_success 'verify blob:limit=1001' '
 '
 
 test_expect_success 'verify blob:limit=1k' '
-	git -C r2 ls-files -s large.10000 |
-	awk -f print_2.awk |
+	git -C r2 ls-files -s large.10000 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
-	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1k |
-	awk -f print_1.awk |
+	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1k >revs &&
+	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
 
@@ -127,8 +129,8 @@ test_expect_success 'verify blob:limit=1k' '
 '
 
 test_expect_success 'verify blob:limit=1m' '
-	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1m |
-	awk -f print_1.awk |
+	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1m >revs &&
+	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
 
@@ -156,12 +158,12 @@ test_expect_success 'setup r3' '
 '
 
 test_expect_success 'verify sparse:path=pattern1 omits top-level files' '
-	git -C r3 ls-files -s sparse1 sparse2 |
-	awk -f print_2.awk |
+	git -C r3 ls-files -s sparse1 sparse2 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
-	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:path=../pattern1 |
-	awk -f print_1.awk |
+	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:path=../pattern1 >revs &&
+	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
 
@@ -169,12 +171,12 @@ test_expect_success 'verify sparse:path=pattern1 omits top-level files' '
 '
 
 test_expect_success 'verify sparse:path=pattern2 omits both sparse2 files' '
-	git -C r3 ls-files -s sparse2 dir1/sparse2 |
-	awk -f print_2.awk |
+	git -C r3 ls-files -s sparse2 dir1/sparse2 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
-	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:path=../pattern2 |
-	awk -f print_1.awk |
+	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:path=../pattern2 >revs &&
+	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
 
@@ -192,14 +194,14 @@ test_expect_success 'setup r3 part 2' '
 '
 
 test_expect_success 'verify sparse:oid=OID omits top-level files' '
-	git -C r3 ls-files -s pattern sparse1 sparse2 |
-	awk -f print_2.awk |
+	git -C r3 ls-files -s pattern sparse1 sparse2 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	oid=$(git -C r3 ls-files -s pattern | awk -f print_2.awk) &&
 
-	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:oid=$oid |
-	awk -f print_1.awk |
+	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:oid=$oid >revs &&
+	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
 
@@ -207,12 +209,12 @@ test_expect_success 'verify sparse:oid=OID omits top-level files' '
 '
 
 test_expect_success 'verify sparse:oid=oid-ish omits top-level files' '
-	git -C r3 ls-files -s pattern sparse1 sparse2 |
-	awk -f print_2.awk |
+	git -C r3 ls-files -s pattern sparse1 sparse2 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
-	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:oid=master:pattern |
-	awk -f print_1.awk |
+	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:oid=master:pattern >revs &&
+	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
 
@@ -223,8 +225,9 @@ test_expect_success 'verify sparse:oid=oid-ish omits top-level files' '
 # This models previously omitted objects that we did not receive.
 
 test_expect_success 'rev-list W/ --missing=print' '
-	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 |
-	awk -f print_2.awk |
+	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 \
+		>ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	for id in `cat expected | sed "s|..|&/|"`
@@ -232,8 +235,8 @@ test_expect_success 'rev-list W/ --missing=print' '
 		rm r1/.git/objects/$id
 	done &&
 
-	git -C r1 rev-list --quiet HEAD --missing=print --objects |
-	awk -f print_1.awk |
+	git -C r1 rev-list --quiet HEAD --missing=print --objects >revs &&
+	awk -f print_1.awk revs |
 	sed "s/?//" |
 	sort >observed &&
 
diff --git a/t/t9101-git-svn-props.sh b/t/t9101-git-svn-props.sh
index 8a5c8dc1a..8cba331fc 100755
--- a/t/t9101-git-svn-props.sh
+++ b/t/t9101-git-svn-props.sh
@@ -174,7 +174,8 @@ test_expect_success 'test create-ignore' "
 	cmp ./deeply/.gitignore create-ignore.expect &&
 	cmp ./deeply/nested/.gitignore create-ignore.expect &&
 	cmp ./deeply/nested/directory/.gitignore create-ignore.expect &&
-	git ls-files -s | grep gitignore | cmp - create-ignore-index.expect
+	git ls-files -s >ls_files_result &&
+	grep gitignore ls_files_result | cmp - create-ignore-index.expect
 	"
 
 cat >prop.expect <<\EOF
-- 
2.19.0.605.g01d371f741-goog


^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [PATCH v4 6/7] t9109: don't swallow Git errors upstream of pipes
  2018-10-03 16:25 ` [PATCH v4 0/7] Clean up tests for test_cmp arg ordering and pipe placement Matthew DeVore
                     ` (4 preceding siblings ...)
  2018-10-03 16:26   ` [PATCH v4 5/7] tests: don't swallow Git errors upstream of pipes Matthew DeVore
@ 2018-10-03 16:26   ` Matthew DeVore
  2018-10-03 16:26   ` [PATCH v4 7/7] tests: order arguments to git-rev-list properly Matthew DeVore
  6 siblings, 0 replies; 66+ messages in thread
From: Matthew DeVore @ 2018-10-03 16:26 UTC (permalink / raw)
  To: git; +Cc: Matthew DeVore, peff, jonathantanmy, gitster, jrn, sunshine,
	szeder.dev

'git ... | foo' will mask any errors or crashes in git, so split up such
pipes in this file.

One testcase uses several separate pipe sequences in a row which are
awkward to split up. Wrap the split-up pipe in a function so the
awkwardness is not repeated. Also change that testcase's surrounding
quotes from double to single to avoid premature string interpolation.

Signed-off-by: Matthew DeVore <matvore@google.com>
---
 t/t9101-git-svn-props.sh | 31 +++++++++++++++++++------------
 1 file changed, 19 insertions(+), 12 deletions(-)

diff --git a/t/t9101-git-svn-props.sh b/t/t9101-git-svn-props.sh
index 8cba331fc..c26c4b092 100755
--- a/t/t9101-git-svn-props.sh
+++ b/t/t9101-git-svn-props.sh
@@ -190,17 +190,21 @@ EOF
 # This test can be improved: since all the svn:ignore contain the same
 # pattern, it can pass even though the propget did not execute on the
 # right directory.
-test_expect_success 'test propget' "
-	git svn propget svn:ignore . | cmp - prop.expect &&
+test_expect_success 'test propget' '
+	test_propget () {
+		git svn propget $1 $2 >actual &&
+		cmp $3 actual
+	} &&
+	test_propget svn:ignore . prop.expect &&
 	cd deeply &&
-	git svn propget svn:ignore . | cmp - ../prop.expect &&
-	git svn propget svn:entry:committed-rev nested/directory/.keep \
-	  | cmp - ../prop2.expect &&
-	git svn propget svn:ignore .. | cmp - ../prop.expect &&
-	git svn propget svn:ignore nested/ | cmp - ../prop.expect &&
-	git svn propget svn:ignore ./nested | cmp - ../prop.expect &&
-	git svn propget svn:ignore .././deeply/nested | cmp - ../prop.expect
-	"
+	test_propget svn:ignore . ../prop.expect &&
+	test_propget svn:entry:committed-rev nested/directory/.keep \
+		../prop2.expect &&
+	test_propget svn:ignore .. ../prop.expect &&
+	test_propget svn:ignore nested/ ../prop.expect &&
+	test_propget svn:ignore ./nested ../prop.expect &&
+	test_propget svn:ignore .././deeply/nested ../prop.expect
+	'
 
 cat >prop.expect <<\EOF
 Properties on '.':
@@ -219,8 +223,11 @@ Properties on 'nested/directory/.keep':
 EOF
 
 test_expect_success 'test proplist' "
-	git svn proplist . | cmp - prop.expect &&
-	git svn proplist nested/directory/.keep | cmp - prop2.expect
+	git svn proplist . >actual &&
+	cmp prop.expect actual &&
+
+	git svn proplist nested/directory/.keep >actual &&
+	cmp prop2.expect actual
 	"
 
 test_done
-- 
2.19.0.605.g01d371f741-goog


^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [PATCH v4 7/7] tests: order arguments to git-rev-list properly
  2018-10-03 16:25 ` [PATCH v4 0/7] Clean up tests for test_cmp arg ordering and pipe placement Matthew DeVore
                     ` (5 preceding siblings ...)
  2018-10-03 16:26   ` [PATCH v4 6/7] t9109: " Matthew DeVore
@ 2018-10-03 16:26   ` Matthew DeVore
  2018-10-03 16:33     ` Matthew DeVore
  6 siblings, 1 reply; 66+ messages in thread
From: Matthew DeVore @ 2018-10-03 16:26 UTC (permalink / raw)
  To: git; +Cc: Matthew DeVore, peff, jonathantanmy, gitster, jrn, sunshine,
	szeder.dev

It is a common mistake to put positional arguments before flags when
invoking git-rev-list. Order the positional arguments last.

This patch skips git-rev-list invocations which include the --not flag,
since the ordering of flags and positional arguments affects the
behavior. This patch also skips invocations of git-rev-list that occur
in command substitution in which the exit code is discarded, since
fixing those properly will require a more involved cleanup.

Signed-off-by: Matthew DeVore <matvore@google.com>
---
 t/t5616-partial-clone.sh            | 26 +++++++++--------
 t/t5702-protocol-v2.sh              |  4 +--
 t/t6112-rev-list-filters-objects.sh | 43 ++++++++++++++++++-----------
 3 files changed, 44 insertions(+), 29 deletions(-)

diff --git a/t/t5616-partial-clone.sh b/t/t5616-partial-clone.sh
index fc7aeb1ab..eeedd1623 100755
--- a/t/t5616-partial-clone.sh
+++ b/t/t5616-partial-clone.sh
@@ -35,7 +35,7 @@ test_expect_success 'setup bare clone for server' '
 test_expect_success 'do partial clone 1' '
 	git clone --no-checkout --filter=blob:none "file://$(pwd)/srv.bare" pc1 &&
 
-	git -C pc1 rev-list HEAD --quiet --objects --missing=print >revs &&
+	git -C pc1 rev-list --quiet --objects --missing=print >revs HEAD &&
 	awk -f print_1.awk revs |
 	sed "s/?//" |
 	sort >observed.oids &&
@@ -48,10 +48,10 @@ test_expect_success 'do partial clone 1' '
 
 # checkout master to force dynamic object fetch of blobs at HEAD.
 test_expect_success 'verify checkout with dynamic object fetch' '
-	git -C pc1 rev-list HEAD --quiet --objects --missing=print >observed &&
+	git -C pc1 rev-list --quiet --objects --missing=print HEAD >observed &&
 	test_line_count = 4 observed &&
 	git -C pc1 checkout master &&
-	git -C pc1 rev-list HEAD --quiet --objects --missing=print >observed &&
+	git -C pc1 rev-list --quiet --objects --missing=print HEAD >observed &&
 	test_line_count = 0 observed
 '
 
@@ -74,7 +74,8 @@ test_expect_success 'push new commits to server' '
 # have the new blobs.
 test_expect_success 'partial fetch inherits filter settings' '
 	git -C pc1 fetch origin &&
-	git -C pc1 rev-list master..origin/master --quiet --objects --missing=print >observed &&
+	git -C pc1 rev-list --quiet --objects --missing=print \
+		master..origin/master >observed &&
 	test_line_count = 5 observed
 '
 
@@ -82,7 +83,8 @@ test_expect_success 'partial fetch inherits filter settings' '
 # we should only get 1 new blob (for the file in origin/master).
 test_expect_success 'verify diff causes dynamic object fetch' '
 	git -C pc1 diff master..origin/master -- file.1.txt &&
-	git -C pc1 rev-list master..origin/master --quiet --objects --missing=print >observed &&
+	git -C pc1 rev-list --quiet --objects --missing=print \
+		 master..origin/master >observed &&
 	test_line_count = 4 observed
 '
 
@@ -91,7 +93,8 @@ test_expect_success 'verify diff causes dynamic object fetch' '
 test_expect_success 'verify blame causes dynamic object fetch' '
 	git -C pc1 blame origin/master -- file.1.txt >observed.blame &&
 	test_cmp expect.blame observed.blame &&
-	git -C pc1 rev-list master..origin/master --quiet --objects --missing=print >observed &&
+	git -C pc1 rev-list --quiet --objects --missing=print >observed \
+		master..origin/master &&
 	test_line_count = 0 observed
 '
 
@@ -111,7 +114,8 @@ test_expect_success 'push new commits to server for file.2.txt' '
 # Verify we have all the new blobs.
 test_expect_success 'override inherited filter-spec using --no-filter' '
 	git -C pc1 fetch --no-filter origin &&
-	git -C pc1 rev-list master..origin/master --quiet --objects --missing=print >observed &&
+	git -C pc1 rev-list --quiet --objects --missing=print \
+		master..origin/master >observed &&
 	test_line_count = 0 observed
 '
 
@@ -133,8 +137,8 @@ test_expect_success 'push new commits to server for file.3.txt' '
 test_expect_success 'manual prefetch of missing objects' '
 	git -C pc1 fetch --filter=blob:none origin &&
 
-	git -C pc1 rev-list master..origin/master --quiet --objects --missing=print \
-		>revs &&
+	git -C pc1 rev-list --quiet --objects --missing=print \
+		 master..origin/master >revs &&
 	awk -f print_1.awk revs |
 	sed "s/?//" |
 	sort >observed.oids &&
@@ -142,8 +146,8 @@ test_expect_success 'manual prefetch of missing objects' '
 	test_line_count = 6 observed.oids &&
 	git -C pc1 fetch-pack --stdin "file://$(pwd)/srv.bare" <observed.oids &&
 
-	git -C pc1 rev-list master..origin/master --quiet --objects --missing=print \
-		>revs &&
+	git -C pc1 rev-list --quiet --objects --missing=print \
+		master..origin/master >revs &&
 	awk -f print_1.awk revs |
 	sed "s/?//" |
 	sort >observed.oids &&
diff --git a/t/t5702-protocol-v2.sh b/t/t5702-protocol-v2.sh
index 54727450b..11a84efff 100755
--- a/t/t5702-protocol-v2.sh
+++ b/t/t5702-protocol-v2.sh
@@ -271,7 +271,7 @@ test_expect_success 'partial clone' '
 	grep "version 2" trace &&
 
 	# Ensure that the old version of the file is missing
-	git -C client rev-list master --quiet --objects --missing=print \
+	git -C client rev-list --quiet --objects --missing=print master \
 		>observed.oids &&
 	grep "$(git -C server rev-parse message1:a.txt)" observed.oids &&
 
@@ -297,7 +297,7 @@ test_expect_success 'partial fetch' '
 	grep "version 2" trace &&
 
 	# Ensure that the old version of the file is missing
-	git -C client rev-list other --quiet --objects --missing=print \
+	git -C client rev-list --quiet --objects --missing=print other \
 		>observed.oids &&
 	grep "$(git -C server rev-parse message1:a.txt)" observed.oids &&
 
diff --git a/t/t6112-rev-list-filters-objects.sh b/t/t6112-rev-list-filters-objects.sh
index b00cf6fa8..53975c572 100755
--- a/t/t6112-rev-list-filters-objects.sh
+++ b/t/t6112-rev-list-filters-objects.sh
@@ -25,7 +25,8 @@ test_expect_success 'verify blob:none omits all 5 blobs' '
 	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
-	git -C r1 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:none >revs &&
+	git -C r1 rev-list --quiet --objects --filter-print-omitted \
+		--filter=blob:none HEAD >revs &&
 	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
@@ -34,12 +35,12 @@ test_expect_success 'verify blob:none omits all 5 blobs' '
 '
 
 test_expect_success 'verify emitted+omitted == all' '
-	git -C r1 rev-list HEAD --objects >revs &&
+	git -C r1 rev-list --objects HEAD >revs &&
 	awk -f print_1.awk revs |
 	sort >expected &&
 
-	git -C r1 rev-list HEAD --objects --filter-print-omitted --filter=blob:none \
-		>revs &&
+	git -C r1 rev-list --objects --filter-print-omitted --filter=blob:none \
+		HEAD >revs &&
 	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
@@ -68,7 +69,8 @@ test_expect_success 'verify blob:limit=500 omits all blobs' '
 	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
-	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=500 >revs &&
+	git -C r2 rev-list --quiet --objects --filter-print-omitted \
+		--filter=blob:limit=500 HEAD >revs &&
 	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
@@ -77,11 +79,12 @@ test_expect_success 'verify blob:limit=500 omits all blobs' '
 '
 
 test_expect_success 'verify emitted+omitted == all' '
-	git -C r2 rev-list HEAD --objects >revs &&
+	git -C r2 rev-list --objects HEAD >revs &&
 	awk -f print_1.awk revs |
 	sort >expected &&
 
-	git -C r2 rev-list HEAD --objects --filter-print-omitted --filter=blob:limit=500 >revs &&
+	git -C r2 rev-list --objects --filter-print-omitted \
+		--filter=blob:limit=500 HEAD >revs &&
 	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
@@ -94,7 +97,8 @@ test_expect_success 'verify blob:limit=1000' '
 	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
-	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1000 >revs &&
+	git -C r2 rev-list --quiet --objects --filter-print-omitted \
+		--filter=blob:limit=1000 HEAD >revs &&
 	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
@@ -107,7 +111,8 @@ test_expect_success 'verify blob:limit=1001' '
 	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
-	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1001 >revs &&
+	git -C r2 rev-list --quiet --objects --filter-print-omitted \
+		--filter=blob:limit=1001 HEAD >revs &&
 	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
@@ -120,7 +125,8 @@ test_expect_success 'verify blob:limit=1k' '
 	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
-	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1k >revs &&
+	git -C r2 rev-list --quiet --objects --filter-print-omitted \
+		--filter=blob:limit=1k HEAD >revs &&
 	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
@@ -129,7 +135,8 @@ test_expect_success 'verify blob:limit=1k' '
 '
 
 test_expect_success 'verify blob:limit=1m' '
-	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1m >revs &&
+	git -C r2 rev-list --quiet --objects --filter-print-omitted \
+		--filter=blob:limit=1m HEAD >revs &&
 	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
@@ -162,7 +169,8 @@ test_expect_success 'verify sparse:path=pattern1 omits top-level files' '
 	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
-	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:path=../pattern1 >revs &&
+	git -C r3 rev-list --quiet --objects --filter-print-omitted \
+		--filter=sparse:path=../pattern1 HEAD >revs &&
 	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
@@ -175,7 +183,8 @@ test_expect_success 'verify sparse:path=pattern2 omits both sparse2 files' '
 	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
-	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:path=../pattern2 >revs &&
+	git -C r3 rev-list --quiet --objects --filter-print-omitted \
+		--filter=sparse:path=../pattern2 HEAD >revs &&
 	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
@@ -200,7 +209,8 @@ test_expect_success 'verify sparse:oid=OID omits top-level files' '
 
 	oid=$(git -C r3 ls-files -s pattern | awk -f print_2.awk) &&
 
-	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:oid=$oid >revs &&
+	git -C r3 rev-list --quiet --objects --filter-print-omitted \
+		--filter=sparse:oid=$oid HEAD >revs &&
 	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
@@ -213,7 +223,8 @@ test_expect_success 'verify sparse:oid=oid-ish omits top-level files' '
 	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
-	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:oid=master:pattern >revs &&
+	git -C r3 rev-list --quiet --objects --filter-print-omitted \
+		--filter=sparse:oid=master:pattern HEAD >revs &&
 	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
@@ -235,7 +246,7 @@ test_expect_success 'rev-list W/ --missing=print' '
 		rm r1/.git/objects/$id
 	done &&
 
-	git -C r1 rev-list --quiet HEAD --missing=print --objects >revs &&
+	git -C r1 rev-list --quiet --missing=print --objects HEAD >revs &&
 	awk -f print_1.awk revs |
 	sed "s/?//" |
 	sort >observed &&
-- 
2.19.0.605.g01d371f741-goog


^ permalink raw reply related	[flat|nested] 66+ messages in thread

* Re: [PATCH v4 7/7] tests: order arguments to git-rev-list properly
  2018-10-03 16:26   ` [PATCH v4 7/7] tests: order arguments to git-rev-list properly Matthew DeVore
@ 2018-10-03 16:33     ` Matthew DeVore
  2018-10-05  8:16       ` Junio C Hamano
  0 siblings, 1 reply; 66+ messages in thread
From: Matthew DeVore @ 2018-10-03 16:33 UTC (permalink / raw)
  To: git
  Cc: Jeff King, Jonathan Tan, Junio C Hamano, Jonathan Nieder,
	Eric Sunshine, szeder.dev

On Wed, Oct 3, 2018 at 9:26 AM Matthew DeVore <matvore@google.com> wrote:
>
> -       git -C pc1 rev-list HEAD --quiet --objects --missing=print >revs &&
> +       git -C pc1 rev-list --quiet --objects --missing=print >revs HEAD &&
>         awk -f print_1.awk revs |
...
>         git -C pc1 blame origin/master -- file.1.txt >observed.blame &&
>         test_cmp expect.blame observed.blame &&
> -       git -C pc1 rev-list master..origin/master --quiet --objects --missing=print >observed &&
> +       git -C pc1 rev-list --quiet --objects --missing=print >observed \
> +               master..origin/master &&
>         test_line_count = 0 observed

I screwed up by putting the positional argument *after* the
redirection. Sorry for the mix-up. This is interestingly syntactically
valid, though bad stylistically. Here is an inter-diff:

diff --git a/t/t5616-partial-clone.sh b/t/t5616-partial-clone.sh
index eeedd1623..6ff614692 100755
--- a/t/t5616-partial-clone.sh
+++ b/t/t5616-partial-clone.sh
@@ -35,7 +35,7 @@ test_expect_success 'setup bare clone for server' '
 test_expect_success 'do partial clone 1' '
         git clone --no-checkout --filter=blob:none
"file://$(pwd)/srv.bare" pc1 &&

-        git -C pc1 rev-list --quiet --objects --missing=print >revs HEAD &&
+        git -C pc1 rev-list --quiet --objects --missing=print HEAD >revs &&
         awk -f print_1.awk revs |
         sed "s/?//" |
         sort >observed.oids &&
@@ -93,8 +93,8 @@ test_expect_success 'verify diff causes dynamic
object fetch' '
 test_expect_success 'verify blame causes dynamic object fetch' '
         git -C pc1 blame origin/master -- file.1.txt >observed.blame &&
         test_cmp expect.blame observed.blame &&
-        git -C pc1 rev-list --quiet --objects --missing=print >observed \
-                master..origin/master &&
+        git -C pc1 rev-list --quiet --objects --missing=print \
+                master..origin/master >observed &&
         test_line_count = 0 observed
 '

^ permalink raw reply related	[flat|nested] 66+ messages in thread

* Re: [PATCH v4 1/7] t/README: reformat Do, Don't, Keep in mind lists
  2018-10-03 16:25   ` [PATCH v4 1/7] t/README: reformat Do, Don't, Keep in mind lists Matthew DeVore
@ 2018-10-05  6:15     ` Junio C Hamano
  2018-10-05 14:57       ` Matthew DeVore
  0 siblings, 1 reply; 66+ messages in thread
From: Junio C Hamano @ 2018-10-05  6:15 UTC (permalink / raw)
  To: Matthew DeVore; +Cc: git, peff, jonathantanmy, jrn, sunshine, szeder.dev

Matthew DeVore <matvore@google.com> writes:

> diff --git a/t/README b/t/README
> index 9028b47d9..85024aba6 100644
> --- a/t/README
> +++ b/t/README
> @@ -393,13 +393,13 @@ This test harness library does the following things:
>     consistently when command line arguments --verbose (or -v),
>     --debug (or -d), and --immediate (or -i) is given.
>  
> -Do's, don'ts & things to keep in mind
> +Do's & don'ts
>  -------------------------------------

We may not format this with AsciiDoc, but please shorten the
underline so that it aligns with the line above that it applies to.

>  Here are a few examples of things you probably should and shouldn't do
>  when writing tests.

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v4 7/7] tests: order arguments to git-rev-list properly
  2018-10-03 16:33     ` Matthew DeVore
@ 2018-10-05  8:16       ` Junio C Hamano
  0 siblings, 0 replies; 66+ messages in thread
From: Junio C Hamano @ 2018-10-05  8:16 UTC (permalink / raw)
  To: Matthew DeVore
  Cc: git, Jeff King, Jonathan Tan, Jonathan Nieder, Eric Sunshine,
	szeder.dev

Matthew DeVore <matvore@google.com> writes:

> I screwed up by putting the positional argument *after* the
> redirection. Sorry for the mix-up. This is interestingly syntactically
> valid, though bad stylistically. Here is an inter-diff:

Thanks for being careful.  Except for a rather idiomatic 

	echo >&2 message ...

which has redirection at the beginning to emphasize that the output
goes to the standard error stream, I do agree with your "stylistic"
choice of keeping the redirection at the end.

> diff --git a/t/t5616-partial-clone.sh b/t/t5616-partial-clone.sh
> index eeedd1623..6ff614692 100755
> --- a/t/t5616-partial-clone.sh
> +++ b/t/t5616-partial-clone.sh
> @@ -35,7 +35,7 @@ test_expect_success 'setup bare clone for server' '
>  test_expect_success 'do partial clone 1' '
>          git clone --no-checkout --filter=blob:none
> "file://$(pwd)/srv.bare" pc1 &&
>
> -        git -C pc1 rev-list --quiet --objects --missing=print >revs HEAD &&
> +        git -C pc1 rev-list --quiet --objects --missing=print HEAD >revs &&
>          awk -f print_1.awk revs |
>          sed "s/?//" |
>          sort >observed.oids &&
> @@ -93,8 +93,8 @@ test_expect_success 'verify diff causes dynamic
> object fetch' '
>  test_expect_success 'verify blame causes dynamic object fetch' '
>          git -C pc1 blame origin/master -- file.1.txt >observed.blame &&
>          test_cmp expect.blame observed.blame &&
> -        git -C pc1 rev-list --quiet --objects --missing=print >observed \
> -                master..origin/master &&
> +        git -C pc1 rev-list --quiet --objects --missing=print \
> +                master..origin/master >observed &&
>          test_line_count = 0 observed
>  '

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v4 1/7] t/README: reformat Do, Don't, Keep in mind lists
  2018-10-05  6:15     ` Junio C Hamano
@ 2018-10-05 14:57       ` Matthew DeVore
  0 siblings, 0 replies; 66+ messages in thread
From: Matthew DeVore @ 2018-10-05 14:57 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: git, Jeff King, Jonathan Tan, Jonathan Nieder, Eric Sunshine,
	szeder.dev

On Thu, Oct 4, 2018 at 11:15 PM Junio C Hamano <gitster@pobox.com> wrote:
>
> Matthew DeVore <matvore@google.com> writes:
>
> > -Do's, don'ts & things to keep in mind
> > +Do's & don'ts
> >  -------------------------------------
>
> We may not format this with AsciiDoc, but please shorten the
> underline so that it aligns with the line above that it applies to.
>
Thanks - Done. I will send a re-roll within the next 8 hours assuming
no further comments.

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v4 5/7] tests: don't swallow Git errors upstream of pipes
  2018-10-03 16:26   ` [PATCH v4 5/7] tests: don't swallow Git errors upstream of pipes Matthew DeVore
@ 2018-10-05 16:48     ` Junio C Hamano
  2018-10-05 17:54       ` Matthew DeVore
  0 siblings, 1 reply; 66+ messages in thread
From: Junio C Hamano @ 2018-10-05 16:48 UTC (permalink / raw)
  To: Matthew DeVore; +Cc: git, peff, jonathantanmy, jrn, sunshine, szeder.dev

Matthew DeVore <matvore@google.com> writes:

> Some pipes in tests lose the exit code of git processes, which can mask
> unexpected behavior like crashes. Split these pipes up so that git
> commands are only at the end of pipes rather than the beginning or
> middle.
>
> The violations fixed in this patch were found in the process of fixing
> pipe placement in a prior patch.

Hopefully this is not a blind mechanical patch, as introduction of
unexpected temporary files in the working tree could interfere with
later tests (e.g. they may expect exact set of untracked files, and
these new temporary files would b unexpected additions).

Thanks.

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v4 2/7] Documentation: add shell guidelines
  2018-10-03 16:26   ` [PATCH v4 2/7] Documentation: add shell guidelines Matthew DeVore
@ 2018-10-05 16:48     ` Junio C Hamano
  2018-10-05 18:21       ` Matthew DeVore
  0 siblings, 1 reply; 66+ messages in thread
From: Junio C Hamano @ 2018-10-05 16:48 UTC (permalink / raw)
  To: Matthew DeVore; +Cc: git, peff, jonathantanmy, jrn, sunshine, szeder.dev

Matthew DeVore <matvore@google.com> writes:

> Add the following guideline to Documentation/CodingGuidelines:
>
> 	&&, ||, and | should appear at the end of lines, not the
> 	beginning, and the \ line continuation character should be
> 	omitted

"should be omitted" sounds as if it is the norm to have such a
character, but it is not.  The text in the actual patch body does a
much better job than this.

Perhaps

	Break overlong lines after "&&", "||", and "|", not before
	them; that way the command can continue to subsequent lines
	without backslash at the end.

> And the following to t/README (since it is specific to writing tests):
>
> 	pipes and $(git ...) should be avoided when they swallow exit
> 	codes of Git processes

Good.

> Signed-off-by: Matthew DeVore <matvore@google.com>
> ---
>  Documentation/CodingGuidelines | 18 ++++++++++++++++++
>  t/README                       | 28 ++++++++++++++++++++++++++++
>  2 files changed, 46 insertions(+)
>
> diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines
> index 48aa4edfb..72967deb7 100644
> --- a/Documentation/CodingGuidelines
> +++ b/Documentation/CodingGuidelines
> @@ -118,6 +118,24 @@ For shell scripts specifically (not exhaustive):
>  		do this
>  	fi
>  
> + - If a command sequence joined with && or || or | spans multiple
> +   lines, put each command on a separate line and put && and || and |
> +   operators at the end of each line, rather than the start. This
> +   means you don't need to use \ to join lines, since the above
> +   operators imply the sequence isn't finished.

Correct.  Even though I wonder if we need to say the last sentence,
which is rather obvious, patch is already written and I do not see
much point editing this further.

> +	(incorrect)
> +	grep blob verify_pack_result \
> +	| awk -f print_1.awk \
> +	| sort >actual &&
> +	...
> +
> +	(correct)
> +	grep blob verify_pack_result |
> +	awk -f print_1.awk |
> +	sort >actual &&
> +	...
> +
>   - We prefer "test" over "[ ... ]".
>  
>   - We do not write the noiseword "function" in front of shell
> diff --git a/t/README b/t/README
> index 85024aba6..9a71d5732 100644
> --- a/t/README
> +++ b/t/README
> @@ -466,6 +466,34 @@ And here are the "don'ts:"
>     platform commands; just use '! cmd'.  We are not in the business
>     of verifying that the world given to us sanely works.
>  
> + - Don't use Git upstream in the non-final position in a piped chain, as
> +   in:

"upstream in the non-final position" is a bit redundant, isn't it?

  - Don't feed the output of 'git' to a pipe, as in:

> +
> +     git -C repo ls-files |
> +     xargs -n 1 basename |
> +     grep foo
> +
> +   which will discard git's exit code and may mask a crash. In the
> +   above example, all exit codes are ignored except grep's.

Good.

> +   Instead, write the output of that command to a temporary
> +   file with ">" or assign it to a variable with "x=$(git ...)" rather
> +   than pipe it.
> +
> + - Don't use command substitution in a way that discards git's exit
> +   code. When assigning to a variable, the exit code is not discarded,
> +   e.g.:
> +
> +     x=$(git cat-file -p $sha) &&
> +     ...
> +
> +   is OK because a crash in "git cat-file" will cause the "&&" chain
> +   to fail, but:
> +
> +     test "refs/heads/foo" = "$(git symbolic-ref HEAD)"
> +
> +   is not OK and a crash in git could go undetected.

Good.

>   - Don't use perl without spelling it as "$PERL_PATH". This is to help
>     our friends on Windows where the platform Perl often adds CR before
>     the end of line, and they bundle Git with a version of Perl that

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v4 5/7] tests: don't swallow Git errors upstream of pipes
  2018-10-05 16:48     ` Junio C Hamano
@ 2018-10-05 17:54       ` Matthew DeVore
  2018-10-05 18:12         ` Matthew DeVore
  0 siblings, 1 reply; 66+ messages in thread
From: Matthew DeVore @ 2018-10-05 17:54 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: git, Jeff King, Jonathan Tan, Jonathan Nieder, Eric Sunshine,
	szeder.dev

On Fri, Oct 5, 2018 at 9:48 AM Junio C Hamano <gitster@pobox.com> wrote:
>
> Hopefully this is not a blind mechanical patch, as introduction of
> unexpected temporary files in the working tree could interfere with
> later tests (e.g. they may expect exact set of untracked files, and
> these new temporary files would b unexpected additions).
>
> Thanks.

I reviewed the files modified in this patch. For the svn one, there
are other scratch files being created in the cwd before mine, so my
additions should be fine, I admit I don't fully understand the
commands being run in that test...after the temp files are created, I
see git svn proplist and git svn propget being executed... the public
documentation for them does not seem to contradict my assumption.
(http://svnbook.red-bean.com/en/1.6/svn.ref.svn.c.propget.html)

As for the other test files in this patch, all git invocations are
either "git clone" or "git init <dir>" or "git -C ..." which means
none of them care about extra files in the cwd. After I searched for
Git commands I read through the files somewhat briskly and looked for
any globs or suspicious invocations of awk, grep, or other commands
(we really do use a limited number of commands in the tests I saw :)
and did not find anything that depended on existence or non-existence
of unnamed files.

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v4 5/7] tests: don't swallow Git errors upstream of pipes
  2018-10-05 17:54       ` Matthew DeVore
@ 2018-10-05 18:12         ` Matthew DeVore
  0 siblings, 0 replies; 66+ messages in thread
From: Matthew DeVore @ 2018-10-05 18:12 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: git, Jeff King, Jonathan Tan, Jonathan Nieder, Eric Sunshine,
	szeder.dev

I just realized that the changes to t9101 should actually be part of
the next patch (6/7), not this one. I've fixed that for the next
re-roll.

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v4 2/7] Documentation: add shell guidelines
  2018-10-05 16:48     ` Junio C Hamano
@ 2018-10-05 18:21       ` Matthew DeVore
  0 siblings, 0 replies; 66+ messages in thread
From: Matthew DeVore @ 2018-10-05 18:21 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: git, Jeff King, Jonathan Tan, Jonathan Nieder, Eric Sunshine,
	szeder.dev

On Fri, Oct 5, 2018 at 9:48 AM Junio C Hamano <gitster@pobox.com> wrote:
>
> Matthew DeVore <matvore@google.com> writes:
>
> > Add the following guideline to Documentation/CodingGuidelines:
> >
> >       &&, ||, and | should appear at the end of lines, not the
> >       beginning, and the \ line continuation character should be
> >       omitted
>
> "should be omitted" sounds as if it is the norm to have such a
> character, but it is not.  The text in the actual patch body does a
> much better job than this.
>
> Perhaps
>
>         Break overlong lines after "&&", "||", and "|", not before
>         them; that way the command can continue to subsequent lines
>         without backslash at the end.
That sounds good. Fixed.

> > + - If a command sequence joined with && or || or | spans multiple
> > +   lines, put each command on a separate line and put && and || and |
> > +   operators at the end of each line, rather than the start. This
> > +   means you don't need to use \ to join lines, since the above
> > +   operators imply the sequence isn't finished.
>
> Correct.  Even though I wonder if we need to say the last sentence,
> which is rather obvious, patch is already written and I do not see
> much point editing this further.
ack

> > @@ -466,6 +466,34 @@ And here are the "don'ts:"
> >     platform commands; just use '! cmd'.  We are not in the business
> >     of verifying that the world given to us sanely works.
> >
> > + - Don't use Git upstream in the non-final position in a piped chain, as
> > +   in:
>
> "upstream in the non-final position" is a bit redundant, isn't it?
>
>   - Don't feed the output of 'git' to a pipe, as in:

Done, but I changed it to "Don't feed the output of a git command to a
pipe, as in:" since referring to it as "git command" without the
quotes seems rather common in this file.

Thank you for the review!

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v5 0/7] subject: Clean up tests for test_cmp arg ordering and pipe placement
  2018-09-15  0:02 [PATCH v1 0/2] Cleanup tests for test_cmp argument ordering and "|" placement Matthew DeVore
                   ` (6 preceding siblings ...)
  2018-10-03 16:25 ` [PATCH v4 0/7] Clean up tests for test_cmp arg ordering and pipe placement Matthew DeVore
@ 2018-10-05 21:54 ` Matthew DeVore
  2018-10-05 21:54   ` [PATCH v5 1/7] t/README: reformat Do, Don't, Keep in mind lists Matthew DeVore
                     ` (7 more replies)
  7 siblings, 8 replies; 66+ messages in thread
From: Matthew DeVore @ 2018-10-05 21:54 UTC (permalink / raw)
  To: git; +Cc: Matthew DeVore, peff, jonathantanmy, gitster, jrn, sunshine,
	szeder.dev

This version of the patchset fixes some wording and formatting issues
pointed out by Junio. The commit message in the first patch has also
been reworded.

Thank you,
Matt

diff --git a/t/README b/t/README
index 9a71d5732..ab9fa4230 100644
--- a/t/README
+++ b/t/README
@@ -394,7 +394,7 @@ This test harness library does the following things:
    --debug (or -d), and --immediate (or -i) is given.
 
 Do's & don'ts
--------------------------------------
+-------------
 
 Here are a few examples of things you probably should and shouldn't do
 when writing tests.
@@ -466,8 +466,7 @@ And here are the "don'ts:"
    platform commands; just use '! cmd'.  We are not in the business
    of verifying that the world given to us sanely works.
 
- - Don't use Git upstream in the non-final position in a piped chain, as
-   in:
+ - Don't feed the output of a git command to a pipe, as in:
 
      git -C repo ls-files |
      xargs -n 1 basename |
diff --git a/t/t5616-partial-clone.sh b/t/t5616-partial-clone.sh
index eeedd1623..6ff614692 100755
--- a/t/t5616-partial-clone.sh
+++ b/t/t5616-partial-clone.sh
@@ -35,7 +35,7 @@ test_expect_success 'setup bare clone for server' '
 test_expect_success 'do partial clone 1' '
         git clone --no-checkout --filter=blob:none "file://$(pwd)/srv.bare" pc1 &&
 
-        git -C pc1 rev-list --quiet --objects --missing=print >revs HEAD &&
+        git -C pc1 rev-list --quiet --objects --missing=print HEAD >revs &&
         awk -f print_1.awk revs |
         sed "s/?//" |
         sort >observed.oids &&
@@ -93,8 +93,8 @@ test_expect_success 'verify diff causes dynamic object fetch' '
 test_expect_success 'verify blame causes dynamic object fetch' '
         git -C pc1 blame origin/master -- file.1.txt >observed.blame &&
         test_cmp expect.blame observed.blame &&
-        git -C pc1 rev-list --quiet --objects --missing=print >observed \
-                master..origin/master &&
+        git -C pc1 rev-list --quiet --objects --missing=print \
+                master..origin/master >observed &&
         test_line_count = 0 observed
 '
 

Matthew DeVore (7):
  t/README: reformat Do, Don't, Keep in mind lists
  Documentation: add shell guidelines
  tests: standardize pipe placement
  t/*: fix ordering of expected/observed arguments
  tests: don't swallow Git errors upstream of pipes
  t9109: don't swallow Git errors upstream of pipes
  tests: order arguments to git-rev-list properly

 Documentation/CodingGuidelines         |  18 ++
 t/README                               |  69 +++--
 t/lib-gpg.sh                           |   9 +-
 t/t0000-basic.sh                       |   2 +-
 t/t0021-conversion.sh                  |   4 +-
 t/t1006-cat-file.sh                    |   8 +-
 t/t1300-config.sh                      |   9 +-
 t/t1303-wacky-config.sh                |   4 +-
 t/t2101-update-index-reupdate.sh       |   2 +-
 t/t3200-branch.sh                      |   2 +-
 t/t3320-notes-merge-worktrees.sh       |   4 +-
 t/t3400-rebase.sh                      |   8 +-
 t/t3417-rebase-whitespace-fix.sh       |   6 +-
 t/t3702-add-edit.sh                    |   4 +-
 t/t3903-stash.sh                       |   8 +-
 t/t3905-stash-include-untracked.sh     |   2 +-
 t/t4025-hunk-header.sh                 |   2 +-
 t/t4117-apply-reject.sh                |   6 +-
 t/t4124-apply-ws-rule.sh               |  30 +--
 t/t4138-apply-ws-expansion.sh          |   2 +-
 t/t5317-pack-objects-filter-objects.sh | 360 ++++++++++++++-----------
 t/t5318-commit-graph.sh                |   2 +-
 t/t5500-fetch-pack.sh                  |   7 +-
 t/t5616-partial-clone.sh               |  50 ++--
 t/t5701-git-serve.sh                   |  14 +-
 t/t5702-protocol-v2.sh                 |  14 +-
 t/t6023-merge-file.sh                  |  12 +-
 t/t6027-merge-binary.sh                |   4 +-
 t/t6031-merge-filemode.sh              |   2 +-
 t/t6112-rev-list-filters-objects.sh    | 237 +++++++++-------
 t/t7201-co.sh                          |   4 +-
 t/t7406-submodule-update.sh            |   8 +-
 t/t7800-difftool.sh                    |   2 +-
 t/t9100-git-svn-basic.sh               |   2 +-
 t/t9101-git-svn-props.sh               |  34 ++-
 t/t9133-git-svn-nested-git-repo.sh     |   6 +-
 t/t9600-cvsimport.sh                   |   2 +-
 t/t9603-cvsimport-patchsets.sh         |   4 +-
 t/t9604-cvsimport-timestamps.sh        |   4 +-
 39 files changed, 568 insertions(+), 399 deletions(-)

-- 
2.19.0.605.g01d371f741-goog


^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [PATCH v5 1/7] t/README: reformat Do, Don't, Keep in mind lists
  2018-10-05 21:54 ` [PATCH v5 0/7] subject: Clean up tests for test_cmp arg ordering and pipe placement Matthew DeVore
@ 2018-10-05 21:54   ` Matthew DeVore
  2018-10-05 21:54   ` [PATCH v5 2/7] Documentation: add shell guidelines Matthew DeVore
                     ` (6 subsequent siblings)
  7 siblings, 0 replies; 66+ messages in thread
From: Matthew DeVore @ 2018-10-05 21:54 UTC (permalink / raw)
  To: git; +Cc: Matthew DeVore, peff, jonathantanmy, gitster, jrn, sunshine,
	szeder.dev

The list of Don'ts for test writing has grown large such that it is hard
to see at a glance which section an item is in. In other words, if I
ignore a little bit of surrounding context, the "don'ts" look like
"do's."

To make the list more readable, prefix "Don't" in front of every first
sentence in the items.

Also, the "Keep in mind" list is out of place and awkward, because it
was a very short "list" beneath two very long ones, and it seemed easy
to miss under the list of "don'ts," and it only had one item. So move
this item to the list of "do's" and phrase as "Remember..."

Signed-off-by: Matthew DeVore <matvore@google.com>
---
 t/README | 42 ++++++++++++++++++++----------------------
 1 file changed, 20 insertions(+), 22 deletions(-)

diff --git a/t/README b/t/README
index 9028b47d9..68012d673 100644
--- a/t/README
+++ b/t/README
@@ -393,13 +393,13 @@ This test harness library does the following things:
    consistently when command line arguments --verbose (or -v),
    --debug (or -d), and --immediate (or -i) is given.
 
-Do's, don'ts & things to keep in mind
--------------------------------------
+Do's & don'ts
+-------------
 
 Here are a few examples of things you probably should and shouldn't do
 when writing tests.
 
-Do:
+Here are the "do's:"
 
  - Put all code inside test_expect_success and other assertions.
 
@@ -444,16 +444,21 @@ Do:
    Windows, where the shell (MSYS bash) mangles absolute path names.
    For details, see the commit message of 4114156ae9.
 
-Don't:
+ - Remember that inside the <script> part, the standard output and
+   standard error streams are discarded, and the test harness only
+   reports "ok" or "not ok" to the end user running the tests. Under
+   --verbose, they are shown to help debug the tests.
+
+And here are the "don'ts:"
 
- - exit() within a <script> part.
+ - Don't exit() within a <script> part.
 
    The harness will catch this as a programming error of the test.
    Use test_done instead if you need to stop the tests early (see
    "Skipping tests" below).
 
- - use '! git cmd' when you want to make sure the git command exits
-   with failure in a controlled way by calling "die()".  Instead,
+ - Don't use '! git cmd' when you want to make sure the git command
+   exits with failure in a controlled way by calling "die()".  Instead,
    use 'test_must_fail git cmd'.  This will signal a failure if git
    dies in an unexpected way (e.g. segfault).
 
@@ -461,8 +466,8 @@ Don't:
    platform commands; just use '! cmd'.  We are not in the business
    of verifying that the world given to us sanely works.
 
- - use perl without spelling it as "$PERL_PATH". This is to help our
-   friends on Windows where the platform Perl often adds CR before
+ - Don't use perl without spelling it as "$PERL_PATH". This is to help
+   our friends on Windows where the platform Perl often adds CR before
    the end of line, and they bundle Git with a version of Perl that
    does not do so, whose path is specified with $PERL_PATH. Note that we
    provide a "perl" function which uses $PERL_PATH under the hood, so
@@ -470,17 +475,17 @@ Don't:
    (but you do, for example, on a shebang line or in a sub script
    created via "write_script").
 
- - use sh without spelling it as "$SHELL_PATH", when the script can
-   be misinterpreted by broken platform shell (e.g. Solaris).
+ - Don't use sh without spelling it as "$SHELL_PATH", when the script
+   can be misinterpreted by broken platform shell (e.g. Solaris).
 
- - chdir around in tests.  It is not sufficient to chdir to
+ - Don't chdir around in tests.  It is not sufficient to chdir to
    somewhere and then chdir back to the original location later in
    the test, as any intermediate step can fail and abort the test,
    causing the next test to start in an unexpected directory.  Do so
    inside a subshell if necessary.
 
- - save and verify the standard error of compound commands, i.e. group
-   commands, subshells, and shell functions (except test helper
+ - Don't save and verify the standard error of compound commands, i.e.
+   group commands, subshells, and shell functions (except test helper
    functions like 'test_must_fail') like this:
 
      ( cd dir && git cmd ) 2>error &&
@@ -495,7 +500,7 @@ Don't:
      ( cd dir && git cmd 2>../error ) &&
      test_cmp expect error
 
- - Break the TAP output
+ - Don't break the TAP output
 
    The raw output from your test may be interpreted by a TAP harness. TAP
    harnesses will ignore everything they don't know about, but don't step
@@ -515,13 +520,6 @@ Don't:
    but the best indication is to just run the tests with prove(1),
    it'll complain if anything is amiss.
 
-Keep in mind:
-
- - Inside the <script> part, the standard output and standard error
-   streams are discarded, and the test harness only reports "ok" or
-   "not ok" to the end user running the tests. Under --verbose, they
-   are shown to help debugging the tests.
-
 
 Skipping tests
 --------------
-- 
2.19.0.605.g01d371f741-goog


^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [PATCH v5 2/7] Documentation: add shell guidelines
  2018-10-05 21:54 ` [PATCH v5 0/7] subject: Clean up tests for test_cmp arg ordering and pipe placement Matthew DeVore
  2018-10-05 21:54   ` [PATCH v5 1/7] t/README: reformat Do, Don't, Keep in mind lists Matthew DeVore
@ 2018-10-05 21:54   ` Matthew DeVore
  2018-10-05 21:54   ` [PATCH v5 3/7] tests: standardize pipe placement Matthew DeVore
                     ` (5 subsequent siblings)
  7 siblings, 0 replies; 66+ messages in thread
From: Matthew DeVore @ 2018-10-05 21:54 UTC (permalink / raw)
  To: git; +Cc: Matthew DeVore, peff, jonathantanmy, gitster, jrn, sunshine,
	szeder.dev

Add the following guideline to Documentation/CodingGuidelines:

	Break overlong lines after "&&", "||", and "|", not before
	them; that way the command can continue to subsequent lines
	without backslash at the end.

And the following to t/README (since it is specific to writing tests):

	Pipes and $(git ...) should be avoided when they swallow exit
	codes of Git processes

Signed-off-by: Matthew DeVore <matvore@google.com>
---
 Documentation/CodingGuidelines | 18 ++++++++++++++++++
 t/README                       | 27 +++++++++++++++++++++++++++
 2 files changed, 45 insertions(+)

diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines
index 48aa4edfb..72967deb7 100644
--- a/Documentation/CodingGuidelines
+++ b/Documentation/CodingGuidelines
@@ -118,6 +118,24 @@ For shell scripts specifically (not exhaustive):
 		do this
 	fi
 
+ - If a command sequence joined with && or || or | spans multiple
+   lines, put each command on a separate line and put && and || and |
+   operators at the end of each line, rather than the start. This
+   means you don't need to use \ to join lines, since the above
+   operators imply the sequence isn't finished.
+
+	(incorrect)
+	grep blob verify_pack_result \
+	| awk -f print_1.awk \
+	| sort >actual &&
+	...
+
+	(correct)
+	grep blob verify_pack_result |
+	awk -f print_1.awk |
+	sort >actual &&
+	...
+
  - We prefer "test" over "[ ... ]".
 
  - We do not write the noiseword "function" in front of shell
diff --git a/t/README b/t/README
index 68012d673..ab9fa4230 100644
--- a/t/README
+++ b/t/README
@@ -466,6 +466,33 @@ And here are the "don'ts:"
    platform commands; just use '! cmd'.  We are not in the business
    of verifying that the world given to us sanely works.
 
+ - Don't feed the output of a git command to a pipe, as in:
+
+     git -C repo ls-files |
+     xargs -n 1 basename |
+     grep foo
+
+   which will discard git's exit code and may mask a crash. In the
+   above example, all exit codes are ignored except grep's.
+
+   Instead, write the output of that command to a temporary
+   file with ">" or assign it to a variable with "x=$(git ...)" rather
+   than pipe it.
+
+ - Don't use command substitution in a way that discards git's exit
+   code. When assigning to a variable, the exit code is not discarded,
+   e.g.:
+
+     x=$(git cat-file -p $sha) &&
+     ...
+
+   is OK because a crash in "git cat-file" will cause the "&&" chain
+   to fail, but:
+
+     test "refs/heads/foo" = "$(git symbolic-ref HEAD)"
+
+   is not OK and a crash in git could go undetected.
+
  - Don't use perl without spelling it as "$PERL_PATH". This is to help
    our friends on Windows where the platform Perl often adds CR before
    the end of line, and they bundle Git with a version of Perl that
-- 
2.19.0.605.g01d371f741-goog


^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [PATCH v5 3/7] tests: standardize pipe placement
  2018-10-05 21:54 ` [PATCH v5 0/7] subject: Clean up tests for test_cmp arg ordering and pipe placement Matthew DeVore
  2018-10-05 21:54   ` [PATCH v5 1/7] t/README: reformat Do, Don't, Keep in mind lists Matthew DeVore
  2018-10-05 21:54   ` [PATCH v5 2/7] Documentation: add shell guidelines Matthew DeVore
@ 2018-10-05 21:54   ` Matthew DeVore
  2018-10-05 21:54   ` [PATCH v5 4/7] t/*: fix ordering of expected/observed arguments Matthew DeVore
                     ` (4 subsequent siblings)
  7 siblings, 0 replies; 66+ messages in thread
From: Matthew DeVore @ 2018-10-05 21:54 UTC (permalink / raw)
  To: git; +Cc: Matthew DeVore, peff, jonathantanmy, gitster, jrn, sunshine,
	szeder.dev

Instead of using a line-continuation and pipe on the second line, take
advantage of the shell's implicit line continuation after a pipe
character.  So for example, instead of

	some long line \
		| next line

use

	some long line |
	next line

And add a blank line before and after the pipe where it aids readability
(it usually does).

This better matches the coding style documented in
Documentation/CodingGuidelines and used in shell scripts elsewhere in
the tree.

Signed-off-by: Matthew DeVore <matvore@google.com>
---
 t/lib-gpg.sh                           |   9 +-
 t/t1006-cat-file.sh                    |   8 +-
 t/t1300-config.sh                      |   5 +-
 t/t5317-pack-objects-filter-objects.sh | 330 ++++++++++++++-----------
 t/t5500-fetch-pack.sh                  |   7 +-
 t/t5616-partial-clone.sh               |  32 ++-
 t/t6112-rev-list-filters-objects.sh    | 203 ++++++++-------
 7 files changed, 344 insertions(+), 250 deletions(-)

diff --git a/t/lib-gpg.sh b/t/lib-gpg.sh
index 3fe02876c..f1277bef4 100755
--- a/t/lib-gpg.sh
+++ b/t/lib-gpg.sh
@@ -57,9 +57,12 @@ then
 		echo | gpgsm --homedir "${GNUPGHOME}" 2>/dev/null \
 			--passphrase-fd 0 --pinentry-mode loopback \
 			--import "$TEST_DIRECTORY"/lib-gpg/gpgsm_cert.p12 &&
-		gpgsm --homedir "${GNUPGHOME}" 2>/dev/null -K \
-			| grep fingerprint: | cut -d" " -f4 | tr -d '\n' > \
-			${GNUPGHOME}/trustlist.txt &&
+
+		gpgsm --homedir "${GNUPGHOME}" 2>/dev/null -K |
+		grep fingerprint: |
+		cut -d" " -f4 |
+		tr -d '\n' >"${GNUPGHOME}/trustlist.txt" &&
+
 		echo " S relax" >> ${GNUPGHOME}/trustlist.txt &&
 		(gpgconf --kill gpg-agent >/dev/null 2>&1 || : ) &&
 		echo hello | gpgsm --homedir "${GNUPGHOME}" >/dev/null \
diff --git a/t/t1006-cat-file.sh b/t/t1006-cat-file.sh
index 7f19d591f..a0fa926d3 100755
--- a/t/t1006-cat-file.sh
+++ b/t/t1006-cat-file.sh
@@ -218,8 +218,8 @@ test_expect_success "--batch-check for a non-existent hash" '
     test "0000000000000000000000000000000000000042 missing
 0000000000000000000000000000000000000084 missing" = \
     "$( ( echo 0000000000000000000000000000000000000042;
-         echo_without_newline 0000000000000000000000000000000000000084; ) \
-       | git cat-file --batch-check)"
+         echo_without_newline 0000000000000000000000000000000000000084; ) |
+       git cat-file --batch-check)"
 '
 
 test_expect_success "--batch for an existent and a non-existent hash" '
@@ -227,8 +227,8 @@ test_expect_success "--batch for an existent and a non-existent hash" '
 $tag_content
 0000000000000000000000000000000000000000 missing" = \
     "$( ( echo $tag_sha1;
-         echo_without_newline 0000000000000000000000000000000000000000; ) \
-       | git cat-file --batch)"
+         echo_without_newline 0000000000000000000000000000000000000000; ) |
+       git cat-file --batch)"
 '
 
 test_expect_success "--batch-check for an empty line" '
diff --git a/t/t1300-config.sh b/t/t1300-config.sh
index cdf1fed5d..5869d6cb6 100755
--- a/t/t1300-config.sh
+++ b/t/t1300-config.sh
@@ -1770,8 +1770,9 @@ test_expect_success '--show-origin stdin with file include' '
 	cat >expect <<-EOF &&
 		file:$INCLUDE_DIR/stdin.include	include
 	EOF
-	echo "[include]path=\"$INCLUDE_DIR\"/stdin.include" \
-		| git config --show-origin --includes --file - user.stdin >output &&
+	echo "[include]path=\"$INCLUDE_DIR\"/stdin.include" |
+	git config --show-origin --includes --file - user.stdin >output &&
+
 	test_cmp expect output
 '
 
diff --git a/t/t5317-pack-objects-filter-objects.sh b/t/t5317-pack-objects-filter-objects.sh
index 6710c8bc8..ce69148ec 100755
--- a/t/t5317-pack-objects-filter-objects.sh
+++ b/t/t5317-pack-objects-filter-objects.sh
@@ -20,17 +20,20 @@ test_expect_success 'setup r1' '
 '
 
 test_expect_success 'verify blob count in normal packfile' '
-	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	git -C r1 pack-objects --rev --stdout >all.pack <<-EOF &&
 	HEAD
 	EOF
 	git -C r1 index-pack ../all.pack &&
-	git -C r1 verify-pack -v ../all.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r1 verify-pack -v ../all.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
@@ -39,23 +42,27 @@ test_expect_success 'verify blob:none packfile has no blobs' '
 	HEAD
 	EOF
 	git -C r1 index-pack ../filter.pack &&
-	git -C r1 verify-pack -v ../filter.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r1 verify-pack -v ../filter.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	nr=$(wc -l <observed) &&
 	test 0 -eq $nr
 '
 
 test_expect_success 'verify normal and blob:none packfiles have same commits/trees' '
-	git -C r1 verify-pack -v ../all.pack \
-		| grep -E "commit|tree" \
-		| awk -f print_1.awk \
-		| sort >expected &&
-	git -C r1 verify-pack -v ../filter.pack \
-		| grep -E "commit|tree" \
-		| awk -f print_1.awk \
-		| sort >observed &&
+	git -C r1 verify-pack -v ../all.pack |
+	grep -E "commit|tree" |
+	awk -f print_1.awk |
+	sort >expected &&
+
+	git -C r1 verify-pack -v ../filter.pack |
+	grep -E "commit|tree" |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
@@ -75,17 +82,20 @@ test_expect_success 'setup r2' '
 '
 
 test_expect_success 'verify blob count in normal packfile' '
-	git -C r2 ls-files -s large.1000 large.10000 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r2 ls-files -s large.1000 large.10000 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	git -C r2 pack-objects --rev --stdout >all.pack <<-EOF &&
 	HEAD
 	EOF
 	git -C r2 index-pack ../all.pack &&
-	git -C r2 verify-pack -v ../all.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r2 verify-pack -v ../all.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
@@ -94,10 +104,12 @@ test_expect_success 'verify blob:limit=500 omits all blobs' '
 	HEAD
 	EOF
 	git -C r2 index-pack ../filter.pack &&
-	git -C r2 verify-pack -v ../filter.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r2 verify-pack -v ../filter.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	nr=$(wc -l <observed) &&
 	test 0 -eq $nr
 '
@@ -107,99 +119,118 @@ test_expect_success 'verify blob:limit=1000' '
 	HEAD
 	EOF
 	git -C r2 index-pack ../filter.pack &&
-	git -C r2 verify-pack -v ../filter.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r2 verify-pack -v ../filter.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	nr=$(wc -l <observed) &&
 	test 0 -eq $nr
 '
 
 test_expect_success 'verify blob:limit=1001' '
-	git -C r2 ls-files -s large.1000 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r2 ls-files -s large.1000 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	git -C r2 pack-objects --rev --stdout --filter=blob:limit=1001 >filter.pack <<-EOF &&
 	HEAD
 	EOF
 	git -C r2 index-pack ../filter.pack &&
-	git -C r2 verify-pack -v ../filter.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r2 verify-pack -v ../filter.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify blob:limit=10001' '
-	git -C r2 ls-files -s large.1000 large.10000 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r2 ls-files -s large.1000 large.10000 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	git -C r2 pack-objects --rev --stdout --filter=blob:limit=10001 >filter.pack <<-EOF &&
 	HEAD
 	EOF
 	git -C r2 index-pack ../filter.pack &&
-	git -C r2 verify-pack -v ../filter.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r2 verify-pack -v ../filter.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify blob:limit=1k' '
-	git -C r2 ls-files -s large.1000 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r2 ls-files -s large.1000 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	git -C r2 pack-objects --rev --stdout --filter=blob:limit=1k >filter.pack <<-EOF &&
 	HEAD
 	EOF
 	git -C r2 index-pack ../filter.pack &&
-	git -C r2 verify-pack -v ../filter.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r2 verify-pack -v ../filter.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify explicitly specifying oversized blob in input' '
-	git -C r2 ls-files -s large.1000 large.10000 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r2 ls-files -s large.1000 large.10000 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	git -C r2 pack-objects --rev --stdout --filter=blob:limit=1k >filter.pack <<-EOF &&
 	HEAD
 	$(git -C r2 rev-parse HEAD:large.10000)
 	EOF
 	git -C r2 index-pack ../filter.pack &&
-	git -C r2 verify-pack -v ../filter.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r2 verify-pack -v ../filter.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify blob:limit=1m' '
-	git -C r2 ls-files -s large.1000 large.10000 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r2 ls-files -s large.1000 large.10000 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	git -C r2 pack-objects --rev --stdout --filter=blob:limit=1m >filter.pack <<-EOF &&
 	HEAD
 	EOF
 	git -C r2 index-pack ../filter.pack &&
-	git -C r2 verify-pack -v ../filter.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r2 verify-pack -v ../filter.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify normal and blob:limit packfiles have same commits/trees' '
-	git -C r2 verify-pack -v ../all.pack \
-		| grep -E "commit|tree" \
-		| awk -f print_1.awk \
-		| sort >expected &&
-	git -C r2 verify-pack -v ../filter.pack \
-		| grep -E "commit|tree" \
-		| awk -f print_1.awk \
-		| sort >observed &&
+	git -C r2 verify-pack -v ../all.pack |
+	grep -E "commit|tree" |
+	awk -f print_1.awk |
+	sort >expected &&
+
+	git -C r2 verify-pack -v ../filter.pack |
+	grep -E "commit|tree" |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
@@ -224,71 +255,84 @@ test_expect_success 'setup r3' '
 '
 
 test_expect_success 'verify blob count in normal packfile' '
-	git -C r3 ls-files -s sparse1 sparse2 dir1/sparse1 dir1/sparse2 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r3 ls-files -s sparse1 sparse2 dir1/sparse1 dir1/sparse2 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	git -C r3 pack-objects --rev --stdout >all.pack <<-EOF &&
 	HEAD
 	EOF
 	git -C r3 index-pack ../all.pack &&
-	git -C r3 verify-pack -v ../all.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r3 verify-pack -v ../all.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify sparse:path=pattern1' '
-	git -C r3 ls-files -s dir1/sparse1 dir1/sparse2 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r3 ls-files -s dir1/sparse1 dir1/sparse2 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	git -C r3 pack-objects --rev --stdout --filter=sparse:path=../pattern1 >filter.pack <<-EOF &&
 	HEAD
 	EOF
 	git -C r3 index-pack ../filter.pack &&
-	git -C r3 verify-pack -v ../filter.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r3 verify-pack -v ../filter.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify normal and sparse:path=pattern1 packfiles have same commits/trees' '
-	git -C r3 verify-pack -v ../all.pack \
-		| grep -E "commit|tree" \
-		| awk -f print_1.awk \
-		| sort >expected &&
-	git -C r3 verify-pack -v ../filter.pack \
-		| grep -E "commit|tree" \
-		| awk -f print_1.awk \
-		| sort >observed &&
+	git -C r3 verify-pack -v ../all.pack |
+	grep -E "commit|tree" |
+	awk -f print_1.awk |
+	sort >expected &&
+
+	git -C r3 verify-pack -v ../filter.pack |
+	grep -E "commit|tree" |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify sparse:path=pattern2' '
-	git -C r3 ls-files -s sparse1 dir1/sparse1 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r3 ls-files -s sparse1 dir1/sparse1 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	git -C r3 pack-objects --rev --stdout --filter=sparse:path=../pattern2 >filter.pack <<-EOF &&
 	HEAD
 	EOF
 	git -C r3 index-pack ../filter.pack &&
-	git -C r3 verify-pack -v ../filter.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r3 verify-pack -v ../filter.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify normal and sparse:path=pattern2 packfiles have same commits/trees' '
-	git -C r3 verify-pack -v ../all.pack \
-		| grep -E "commit|tree" \
-		| awk -f print_1.awk \
-		| sort >expected &&
-	git -C r3 verify-pack -v ../filter.pack \
-		| grep -E "commit|tree" \
-		| awk -f print_1.awk \
-		| sort >observed &&
+	git -C r3 verify-pack -v ../all.pack |
+	grep -E "commit|tree" |
+	awk -f print_1.awk |
+	sort >expected &&
+
+	git -C r3 verify-pack -v ../filter.pack |
+	grep -E "commit|tree" |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
@@ -312,48 +356,57 @@ test_expect_success 'setup r4' '
 '
 
 test_expect_success 'verify blob count in normal packfile' '
-	git -C r4 ls-files -s pattern sparse1 sparse2 dir1/sparse1 dir1/sparse2 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r4 ls-files -s pattern sparse1 sparse2 dir1/sparse1 dir1/sparse2 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	git -C r4 pack-objects --rev --stdout >all.pack <<-EOF &&
 	HEAD
 	EOF
 	git -C r4 index-pack ../all.pack &&
-	git -C r4 verify-pack -v ../all.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r4 verify-pack -v ../all.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify sparse:oid=OID' '
-	git -C r4 ls-files -s dir1/sparse1 dir1/sparse2 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r4 ls-files -s dir1/sparse1 dir1/sparse2 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	oid=$(git -C r4 ls-files -s pattern | awk -f print_2.awk) &&
 	git -C r4 pack-objects --rev --stdout --filter=sparse:oid=$oid >filter.pack <<-EOF &&
 	HEAD
 	EOF
 	git -C r4 index-pack ../filter.pack &&
-	git -C r4 verify-pack -v ../filter.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r4 verify-pack -v ../filter.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify sparse:oid=oid-ish' '
-	git -C r4 ls-files -s dir1/sparse1 dir1/sparse2 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r4 ls-files -s dir1/sparse1 dir1/sparse2 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	git -C r4 pack-objects --rev --stdout --filter=sparse:oid=master:pattern >filter.pack <<-EOF &&
 	HEAD
 	EOF
 	git -C r4 index-pack ../filter.pack &&
-	git -C r4 verify-pack -v ../filter.pack \
-		| grep blob \
-		| awk -f print_1.awk \
-		| sort >observed &&
+
+	git -C r4 verify-pack -v ../filter.pack |
+	grep blob |
+	awk -f print_1.awk |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
@@ -361,9 +414,10 @@ test_expect_success 'verify sparse:oid=oid-ish' '
 # This models previously omitted objects that we did not receive.
 
 test_expect_success 'setup r1 - delete loose blobs' '
-	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	for id in `cat expected | sed "s|..|&/|"`
 	do
 		rm r1/.git/objects/$id
diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh
index 1b5a4a6d3..086f2c40f 100755
--- a/t/t5500-fetch-pack.sh
+++ b/t/t5500-fetch-pack.sh
@@ -50,8 +50,11 @@ pull_to_client () {
 			case "$heads" in *B*)
 			    git update-ref refs/heads/B "$BTIP";;
 			esac &&
-			git symbolic-ref HEAD refs/heads/$(echo $heads \
-				| sed -e "s/^\(.\).*$/\1/") &&
+
+			git symbolic-ref HEAD refs/heads/$(
+				echo $heads |
+				sed -e "s/^\(.\).*$/\1/"
+			) &&
 
 			git fsck --full &&
 
diff --git a/t/t5616-partial-clone.sh b/t/t5616-partial-clone.sh
index bbbe7537d..e4d032c9d 100755
--- a/t/t5616-partial-clone.sh
+++ b/t/t5616-partial-clone.sh
@@ -34,10 +34,12 @@ test_expect_success 'setup bare clone for server' '
 # confirm partial clone was registered in the local config.
 test_expect_success 'do partial clone 1' '
 	git clone --no-checkout --filter=blob:none "file://$(pwd)/srv.bare" pc1 &&
-	git -C pc1 rev-list HEAD --quiet --objects --missing=print \
-		| awk -f print_1.awk \
-		| sed "s/?//" \
-		| sort >observed.oids &&
+
+	git -C pc1 rev-list HEAD --quiet --objects --missing=print |
+	awk -f print_1.awk |
+	sed "s/?//" |
+	sort >observed.oids &&
+
 	test_cmp expect_1.oids observed.oids &&
 	test "$(git -C pc1 config --local core.repositoryformatversion)" = "1" &&
 	test "$(git -C pc1 config --local extensions.partialclone)" = "origin" &&
@@ -130,16 +132,20 @@ test_expect_success 'push new commits to server for file.3.txt' '
 # perhaps combined with a command in dry-run mode.
 test_expect_success 'manual prefetch of missing objects' '
 	git -C pc1 fetch --filter=blob:none origin &&
-	git -C pc1 rev-list master..origin/master --quiet --objects --missing=print \
-		| awk -f print_1.awk \
-		| sed "s/?//" \
-		| sort >observed.oids &&
+
+	git -C pc1 rev-list master..origin/master --quiet --objects --missing=print |
+	awk -f print_1.awk |
+	sed "s/?//" |
+	sort >observed.oids &&
+
 	test_line_count = 6 observed.oids &&
 	git -C pc1 fetch-pack --stdin "file://$(pwd)/srv.bare" <observed.oids &&
-	git -C pc1 rev-list master..origin/master --quiet --objects --missing=print \
-		| awk -f print_1.awk \
-		| sed "s/?//" \
-		| sort >observed.oids &&
+
+	git -C pc1 rev-list master..origin/master --quiet --objects --missing=print |
+	awk -f print_1.awk |
+	sed "s/?//" |
+	sort >observed.oids &&
+
 	test_line_count = 0 observed.oids
 '
 
@@ -194,7 +200,7 @@ test_expect_success 'upon cloning, check that all refs point to objects' '
 
 	# Craft a packfile not including that blob.
 	git -C "$SERVER" rev-parse HEAD |
-		git -C "$SERVER" pack-objects --stdout >incomplete.pack &&
+	git -C "$SERVER" pack-objects --stdout >incomplete.pack &&
 
 	# Replace the existing packfile with the crafted one. The protocol
 	# requires that the packfile be sent in sideband 1, hence the extra
diff --git a/t/t6112-rev-list-filters-objects.sh b/t/t6112-rev-list-filters-objects.sh
index d4ff0b3be..0f6b569e1 100755
--- a/t/t6112-rev-list-filters-objects.sh
+++ b/t/t6112-rev-list-filters-objects.sh
@@ -20,24 +20,28 @@ test_expect_success 'setup r1' '
 '
 
 test_expect_success 'verify blob:none omits all 5 blobs' '
-	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 \
-		| awk -f print_2.awk \
-		| sort >expected &&
-	git -C r1 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:none \
-		| awk -f print_1.awk \
-		| sed "s/~//" \
-		| sort >observed &&
+	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 |
+	awk -f print_2.awk |
+	sort >expected &&
+
+	git -C r1 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:none |
+	awk -f print_1.awk |
+	sed "s/~//" |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify emitted+omitted == all' '
-	git -C r1 rev-list HEAD --objects \
-		| awk -f print_1.awk \
-		| sort >expected &&
-	git -C r1 rev-list HEAD --objects --filter-print-omitted --filter=blob:none \
-		| awk -f print_1.awk \
-		| sed "s/~//" \
-		| sort >observed &&
+	git -C r1 rev-list HEAD --objects |
+	awk -f print_1.awk |
+	sort >expected &&
+
+	git -C r1 rev-list HEAD --objects --filter-print-omitted --filter=blob:none |
+	awk -f print_1.awk |
+	sed "s/~//" |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
@@ -58,65 +62,76 @@ test_expect_success 'setup r2' '
 '
 
 test_expect_success 'verify blob:limit=500 omits all blobs' '
-	git -C r2 ls-files -s large.1000 large.10000 \
-		| awk -f print_2.awk \
-		| sort >expected &&
-	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=500 \
-		| awk -f print_1.awk \
-		| sed "s/~//" \
-		| sort >observed &&
+	git -C r2 ls-files -s large.1000 large.10000 |
+	awk -f print_2.awk |
+	sort >expected &&
+
+	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=500 |
+	awk -f print_1.awk |
+	sed "s/~//" |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify emitted+omitted == all' '
-	git -C r2 rev-list HEAD --objects \
-		| awk -f print_1.awk \
-		| sort >expected &&
-	git -C r2 rev-list HEAD --objects --filter-print-omitted --filter=blob:limit=500 \
-		| awk -f print_1.awk \
-		| sed "s/~//" \
-		| sort >observed &&
+	git -C r2 rev-list HEAD --objects |
+	awk -f print_1.awk |
+	sort >expected &&
+
+	git -C r2 rev-list HEAD --objects --filter-print-omitted --filter=blob:limit=500 |
+	awk -f print_1.awk |
+	sed "s/~//" |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify blob:limit=1000' '
-	git -C r2 ls-files -s large.1000 large.10000 \
-		| awk -f print_2.awk \
-		| sort >expected &&
-	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1000 \
-		| awk -f print_1.awk \
-		| sed "s/~//" \
-		| sort >observed &&
+	git -C r2 ls-files -s large.1000 large.10000 |
+	awk -f print_2.awk |
+	sort >expected &&
+
+	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1000 |
+	awk -f print_1.awk |
+	sed "s/~//" |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify blob:limit=1001' '
-	git -C r2 ls-files -s large.10000 \
-		| awk -f print_2.awk \
-		| sort >expected &&
-	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1001 \
-		| awk -f print_1.awk \
-		| sed "s/~//" \
-		| sort >observed &&
+	git -C r2 ls-files -s large.10000 |
+	awk -f print_2.awk |
+	sort >expected &&
+
+	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1001 |
+	awk -f print_1.awk |
+	sed "s/~//" |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify blob:limit=1k' '
-	git -C r2 ls-files -s large.10000 \
-		| awk -f print_2.awk \
-		| sort >expected &&
-	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1k \
-		| awk -f print_1.awk \
-		| sed "s/~//" \
-		| sort >observed &&
+	git -C r2 ls-files -s large.10000 |
+	awk -f print_2.awk |
+	sort >expected &&
+
+	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1k |
+	awk -f print_1.awk |
+	sed "s/~//" |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify blob:limit=1m' '
-	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1m \
-		| awk -f print_1.awk \
-		| sed "s/~//" \
-		| sort >observed &&
+	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1m |
+	awk -f print_1.awk |
+	sed "s/~//" |
+	sort >observed &&
+
 	test_must_be_empty observed
 '
 
@@ -141,24 +156,28 @@ test_expect_success 'setup r3' '
 '
 
 test_expect_success 'verify sparse:path=pattern1 omits top-level files' '
-	git -C r3 ls-files -s sparse1 sparse2 \
-		| awk -f print_2.awk \
-		| sort >expected &&
-	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:path=../pattern1 \
-		| awk -f print_1.awk \
-		| sed "s/~//" \
-		| sort >observed &&
+	git -C r3 ls-files -s sparse1 sparse2 |
+	awk -f print_2.awk |
+	sort >expected &&
+
+	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:path=../pattern1 |
+	awk -f print_1.awk |
+	sed "s/~//" |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify sparse:path=pattern2 omits both sparse2 files' '
-	git -C r3 ls-files -s sparse2 dir1/sparse2 \
-		| awk -f print_2.awk \
-		| sort >expected &&
-	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:path=../pattern2 \
-		| awk -f print_1.awk \
-		| sed "s/~//" \
-		| sort >observed &&
+	git -C r3 ls-files -s sparse2 dir1/sparse2 |
+	awk -f print_2.awk |
+	sort >expected &&
+
+	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:path=../pattern2 |
+	awk -f print_1.awk |
+	sed "s/~//" |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
@@ -173,25 +192,30 @@ test_expect_success 'setup r3 part 2' '
 '
 
 test_expect_success 'verify sparse:oid=OID omits top-level files' '
-	git -C r3 ls-files -s pattern sparse1 sparse2 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r3 ls-files -s pattern sparse1 sparse2 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	oid=$(git -C r3 ls-files -s pattern | awk -f print_2.awk) &&
-	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:oid=$oid \
-		| awk -f print_1.awk \
-		| sed "s/~//" \
-		| sort >observed &&
+
+	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:oid=$oid |
+	awk -f print_1.awk |
+	sed "s/~//" |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
 test_expect_success 'verify sparse:oid=oid-ish omits top-level files' '
-	git -C r3 ls-files -s pattern sparse1 sparse2 \
-		| awk -f print_2.awk \
-		| sort >expected &&
-	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:oid=master:pattern \
-		| awk -f print_1.awk \
-		| sed "s/~//" \
-		| sort >observed &&
+	git -C r3 ls-files -s pattern sparse1 sparse2 |
+	awk -f print_2.awk |
+	sort >expected &&
+
+	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:oid=master:pattern |
+	awk -f print_1.awk |
+	sed "s/~//" |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
@@ -199,17 +223,20 @@ test_expect_success 'verify sparse:oid=oid-ish omits top-level files' '
 # This models previously omitted objects that we did not receive.
 
 test_expect_success 'rev-list W/ --missing=print' '
-	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 \
-		| awk -f print_2.awk \
-		| sort >expected &&
+	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 |
+	awk -f print_2.awk |
+	sort >expected &&
+
 	for id in `cat expected | sed "s|..|&/|"`
 	do
 		rm r1/.git/objects/$id
 	done &&
-	git -C r1 rev-list --quiet HEAD --missing=print --objects \
-		| awk -f print_1.awk \
-		| sed "s/?//" \
-		| sort >observed &&
+
+	git -C r1 rev-list --quiet HEAD --missing=print --objects |
+	awk -f print_1.awk |
+	sed "s/?//" |
+	sort >observed &&
+
 	test_cmp observed expected
 '
 
-- 
2.19.0.605.g01d371f741-goog


^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [PATCH v5 4/7] t/*: fix ordering of expected/observed arguments
  2018-10-05 21:54 ` [PATCH v5 0/7] subject: Clean up tests for test_cmp arg ordering and pipe placement Matthew DeVore
                     ` (2 preceding siblings ...)
  2018-10-05 21:54   ` [PATCH v5 3/7] tests: standardize pipe placement Matthew DeVore
@ 2018-10-05 21:54   ` Matthew DeVore
  2018-10-05 21:54   ` [PATCH v5 5/7] tests: don't swallow Git errors upstream of pipes Matthew DeVore
                     ` (3 subsequent siblings)
  7 siblings, 0 replies; 66+ messages in thread
From: Matthew DeVore @ 2018-10-05 21:54 UTC (permalink / raw)
  To: git; +Cc: Matthew DeVore, peff, jonathantanmy, gitster, jrn, sunshine,
	szeder.dev

Fix various places where the ordering was obviously wrong, meaning it
was easy to find with grep.

Signed-off-by: Matthew DeVore <matvore@google.com>
---
 t/t0000-basic.sh                       |  2 +-
 t/t0021-conversion.sh                  |  4 +--
 t/t1300-config.sh                      |  4 +--
 t/t1303-wacky-config.sh                |  4 +--
 t/t2101-update-index-reupdate.sh       |  2 +-
 t/t3200-branch.sh                      |  2 +-
 t/t3320-notes-merge-worktrees.sh       |  4 +--
 t/t3400-rebase.sh                      |  8 +++---
 t/t3417-rebase-whitespace-fix.sh       |  6 ++---
 t/t3702-add-edit.sh                    |  4 +--
 t/t3903-stash.sh                       |  8 +++---
 t/t3905-stash-include-untracked.sh     |  2 +-
 t/t4025-hunk-header.sh                 |  2 +-
 t/t4117-apply-reject.sh                |  6 ++---
 t/t4124-apply-ws-rule.sh               | 30 +++++++++++------------
 t/t4138-apply-ws-expansion.sh          |  2 +-
 t/t5317-pack-objects-filter-objects.sh | 34 +++++++++++++-------------
 t/t5318-commit-graph.sh                |  2 +-
 t/t5701-git-serve.sh                   | 14 +++++------
 t/t5702-protocol-v2.sh                 | 10 ++++----
 t/t6023-merge-file.sh                  | 12 ++++-----
 t/t6027-merge-binary.sh                |  4 +--
 t/t6031-merge-filemode.sh              |  2 +-
 t/t6112-rev-list-filters-objects.sh    | 24 +++++++++---------
 t/t7201-co.sh                          |  4 +--
 t/t7406-submodule-update.sh            |  8 +++---
 t/t7800-difftool.sh                    |  2 +-
 t/t9100-git-svn-basic.sh               |  2 +-
 t/t9133-git-svn-nested-git-repo.sh     |  6 ++---
 t/t9600-cvsimport.sh                   |  2 +-
 t/t9603-cvsimport-patchsets.sh         |  4 +--
 t/t9604-cvsimport-timestamps.sh        |  4 +--
 32 files changed, 112 insertions(+), 112 deletions(-)

diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh
index 850f651e4..224c098a8 100755
--- a/t/t0000-basic.sh
+++ b/t/t0000-basic.sh
@@ -1018,7 +1018,7 @@ test_expect_success SHA1 'validate git diff-files output for a know cache/work t
 :120000 120000 6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c 0000000000000000000000000000000000000000 M	path3/subp3/file3sym
 EOF
 	git diff-files >current &&
-	test_cmp current expected
+	test_cmp expected current
 '
 
 test_expect_success 'git update-index --refresh should succeed' '
diff --git a/t/t0021-conversion.sh b/t/t0021-conversion.sh
index 308cd28f3..fd5f1ac64 100755
--- a/t/t0021-conversion.sh
+++ b/t/t0021-conversion.sh
@@ -166,10 +166,10 @@ test_expect_success expanded_in_repo '
 	rm -f expanded-keywords expanded-keywords-crlf &&
 
 	git checkout -- expanded-keywords &&
-	test_cmp expanded-keywords expected-output &&
+	test_cmp expected-output expanded-keywords &&
 
 	git checkout -- expanded-keywords-crlf &&
-	test_cmp expanded-keywords-crlf expected-output-crlf
+	test_cmp expected-output-crlf expanded-keywords-crlf
 '
 
 # The use of %f in a filter definition is expanded to the path to
diff --git a/t/t1300-config.sh b/t/t1300-config.sh
index 5869d6cb6..e2cd50ecf 100755
--- a/t/t1300-config.sh
+++ b/t/t1300-config.sh
@@ -1001,7 +1001,7 @@ EOF
 
 test_expect_success 'value continued on next line' '
 	git config --list > result &&
-	test_cmp result expect
+	test_cmp expect result
 '
 
 cat > .git/config <<\EOF
@@ -1882,7 +1882,7 @@ test_expect_success '--replace-all does not invent newlines' '
 	Qkey = b
 	EOF
 	git config --replace-all abc.key b &&
-	test_cmp .git/config expect
+	test_cmp expect .git/config
 '
 
 test_done
diff --git a/t/t1303-wacky-config.sh b/t/t1303-wacky-config.sh
index 3b92083e1..0000e664e 100755
--- a/t/t1303-wacky-config.sh
+++ b/t/t1303-wacky-config.sh
@@ -14,7 +14,7 @@ setup() {
 check() {
 	echo "$2" >expected
 	git config --get "$1" >actual 2>&1
-	test_cmp actual expected
+	test_cmp expected actual
 }
 
 # 'check section.key regex value' verifies that the entry for
@@ -22,7 +22,7 @@ check() {
 check_regex() {
 	echo "$3" >expected
 	git config --get "$1" "$2" >actual 2>&1
-	test_cmp actual expected
+	test_cmp expected actual
 }
 
 test_expect_success 'modify same key' '
diff --git a/t/t2101-update-index-reupdate.sh b/t/t2101-update-index-reupdate.sh
index 685ec4563..6c32d42c8 100755
--- a/t/t2101-update-index-reupdate.sh
+++ b/t/t2101-update-index-reupdate.sh
@@ -73,7 +73,7 @@ test_expect_success 'update-index --update from subdir' '
 	100644 $(git hash-object dir1/file3) 0	dir1/file3
 	100644 $file2 0	file2
 	EOF
-	test_cmp current expected
+	test_cmp expected current
 '
 
 test_expect_success 'update-index --update with pathspec' '
diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index 93f21ab07..478b82cf9 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -1221,7 +1221,7 @@ test_expect_success 'use --edit-description' '
 	EOF
 	EDITOR=./editor git branch --edit-description &&
 	echo "New contents" >expect &&
-	test_cmp EDITOR_OUTPUT expect
+	test_cmp expect EDITOR_OUTPUT
 '
 
 test_expect_success 'detect typo in branch name when using --edit-description' '
diff --git a/t/t3320-notes-merge-worktrees.sh b/t/t3320-notes-merge-worktrees.sh
index 10bfc8b94..823fdbda1 100755
--- a/t/t3320-notes-merge-worktrees.sh
+++ b/t/t3320-notes-merge-worktrees.sh
@@ -44,7 +44,7 @@ test_expect_success 'merge z into y fails and sets NOTES_MERGE_REF' '
 	git config core.notesRef refs/notes/y &&
 	test_must_fail git notes merge z &&
 	echo "ref: refs/notes/y" >expect &&
-	test_cmp .git/NOTES_MERGE_REF expect
+	test_cmp expect .git/NOTES_MERGE_REF
 '
 
 test_expect_success 'merge z into y while mid-merge in another workdir fails' '
@@ -66,7 +66,7 @@ test_expect_success 'merge z into x while mid-merge on y succeeds' '
 		grep -v "A notes merge into refs/notes/x is already in-progress in" out
 	) &&
 	echo "ref: refs/notes/x" >expect &&
-	test_cmp .git/worktrees/worktree2/NOTES_MERGE_REF expect
+	test_cmp expect .git/worktrees/worktree2/NOTES_MERGE_REF
 '
 
 test_done
diff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh
index 3996ee013..3e73f7584 100755
--- a/t/t3400-rebase.sh
+++ b/t/t3400-rebase.sh
@@ -183,13 +183,13 @@ test_expect_success 'cherry-picked commits and fork-point work together' '
 	test_commit final_B B "Final B" &&
 	git rebase &&
 	echo Amended >expect &&
-	test_cmp A expect &&
+	test_cmp expect A &&
 	echo "Final B" >expect &&
-	test_cmp B expect &&
+	test_cmp expect B &&
 	echo C >expect &&
-	test_cmp C expect &&
+	test_cmp expect C &&
 	echo D >expect &&
-	test_cmp D expect
+	test_cmp expect D
 '
 
 test_expect_success 'rebase -q is quiet' '
diff --git a/t/t3417-rebase-whitespace-fix.sh b/t/t3417-rebase-whitespace-fix.sh
index 1fb3e499b..e85cdc703 100755
--- a/t/t3417-rebase-whitespace-fix.sh
+++ b/t/t3417-rebase-whitespace-fix.sh
@@ -55,7 +55,7 @@ test_expect_success 'blank line at end of file; extend at end of file' '
 	git add file &&	git commit -m second &&
 	git rebase --whitespace=fix HEAD^^ &&
 	git diff --exit-code HEAD^:file expect-first &&
-	test_cmp file expect-second
+	test_cmp expect-second file
 '
 
 # prepare third revision of "file"
@@ -82,7 +82,7 @@ test_expect_success 'two blanks line at end of file; extend at end of file' '
 	cp third file && git add file && git commit -m third &&
 	git rebase --whitespace=fix HEAD^^ &&
 	git diff --exit-code HEAD^:file expect-second &&
-	test_cmp file expect-third
+	test_cmp expect-third file
 '
 
 test_expect_success 'same, but do not remove trailing spaces' '
@@ -120,7 +120,7 @@ test_expect_success 'at beginning of file' '
 	done >> file &&
 	git commit -m more file	&&
 	git rebase --whitespace=fix HEAD^^ &&
-	test_cmp file expect-beginning
+	test_cmp expect-beginning file
 '
 
 test_done
diff --git a/t/t3702-add-edit.sh b/t/t3702-add-edit.sh
index c6af7f82b..6c676645d 100755
--- a/t/t3702-add-edit.sh
+++ b/t/t3702-add-edit.sh
@@ -110,10 +110,10 @@ test_expect_success 'add -e' '
 	cp second-part file &&
 	git add -e &&
 	test_cmp second-part file &&
-	test_cmp orig-patch expected-patch &&
+	test_cmp expected-patch orig-patch &&
 	git diff --cached >actual &&
 	grep -v index actual >out &&
-	test_cmp out expected
+	test_cmp expected out
 
 '
 
diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh
index 6450bc669..cd216655b 100755
--- a/t/t3903-stash.sh
+++ b/t/t3903-stash.sh
@@ -36,7 +36,7 @@ EOF
 test_expect_success 'parents of stash' '
 	test $(git rev-parse stash^) = $(git rev-parse HEAD) &&
 	git diff stash^2..stash > output &&
-	test_cmp output expect
+	test_cmp expect output
 '
 
 test_expect_success 'applying bogus stash does nothing' '
@@ -210,9 +210,9 @@ test_expect_success 'stash branch' '
 	test refs/heads/stashbranch = $(git symbolic-ref HEAD) &&
 	test $(git rev-parse HEAD) = $(git rev-parse master^) &&
 	git diff --cached > output &&
-	test_cmp output expect &&
+	test_cmp expect output &&
 	git diff > output &&
-	test_cmp output expect1 &&
+	test_cmp expect1 output &&
 	git add file &&
 	git commit -m alternate\ second &&
 	git diff master..stashbranch > output &&
@@ -710,7 +710,7 @@ test_expect_success 'stash where working directory contains "HEAD" file' '
 	git diff-index --cached --quiet HEAD &&
 	test "$(git rev-parse stash^)" = "$(git rev-parse HEAD)" &&
 	git diff stash^..stash > output &&
-	test_cmp output expect
+	test_cmp expect output
 '
 
 test_expect_success 'store called with invalid commit' '
diff --git a/t/t3905-stash-include-untracked.sh b/t/t3905-stash-include-untracked.sh
index 597b0637d..cc1c8a7bb 100755
--- a/t/t3905-stash-include-untracked.sh
+++ b/t/t3905-stash-include-untracked.sh
@@ -142,7 +142,7 @@ test_expect_success 'stash save --include-untracked removed files' '
 	rm -f file &&
 	git stash save --include-untracked &&
 	echo 1 > expect &&
-	test_cmp file expect
+	test_cmp expect file
 '
 
 rm -f expect
diff --git a/t/t4025-hunk-header.sh b/t/t4025-hunk-header.sh
index fa44e7886..35578f2bb 100755
--- a/t/t4025-hunk-header.sh
+++ b/t/t4025-hunk-header.sh
@@ -37,7 +37,7 @@ test_expect_success 'hunk header truncation with an overly long line' '
 		echo " A $N$N$N$N$N$N$N$N$N2" &&
 		echo " L  $N$N$N$N$N$N$N$N$N1"
 	) >expected &&
-	test_cmp actual expected
+	test_cmp expected actual
 
 '
 
diff --git a/t/t4117-apply-reject.sh b/t/t4117-apply-reject.sh
index d80187de9..f7de6f077 100755
--- a/t/t4117-apply-reject.sh
+++ b/t/t4117-apply-reject.sh
@@ -72,7 +72,7 @@ test_expect_success 'apply with --reject should fail but update the file' '
 	rm -f file1.rej file2.rej &&
 
 	test_must_fail git apply --reject patch.1 &&
-	test_cmp file1 expected &&
+	test_cmp expected file1 &&
 
 	cat file1.rej &&
 	test_path_is_missing file2.rej
@@ -85,7 +85,7 @@ test_expect_success 'apply with --reject should fail but update the file' '
 
 	test_must_fail git apply --reject patch.2 >rejects &&
 	test_path_is_missing file1 &&
-	test_cmp file2 expected &&
+	test_cmp expected file2 &&
 
 	cat file2.rej &&
 	test_path_is_missing file1.rej
@@ -99,7 +99,7 @@ test_expect_success 'the same test with --verbose' '
 
 	test_must_fail git apply --reject --verbose patch.2 >rejects &&
 	test_path_is_missing file1 &&
-	test_cmp file2 expected &&
+	test_cmp expected file2 &&
 
 	cat file2.rej &&
 	test_path_is_missing file1.rej
diff --git a/t/t4124-apply-ws-rule.sh b/t/t4124-apply-ws-rule.sh
index 7e32237a2..ff51e9e78 100755
--- a/t/t4124-apply-ws-rule.sh
+++ b/t/t4124-apply-ws-rule.sh
@@ -313,9 +313,9 @@ test_expect_success 'applying beyond EOF requires one non-blank context line' '
 	{ echo a; echo; } >one &&
 	cp one expect &&
 	test_must_fail git apply --whitespace=fix patch &&
-	test_cmp one expect &&
+	test_cmp expect one &&
 	test_must_fail git apply --ignore-space-change --whitespace=fix patch &&
-	test_cmp one expect
+	test_cmp expect one
 '
 
 test_expect_success 'tons of blanks at EOF should not apply' '
@@ -342,10 +342,10 @@ test_expect_success 'missing blank line at end with --whitespace=fix' '
 	cp one saved-one &&
 	test_must_fail git apply patch &&
 	git apply --whitespace=fix patch &&
-	test_cmp one expect &&
+	test_cmp expect one &&
 	mv saved-one one &&
 	git apply --ignore-space-change --whitespace=fix patch &&
-	test_cmp one expect
+	test_cmp expect one
 '
 
 test_expect_success 'two missing blank lines at end with --whitespace=fix' '
@@ -360,11 +360,11 @@ test_expect_success 'two missing blank lines at end with --whitespace=fix' '
 	cp no-blank-lines one &&
 	test_must_fail git apply patch &&
 	git apply --whitespace=fix patch &&
-	test_cmp one expect &&
+	test_cmp expect one &&
 	mv no-blank-lines one &&
 	test_must_fail git apply patch &&
 	git apply --ignore-space-change --whitespace=fix patch &&
-	test_cmp one expect
+	test_cmp expect one
 '
 
 test_expect_success 'missing blank line at end, insert before end, --whitespace=fix' '
@@ -376,7 +376,7 @@ test_expect_success 'missing blank line at end, insert before end, --whitespace=
 	echo a >one &&
 	test_must_fail git apply patch &&
 	git apply --whitespace=fix patch &&
-	test_cmp one expect
+	test_cmp expect one
 '
 
 test_expect_success 'shrink file with tons of missing blanks at end of file' '
@@ -392,10 +392,10 @@ test_expect_success 'shrink file with tons of missing blanks at end of file' '
 	cp no-blank-lines one &&
 	test_must_fail git apply patch &&
 	git apply --whitespace=fix patch &&
-	test_cmp one expect &&
+	test_cmp expect one &&
 	mv no-blank-lines one &&
 	git apply --ignore-space-change --whitespace=fix patch &&
-	test_cmp one expect
+	test_cmp expect one
 '
 
 test_expect_success 'missing blanks at EOF must only match blank lines' '
@@ -427,7 +427,7 @@ test_expect_success 'missing blank line should match context line with spaces' '
 	git add one &&
 
 	git apply --whitespace=fix patch &&
-	test_cmp one expect
+	test_cmp expect one
 '
 
 sed -e's/Z//' >one <<EOF
@@ -447,7 +447,7 @@ test_expect_success 'same, but with the --ignore-space-option' '
 
 	git checkout-index -f one &&
 	git apply --ignore-space-change --whitespace=fix patch &&
-	test_cmp one expect
+	test_cmp expect one
 '
 
 test_expect_success 'same, but with CR-LF line endings && cr-at-eol set' '
@@ -464,7 +464,7 @@ test_expect_success 'same, but with CR-LF line endings && cr-at-eol set' '
 	mv save-one one &&
 
 	git apply --ignore-space-change --whitespace=fix patch &&
-	test_cmp one expect
+	test_cmp expect one
 '
 
 test_expect_success 'CR-LF line endings && add line && text=auto' '
@@ -478,7 +478,7 @@ test_expect_success 'CR-LF line endings && add line && text=auto' '
 	mv save-one one &&
 	echo "one text=auto" >.gitattributes &&
 	git apply patch &&
-	test_cmp one expect
+	test_cmp expect one
 '
 
 test_expect_success 'CR-LF line endings && change line && text=auto' '
@@ -491,7 +491,7 @@ test_expect_success 'CR-LF line endings && change line && text=auto' '
 	mv save-one one &&
 	echo "one text=auto" >.gitattributes &&
 	git apply patch &&
-	test_cmp one expect
+	test_cmp expect one
 '
 
 test_expect_success 'LF in repo, CRLF in worktree && change line && text=auto' '
@@ -503,7 +503,7 @@ test_expect_success 'LF in repo, CRLF in worktree && change line && text=auto' '
 	echo "one text=auto" >.gitattributes &&
 	git -c core.eol=CRLF apply patch &&
 	printf "b\r\n" >expect &&
-	test_cmp one expect
+	test_cmp expect one
 '
 
 test_expect_success 'whitespace=fix to expand' '
diff --git a/t/t4138-apply-ws-expansion.sh b/t/t4138-apply-ws-expansion.sh
index 0ffe33fbe..3b636a63a 100755
--- a/t/t4138-apply-ws-expansion.sh
+++ b/t/t4138-apply-ws-expansion.sh
@@ -114,7 +114,7 @@ for t in 1 2 3 4
 do
 	test_expect_success 'apply with ws expansion (t=$t)' '
 		git apply patch$t.patch &&
-		test_cmp test-$t expect-$t
+		test_cmp expect-$t test-$t
 	'
 done
 
diff --git a/t/t5317-pack-objects-filter-objects.sh b/t/t5317-pack-objects-filter-objects.sh
index ce69148ec..c093eb891 100755
--- a/t/t5317-pack-objects-filter-objects.sh
+++ b/t/t5317-pack-objects-filter-objects.sh
@@ -34,7 +34,7 @@ test_expect_success 'verify blob count in normal packfile' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify blob:none packfile has no blobs' '
@@ -63,7 +63,7 @@ test_expect_success 'verify normal and blob:none packfiles have same commits/tre
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 # Test blob:limit=<n>[kmg] filter.
@@ -96,7 +96,7 @@ test_expect_success 'verify blob count in normal packfile' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify blob:limit=500 omits all blobs' '
@@ -144,7 +144,7 @@ test_expect_success 'verify blob:limit=1001' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify blob:limit=10001' '
@@ -162,7 +162,7 @@ test_expect_success 'verify blob:limit=10001' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify blob:limit=1k' '
@@ -180,7 +180,7 @@ test_expect_success 'verify blob:limit=1k' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify explicitly specifying oversized blob in input' '
@@ -199,7 +199,7 @@ test_expect_success 'verify explicitly specifying oversized blob in input' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify blob:limit=1m' '
@@ -217,7 +217,7 @@ test_expect_success 'verify blob:limit=1m' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify normal and blob:limit packfiles have same commits/trees' '
@@ -231,7 +231,7 @@ test_expect_success 'verify normal and blob:limit packfiles have same commits/tr
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 # Test sparse:path=<path> filter.
@@ -269,7 +269,7 @@ test_expect_success 'verify blob count in normal packfile' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify sparse:path=pattern1' '
@@ -287,7 +287,7 @@ test_expect_success 'verify sparse:path=pattern1' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify normal and sparse:path=pattern1 packfiles have same commits/trees' '
@@ -301,7 +301,7 @@ test_expect_success 'verify normal and sparse:path=pattern1 packfiles have same
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify sparse:path=pattern2' '
@@ -319,7 +319,7 @@ test_expect_success 'verify sparse:path=pattern2' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify normal and sparse:path=pattern2 packfiles have same commits/trees' '
@@ -333,7 +333,7 @@ test_expect_success 'verify normal and sparse:path=pattern2 packfiles have same
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 # Test sparse:oid=<oid-ish> filter.
@@ -370,7 +370,7 @@ test_expect_success 'verify blob count in normal packfile' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify sparse:oid=OID' '
@@ -389,7 +389,7 @@ test_expect_success 'verify sparse:oid=OID' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify sparse:oid=oid-ish' '
@@ -407,7 +407,7 @@ test_expect_success 'verify sparse:oid=oid-ish' '
 	awk -f print_1.awk |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 # Delete some loose objects and use pack-objects, but WITHOUT any filtering.
diff --git a/t/t5318-commit-graph.sh b/t/t5318-commit-graph.sh
index 0c500f7ca..d6da3ce4e 100755
--- a/t/t5318-commit-graph.sh
+++ b/t/t5318-commit-graph.sh
@@ -35,7 +35,7 @@ test_expect_success 'create commits and repack' '
 graph_git_two_modes() {
 	git -c core.commitGraph=true $1 >output
 	git -c core.commitGraph=false $1 >expect
-	test_cmp output expect
+	test_cmp expect output
 }
 
 graph_git_behavior() {
diff --git a/t/t5701-git-serve.sh b/t/t5701-git-serve.sh
index 75ec79e6c..bf139e245 100755
--- a/t/t5701-git-serve.sh
+++ b/t/t5701-git-serve.sh
@@ -16,7 +16,7 @@ test_expect_success 'test capability advertisement' '
 
 	git serve --advertise-capabilities >out &&
 	test-pkt-line unpack <out >actual &&
-	test_cmp actual expect
+	test_cmp expect actual
 '
 
 test_expect_success 'stateless-rpc flag does not list capabilities' '
@@ -89,7 +89,7 @@ test_expect_success 'basics of ls-refs' '
 
 	git serve --stateless-rpc <in >out &&
 	test-pkt-line unpack <out >actual &&
-	test_cmp actual expect
+	test_cmp expect actual
 '
 
 test_expect_success 'basic ref-prefixes' '
@@ -109,7 +109,7 @@ test_expect_success 'basic ref-prefixes' '
 
 	git serve --stateless-rpc <in >out &&
 	test-pkt-line unpack <out >actual &&
-	test_cmp actual expect
+	test_cmp expect actual
 '
 
 test_expect_success 'refs/heads prefix' '
@@ -129,7 +129,7 @@ test_expect_success 'refs/heads prefix' '
 
 	git serve --stateless-rpc <in >out &&
 	test-pkt-line unpack <out >actual &&
-	test_cmp actual expect
+	test_cmp expect actual
 '
 
 test_expect_success 'peel parameter' '
@@ -150,7 +150,7 @@ test_expect_success 'peel parameter' '
 
 	git serve --stateless-rpc <in >out &&
 	test-pkt-line unpack <out >actual &&
-	test_cmp actual expect
+	test_cmp expect actual
 '
 
 test_expect_success 'symrefs parameter' '
@@ -171,7 +171,7 @@ test_expect_success 'symrefs parameter' '
 
 	git serve --stateless-rpc <in >out &&
 	test-pkt-line unpack <out >actual &&
-	test_cmp actual expect
+	test_cmp expect actual
 '
 
 test_expect_success 'sending server-options' '
@@ -191,7 +191,7 @@ test_expect_success 'sending server-options' '
 
 	git serve --stateless-rpc <in >out &&
 	test-pkt-line unpack <out >actual &&
-	test_cmp actual expect
+	test_cmp expect actual
 '
 
 test_expect_success 'unexpected lines are not allowed in fetch request' '
diff --git a/t/t5702-protocol-v2.sh b/t/t5702-protocol-v2.sh
index 3beeed454..54727450b 100755
--- a/t/t5702-protocol-v2.sh
+++ b/t/t5702-protocol-v2.sh
@@ -29,7 +29,7 @@ test_expect_success 'list refs with git:// using protocol v2' '
 	grep "git< version 2" log &&
 
 	git ls-remote --symref "$GIT_DAEMON_URL/parent" >expect &&
-	test_cmp actual expect
+	test_cmp expect actual
 '
 
 test_expect_success 'ref advertisment is filtered with ls-remote using protocol v2' '
@@ -42,7 +42,7 @@ test_expect_success 'ref advertisment is filtered with ls-remote using protocol
 	$(git -C "$daemon_parent" rev-parse refs/heads/master)$(printf "\t")refs/heads/master
 	EOF
 
-	test_cmp actual expect
+	test_cmp expect actual
 '
 
 test_expect_success 'clone with git:// using protocol v2' '
@@ -138,7 +138,7 @@ test_expect_success 'list refs with file:// using protocol v2' '
 	grep "git< version 2" log &&
 
 	git ls-remote --symref "file://$(pwd)/file_parent" >expect &&
-	test_cmp actual expect
+	test_cmp expect actual
 '
 
 test_expect_success 'ref advertisment is filtered with ls-remote using protocol v2' '
@@ -151,7 +151,7 @@ test_expect_success 'ref advertisment is filtered with ls-remote using protocol
 	$(git -C file_parent rev-parse refs/heads/master)$(printf "\t")refs/heads/master
 	EOF
 
-	test_cmp actual expect
+	test_cmp expect actual
 '
 
 test_expect_success 'server-options are sent when using ls-remote' '
@@ -164,7 +164,7 @@ test_expect_success 'server-options are sent when using ls-remote' '
 	$(git -C file_parent rev-parse refs/heads/master)$(printf "\t")refs/heads/master
 	EOF
 
-	test_cmp actual expect &&
+	test_cmp expect actual &&
 	grep "server-option=hello" log &&
 	grep "server-option=world" log
 '
diff --git a/t/t6023-merge-file.sh b/t/t6023-merge-file.sh
index 20aee43f9..51ee887a7 100755
--- a/t/t6023-merge-file.sh
+++ b/t/t6023-merge-file.sh
@@ -99,7 +99,7 @@ EOF
 printf "propter nomen suum." >> expect.txt
 
 test_expect_success "merge does not add LF away of change" \
-	"test_cmp test3.txt expect.txt"
+	"test_cmp expect.txt test3.txt"
 
 cp test.txt backup.txt
 test_expect_success "merge with conflicts" \
@@ -122,7 +122,7 @@ non timebo mala, quoniam tu mecum es:
 virga tua et baculus tuus ipsa me consolata sunt.
 EOF
 
-test_expect_success "expected conflict markers" "test_cmp test.txt expect.txt"
+test_expect_success "expected conflict markers" "test_cmp expect.txt test.txt"
 
 cp backup.txt test.txt
 
@@ -138,7 +138,7 @@ non timebo mala, quoniam tu mecum es:
 virga tua et baculus tuus ipsa me consolata sunt.
 EOF
 test_expect_success "merge conflicting with --ours" \
-	"git merge-file --ours test.txt orig.txt new3.txt && test_cmp test.txt expect.txt"
+	"git merge-file --ours test.txt orig.txt new3.txt && test_cmp expect.txt test.txt"
 cp backup.txt test.txt
 
 cat > expect.txt << EOF
@@ -154,7 +154,7 @@ non timebo mala, quoniam tu mecum es:
 virga tua et baculus tuus ipsa me consolata sunt.
 EOF
 test_expect_success "merge conflicting with --theirs" \
-	"git merge-file --theirs test.txt orig.txt new3.txt && test_cmp test.txt expect.txt"
+	"git merge-file --theirs test.txt orig.txt new3.txt && test_cmp expect.txt test.txt"
 cp backup.txt test.txt
 
 cat > expect.txt << EOF
@@ -171,7 +171,7 @@ non timebo mala, quoniam tu mecum es:
 virga tua et baculus tuus ipsa me consolata sunt.
 EOF
 test_expect_success "merge conflicting with --union" \
-	"git merge-file --union test.txt orig.txt new3.txt && test_cmp test.txt expect.txt"
+	"git merge-file --union test.txt orig.txt new3.txt && test_cmp expect.txt test.txt"
 cp backup.txt test.txt
 
 test_expect_success "merge with conflicts, using -L" \
@@ -195,7 +195,7 @@ virga tua et baculus tuus ipsa me consolata sunt.
 EOF
 
 test_expect_success "expected conflict markers, with -L" \
-	"test_cmp test.txt expect.txt"
+	"test_cmp expect.txt test.txt"
 
 sed "s/ tu / TU /" < new1.txt > new5.txt
 test_expect_success "conflict in removed tail" \
diff --git a/t/t6027-merge-binary.sh b/t/t6027-merge-binary.sh
index 07735410b..4e6c7cb77 100755
--- a/t/t6027-merge-binary.sh
+++ b/t/t6027-merge-binary.sh
@@ -45,7 +45,7 @@ test_expect_success resolve '
 		false
 	else
 		git ls-files -s >current
-		test_cmp current expect
+		test_cmp expect current
 	fi
 '
 
@@ -60,7 +60,7 @@ test_expect_success recursive '
 		false
 	else
 		git ls-files -s >current
-		test_cmp current expect
+		test_cmp expect current
 	fi
 '
 
diff --git a/t/t6031-merge-filemode.sh b/t/t6031-merge-filemode.sh
index 7d06461f1..87741efad 100755
--- a/t/t6031-merge-filemode.sh
+++ b/t/t6031-merge-filemode.sh
@@ -61,7 +61,7 @@ do_both_modes () {
 		git checkout -f a2 &&
 		test_must_fail git merge -s $strategy b2 &&
 		git ls-files -u >actual &&
-		test_cmp actual expect &&
+		test_cmp expect actual &&
 		git ls-files -s file2 | grep ^100755
 	'
 
diff --git a/t/t6112-rev-list-filters-objects.sh b/t/t6112-rev-list-filters-objects.sh
index 0f6b569e1..ae4402226 100755
--- a/t/t6112-rev-list-filters-objects.sh
+++ b/t/t6112-rev-list-filters-objects.sh
@@ -29,7 +29,7 @@ test_expect_success 'verify blob:none omits all 5 blobs' '
 	sed "s/~//" |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify emitted+omitted == all' '
@@ -42,7 +42,7 @@ test_expect_success 'verify emitted+omitted == all' '
 	sed "s/~//" |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 
@@ -71,7 +71,7 @@ test_expect_success 'verify blob:limit=500 omits all blobs' '
 	sed "s/~//" |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify emitted+omitted == all' '
@@ -84,7 +84,7 @@ test_expect_success 'verify emitted+omitted == all' '
 	sed "s/~//" |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify blob:limit=1000' '
@@ -97,7 +97,7 @@ test_expect_success 'verify blob:limit=1000' '
 	sed "s/~//" |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify blob:limit=1001' '
@@ -110,7 +110,7 @@ test_expect_success 'verify blob:limit=1001' '
 	sed "s/~//" |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify blob:limit=1k' '
@@ -123,7 +123,7 @@ test_expect_success 'verify blob:limit=1k' '
 	sed "s/~//" |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify blob:limit=1m' '
@@ -165,7 +165,7 @@ test_expect_success 'verify sparse:path=pattern1 omits top-level files' '
 	sed "s/~//" |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify sparse:path=pattern2 omits both sparse2 files' '
@@ -178,7 +178,7 @@ test_expect_success 'verify sparse:path=pattern2 omits both sparse2 files' '
 	sed "s/~//" |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 # Test sparse:oid=<oid-ish> filter.
@@ -203,7 +203,7 @@ test_expect_success 'verify sparse:oid=OID omits top-level files' '
 	sed "s/~//" |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'verify sparse:oid=oid-ish omits top-level files' '
@@ -216,7 +216,7 @@ test_expect_success 'verify sparse:oid=oid-ish omits top-level files' '
 	sed "s/~//" |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 # Delete some loose objects and use rev-list, but WITHOUT any filtering.
@@ -237,7 +237,7 @@ test_expect_success 'rev-list W/ --missing=print' '
 	sed "s/?//" |
 	sort >observed &&
 
-	test_cmp observed expected
+	test_cmp expected observed
 '
 
 test_expect_success 'rev-list W/O --missing fails' '
diff --git a/t/t7201-co.sh b/t/t7201-co.sh
index 324933acf..826987ca8 100755
--- a/t/t7201-co.sh
+++ b/t/t7201-co.sh
@@ -160,7 +160,7 @@ test_expect_success 'checkout -m with merge conflict' '
 	git diff master:one :3:uno |
 	sed -e "1,/^@@/d" -e "/^ /d" -e "s/^-/d/" -e "s/^+/a/" >current &&
 	fill d2 aT d7 aS >expect &&
-	test_cmp current expect &&
+	test_cmp expect current &&
 	git diff --cached two >current &&
 	test_must_be_empty current
 '
@@ -174,7 +174,7 @@ test_expect_success 'format of merge conflict from checkout -m' '
 
 	git ls-files >current &&
 	fill same two two two >expect &&
-	test_cmp current expect &&
+	test_cmp expect current &&
 
 	cat <<-EOF >expect &&
 	<<<<<<< simple
diff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh
index 10dc91620..e87164aa8 100755
--- a/t/t7406-submodule-update.sh
+++ b/t/t7406-submodule-update.sh
@@ -789,7 +789,7 @@ test_expect_success 'submodule add places git-dir in superprojects git-dir' '
 	 (cd .git/modules/deeper/submodule &&
 	  git log > ../../../../actual
 	 ) &&
-	 test_cmp actual expected
+	 test_cmp expected actual
 	)
 '
 
@@ -807,7 +807,7 @@ test_expect_success 'submodule update places git-dir in superprojects git-dir' '
 	 (cd .git/modules/deeper/submodule &&
 	  git log > ../../../../actual
 	 ) &&
-	 test_cmp actual expected
+	 test_cmp expected actual
 	)
 '
 
@@ -827,7 +827,7 @@ test_expect_success 'submodule add places git-dir in superprojects git-dir recur
 	 git add deeper/submodule &&
 	 git commit -m "update submodule" &&
 	 git push origin : &&
-	 test_cmp actual expected
+	 test_cmp expected actual
 	)
 '
 
@@ -874,7 +874,7 @@ test_expect_success 'submodule update places git-dir in superprojects git-dir re
 	 (cd .git/modules/submodule/modules/subsubmodule &&
 	  git log > ../../../../../actual
 	 ) &&
-	 test_cmp actual expected
+	 test_cmp expected actual
 	)
 '
 
diff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh
index 668bbee73..562bd215a 100755
--- a/t/t7800-difftool.sh
+++ b/t/t7800-difftool.sh
@@ -557,7 +557,7 @@ test_expect_success SYMLINKS 'difftool --dir-diff --symlink without unstaged cha
 	EOF
 	git difftool --dir-diff --symlink \
 		--extcmd "./.git/CHECK_SYMLINKS" branch HEAD &&
-	test_cmp actual expect
+	test_cmp expect actual
 '
 
 write_script modify-right-file <<\EOF
diff --git a/t/t9100-git-svn-basic.sh b/t/t9100-git-svn-basic.sh
index 9af607884..2c309a57d 100755
--- a/t/t9100-git-svn-basic.sh
+++ b/t/t9100-git-svn-basic.sh
@@ -221,7 +221,7 @@ tree d667270a1f7b109f5eb3aaea21ede14b56bfdd6e
 tree 8f51f74cf0163afc9ad68a4b1537288c4558b5a4
 EOF
 
-test_expect_success POSIXPERM,SYMLINKS "$name" "test_cmp a expected"
+test_expect_success POSIXPERM,SYMLINKS "$name" "test_cmp expected a"
 
 test_expect_success 'exit if remote refs are ambigious' '
         git config --add svn-remote.svn.fetch \
diff --git a/t/t9133-git-svn-nested-git-repo.sh b/t/t9133-git-svn-nested-git-repo.sh
index f3c30e63b..f89486086 100755
--- a/t/t9133-git-svn-nested-git-repo.sh
+++ b/t/t9133-git-svn-nested-git-repo.sh
@@ -45,7 +45,7 @@ test_expect_success 'update git svn-cloned repo' '
 		git svn rebase &&
 		echo a > expect &&
 		echo b >> expect &&
-		test_cmp a expect &&
+		test_cmp expect a &&
 		rm expect
 	)
 '
@@ -69,7 +69,7 @@ test_expect_success 'update git svn-cloned repo' '
 		git svn rebase &&
 		echo a > expect &&
 		echo b >> expect &&
-		test_cmp a expect &&
+		test_cmp expect a &&
 		rm expect
 	)
 '
@@ -93,7 +93,7 @@ test_expect_success 'update git svn-cloned repo again' '
 		echo a > expect &&
 		echo b >> expect &&
 		echo c >> expect &&
-		test_cmp a expect &&
+		test_cmp expect a &&
 		rm expect
 	)
 '
diff --git a/t/t9600-cvsimport.sh b/t/t9600-cvsimport.sh
index 5dfee07d9..251fdd66c 100755
--- a/t/t9600-cvsimport.sh
+++ b/t/t9600-cvsimport.sh
@@ -148,7 +148,7 @@ test_expect_success PERL 'import from a CVS working tree' '
 		git cvsimport -a -z0 &&
 		echo 1 >expect &&
 		git log -1 --pretty=format:%s%n >actual &&
-		test_cmp actual expect
+		test_cmp expect actual
 	)
 
 '
diff --git a/t/t9603-cvsimport-patchsets.sh b/t/t9603-cvsimport-patchsets.sh
index c4c3c4954..3e64b11ea 100755
--- a/t/t9603-cvsimport-patchsets.sh
+++ b/t/t9603-cvsimport-patchsets.sh
@@ -29,11 +29,11 @@ test_expect_failure PERL 'import with criss cross times on revisions' '
 Rev 3
 Rev 2
 Rev 1" > expect-master &&
-    test_cmp actual-master expect-master &&
+    test_cmp expect-master actual-master &&
 
     echo "Rev 5 Branch A Wed Mar 11 19:09:10 2009 +0000
 Rev 4 Branch A Wed Mar 11 19:03:52 2009 +0000" > expect-A &&
-    test_cmp actual-A expect-A
+    test_cmp expect-A actual-A
 '
 
 test_done
diff --git a/t/t9604-cvsimport-timestamps.sh b/t/t9604-cvsimport-timestamps.sh
index a4b3db24b..2ff4aa932 100755
--- a/t/t9604-cvsimport-timestamps.sh
+++ b/t/t9604-cvsimport-timestamps.sh
@@ -31,7 +31,7 @@ test_expect_success PERL 'check timestamps are UTC (TZ=CST6CDT)' '
 	Rev  2 2005-02-01 00:00:00 +0000
 	Rev  1 2005-01-01 00:00:00 +0000
 	EOF
-	test_cmp actual-1 expect-1
+	test_cmp expect-1 actual-1
 '
 
 test_expect_success PERL 'check timestamps with author-specific timezones' '
@@ -65,7 +65,7 @@ test_expect_success PERL 'check timestamps with author-specific timezones' '
 	Rev  2 2005-01-31 18:00:00 -0600 User Two
 	Rev  1 2005-01-01 00:00:00 +0000 User One
 	EOF
-	test_cmp actual-2 expect-2
+	test_cmp expect-2 actual-2
 '
 
 test_done
-- 
2.19.0.605.g01d371f741-goog


^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [PATCH v5 5/7] tests: don't swallow Git errors upstream of pipes
  2018-10-05 21:54 ` [PATCH v5 0/7] subject: Clean up tests for test_cmp arg ordering and pipe placement Matthew DeVore
                     ` (3 preceding siblings ...)
  2018-10-05 21:54   ` [PATCH v5 4/7] t/*: fix ordering of expected/observed arguments Matthew DeVore
@ 2018-10-05 21:54   ` Matthew DeVore
  2018-10-05 21:54   ` [PATCH v5 6/7] t9109: " Matthew DeVore
                     ` (2 subsequent siblings)
  7 siblings, 0 replies; 66+ messages in thread
From: Matthew DeVore @ 2018-10-05 21:54 UTC (permalink / raw)
  To: git; +Cc: Matthew DeVore, peff, jonathantanmy, gitster, jrn, sunshine,
	szeder.dev

Some pipes in tests lose the exit code of git processes, which can mask
unexpected behavior like crashes. Split these pipes up so that git
commands are only at the end of pipes rather than the beginning or
middle.

The violations fixed in this patch were found in the process of fixing
pipe placement in a prior patch.

Signed-off-by: Matthew DeVore <matvore@google.com>
---
 t/t5317-pack-objects-filter-objects.sh | 156 +++++++++++++------------
 t/t5616-partial-clone.sh               |  14 ++-
 t/t6112-rev-list-filters-objects.sh    | 103 ++++++++--------
 3 files changed, 141 insertions(+), 132 deletions(-)

diff --git a/t/t5317-pack-objects-filter-objects.sh b/t/t5317-pack-objects-filter-objects.sh
index c093eb891..2e718f0bd 100755
--- a/t/t5317-pack-objects-filter-objects.sh
+++ b/t/t5317-pack-objects-filter-objects.sh
@@ -20,8 +20,9 @@ test_expect_success 'setup r1' '
 '
 
 test_expect_success 'verify blob count in normal packfile' '
-	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 |
-	awk -f print_2.awk |
+	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 \
+		>ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	git -C r1 pack-objects --rev --stdout >all.pack <<-EOF &&
@@ -29,8 +30,8 @@ test_expect_success 'verify blob count in normal packfile' '
 	EOF
 	git -C r1 index-pack ../all.pack &&
 
-	git -C r1 verify-pack -v ../all.pack |
-	grep blob |
+	git -C r1 verify-pack -v ../all.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -43,8 +44,8 @@ test_expect_success 'verify blob:none packfile has no blobs' '
 	EOF
 	git -C r1 index-pack ../filter.pack &&
 
-	git -C r1 verify-pack -v ../filter.pack |
-	grep blob |
+	git -C r1 verify-pack -v ../filter.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -53,13 +54,13 @@ test_expect_success 'verify blob:none packfile has no blobs' '
 '
 
 test_expect_success 'verify normal and blob:none packfiles have same commits/trees' '
-	git -C r1 verify-pack -v ../all.pack |
-	grep -E "commit|tree" |
+	git -C r1 verify-pack -v ../all.pack >verify_result &&
+	grep -E "commit|tree" verify_result |
 	awk -f print_1.awk |
 	sort >expected &&
 
-	git -C r1 verify-pack -v ../filter.pack |
-	grep -E "commit|tree" |
+	git -C r1 verify-pack -v ../filter.pack >verify_result &&
+	grep -E "commit|tree" verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -82,8 +83,8 @@ test_expect_success 'setup r2' '
 '
 
 test_expect_success 'verify blob count in normal packfile' '
-	git -C r2 ls-files -s large.1000 large.10000 |
-	awk -f print_2.awk |
+	git -C r2 ls-files -s large.1000 large.10000 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	git -C r2 pack-objects --rev --stdout >all.pack <<-EOF &&
@@ -91,8 +92,8 @@ test_expect_success 'verify blob count in normal packfile' '
 	EOF
 	git -C r2 index-pack ../all.pack &&
 
-	git -C r2 verify-pack -v ../all.pack |
-	grep blob |
+	git -C r2 verify-pack -v ../all.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -105,8 +106,8 @@ test_expect_success 'verify blob:limit=500 omits all blobs' '
 	EOF
 	git -C r2 index-pack ../filter.pack &&
 
-	git -C r2 verify-pack -v ../filter.pack |
-	grep blob |
+	git -C r2 verify-pack -v ../filter.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -120,8 +121,8 @@ test_expect_success 'verify blob:limit=1000' '
 	EOF
 	git -C r2 index-pack ../filter.pack &&
 
-	git -C r2 verify-pack -v ../filter.pack |
-	grep blob |
+	git -C r2 verify-pack -v ../filter.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -130,8 +131,8 @@ test_expect_success 'verify blob:limit=1000' '
 '
 
 test_expect_success 'verify blob:limit=1001' '
-	git -C r2 ls-files -s large.1000 |
-	awk -f print_2.awk |
+	git -C r2 ls-files -s large.1000 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	git -C r2 pack-objects --rev --stdout --filter=blob:limit=1001 >filter.pack <<-EOF &&
@@ -139,8 +140,8 @@ test_expect_success 'verify blob:limit=1001' '
 	EOF
 	git -C r2 index-pack ../filter.pack &&
 
-	git -C r2 verify-pack -v ../filter.pack |
-	grep blob |
+	git -C r2 verify-pack -v ../filter.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -148,8 +149,8 @@ test_expect_success 'verify blob:limit=1001' '
 '
 
 test_expect_success 'verify blob:limit=10001' '
-	git -C r2 ls-files -s large.1000 large.10000 |
-	awk -f print_2.awk |
+	git -C r2 ls-files -s large.1000 large.10000 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	git -C r2 pack-objects --rev --stdout --filter=blob:limit=10001 >filter.pack <<-EOF &&
@@ -157,8 +158,8 @@ test_expect_success 'verify blob:limit=10001' '
 	EOF
 	git -C r2 index-pack ../filter.pack &&
 
-	git -C r2 verify-pack -v ../filter.pack |
-	grep blob |
+	git -C r2 verify-pack -v ../filter.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -166,8 +167,8 @@ test_expect_success 'verify blob:limit=10001' '
 '
 
 test_expect_success 'verify blob:limit=1k' '
-	git -C r2 ls-files -s large.1000 |
-	awk -f print_2.awk |
+	git -C r2 ls-files -s large.1000 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	git -C r2 pack-objects --rev --stdout --filter=blob:limit=1k >filter.pack <<-EOF &&
@@ -175,8 +176,8 @@ test_expect_success 'verify blob:limit=1k' '
 	EOF
 	git -C r2 index-pack ../filter.pack &&
 
-	git -C r2 verify-pack -v ../filter.pack |
-	grep blob |
+	git -C r2 verify-pack -v ../filter.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -184,8 +185,8 @@ test_expect_success 'verify blob:limit=1k' '
 '
 
 test_expect_success 'verify explicitly specifying oversized blob in input' '
-	git -C r2 ls-files -s large.1000 large.10000 |
-	awk -f print_2.awk |
+	git -C r2 ls-files -s large.1000 large.10000 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	git -C r2 pack-objects --rev --stdout --filter=blob:limit=1k >filter.pack <<-EOF &&
@@ -194,8 +195,8 @@ test_expect_success 'verify explicitly specifying oversized blob in input' '
 	EOF
 	git -C r2 index-pack ../filter.pack &&
 
-	git -C r2 verify-pack -v ../filter.pack |
-	grep blob |
+	git -C r2 verify-pack -v ../filter.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -203,8 +204,8 @@ test_expect_success 'verify explicitly specifying oversized blob in input' '
 '
 
 test_expect_success 'verify blob:limit=1m' '
-	git -C r2 ls-files -s large.1000 large.10000 |
-	awk -f print_2.awk |
+	git -C r2 ls-files -s large.1000 large.10000 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	git -C r2 pack-objects --rev --stdout --filter=blob:limit=1m >filter.pack <<-EOF &&
@@ -212,8 +213,8 @@ test_expect_success 'verify blob:limit=1m' '
 	EOF
 	git -C r2 index-pack ../filter.pack &&
 
-	git -C r2 verify-pack -v ../filter.pack |
-	grep blob |
+	git -C r2 verify-pack -v ../filter.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -221,13 +222,13 @@ test_expect_success 'verify blob:limit=1m' '
 '
 
 test_expect_success 'verify normal and blob:limit packfiles have same commits/trees' '
-	git -C r2 verify-pack -v ../all.pack |
-	grep -E "commit|tree" |
+	git -C r2 verify-pack -v ../all.pack >verify_result &&
+	grep -E "commit|tree" verify_result |
 	awk -f print_1.awk |
 	sort >expected &&
 
-	git -C r2 verify-pack -v ../filter.pack |
-	grep -E "commit|tree" |
+	git -C r2 verify-pack -v ../filter.pack >verify_result &&
+	grep -E "commit|tree" verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -255,8 +256,9 @@ test_expect_success 'setup r3' '
 '
 
 test_expect_success 'verify blob count in normal packfile' '
-	git -C r3 ls-files -s sparse1 sparse2 dir1/sparse1 dir1/sparse2 |
-	awk -f print_2.awk |
+	git -C r3 ls-files -s sparse1 sparse2 dir1/sparse1 dir1/sparse2 \
+		>ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	git -C r3 pack-objects --rev --stdout >all.pack <<-EOF &&
@@ -264,8 +266,8 @@ test_expect_success 'verify blob count in normal packfile' '
 	EOF
 	git -C r3 index-pack ../all.pack &&
 
-	git -C r3 verify-pack -v ../all.pack |
-	grep blob |
+	git -C r3 verify-pack -v ../all.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -273,8 +275,8 @@ test_expect_success 'verify blob count in normal packfile' '
 '
 
 test_expect_success 'verify sparse:path=pattern1' '
-	git -C r3 ls-files -s dir1/sparse1 dir1/sparse2 |
-	awk -f print_2.awk |
+	git -C r3 ls-files -s dir1/sparse1 dir1/sparse2 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	git -C r3 pack-objects --rev --stdout --filter=sparse:path=../pattern1 >filter.pack <<-EOF &&
@@ -282,8 +284,8 @@ test_expect_success 'verify sparse:path=pattern1' '
 	EOF
 	git -C r3 index-pack ../filter.pack &&
 
-	git -C r3 verify-pack -v ../filter.pack |
-	grep blob |
+	git -C r3 verify-pack -v ../filter.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -291,13 +293,13 @@ test_expect_success 'verify sparse:path=pattern1' '
 '
 
 test_expect_success 'verify normal and sparse:path=pattern1 packfiles have same commits/trees' '
-	git -C r3 verify-pack -v ../all.pack |
-	grep -E "commit|tree" |
+	git -C r3 verify-pack -v ../all.pack >verify_result &&
+	grep -E "commit|tree" verify_result |
 	awk -f print_1.awk |
 	sort >expected &&
 
-	git -C r3 verify-pack -v ../filter.pack |
-	grep -E "commit|tree" |
+	git -C r3 verify-pack -v ../filter.pack >verify_result &&
+	grep -E "commit|tree" verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -305,8 +307,8 @@ test_expect_success 'verify normal and sparse:path=pattern1 packfiles have same
 '
 
 test_expect_success 'verify sparse:path=pattern2' '
-	git -C r3 ls-files -s sparse1 dir1/sparse1 |
-	awk -f print_2.awk |
+	git -C r3 ls-files -s sparse1 dir1/sparse1 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	git -C r3 pack-objects --rev --stdout --filter=sparse:path=../pattern2 >filter.pack <<-EOF &&
@@ -314,8 +316,8 @@ test_expect_success 'verify sparse:path=pattern2' '
 	EOF
 	git -C r3 index-pack ../filter.pack &&
 
-	git -C r3 verify-pack -v ../filter.pack |
-	grep blob |
+	git -C r3 verify-pack -v ../filter.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -323,13 +325,13 @@ test_expect_success 'verify sparse:path=pattern2' '
 '
 
 test_expect_success 'verify normal and sparse:path=pattern2 packfiles have same commits/trees' '
-	git -C r3 verify-pack -v ../all.pack |
-	grep -E "commit|tree" |
+	git -C r3 verify-pack -v ../all.pack >verify_result &&
+	grep -E "commit|tree" verify_result |
 	awk -f print_1.awk |
 	sort >expected &&
 
-	git -C r3 verify-pack -v ../filter.pack |
-	grep -E "commit|tree" |
+	git -C r3 verify-pack -v ../filter.pack >verify_result &&
+	grep -E "commit|tree" verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -356,8 +358,9 @@ test_expect_success 'setup r4' '
 '
 
 test_expect_success 'verify blob count in normal packfile' '
-	git -C r4 ls-files -s pattern sparse1 sparse2 dir1/sparse1 dir1/sparse2 |
-	awk -f print_2.awk |
+	git -C r4 ls-files -s pattern sparse1 sparse2 dir1/sparse1 dir1/sparse2 \
+		>ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	git -C r4 pack-objects --rev --stdout >all.pack <<-EOF &&
@@ -365,8 +368,8 @@ test_expect_success 'verify blob count in normal packfile' '
 	EOF
 	git -C r4 index-pack ../all.pack &&
 
-	git -C r4 verify-pack -v ../all.pack |
-	grep blob |
+	git -C r4 verify-pack -v ../all.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -374,8 +377,8 @@ test_expect_success 'verify blob count in normal packfile' '
 '
 
 test_expect_success 'verify sparse:oid=OID' '
-	git -C r4 ls-files -s dir1/sparse1 dir1/sparse2 |
-	awk -f print_2.awk |
+	git -C r4 ls-files -s dir1/sparse1 dir1/sparse2 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	oid=$(git -C r4 ls-files -s pattern | awk -f print_2.awk) &&
@@ -384,8 +387,8 @@ test_expect_success 'verify sparse:oid=OID' '
 	EOF
 	git -C r4 index-pack ../filter.pack &&
 
-	git -C r4 verify-pack -v ../filter.pack |
-	grep blob |
+	git -C r4 verify-pack -v ../filter.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -393,8 +396,8 @@ test_expect_success 'verify sparse:oid=OID' '
 '
 
 test_expect_success 'verify sparse:oid=oid-ish' '
-	git -C r4 ls-files -s dir1/sparse1 dir1/sparse2 |
-	awk -f print_2.awk |
+	git -C r4 ls-files -s dir1/sparse1 dir1/sparse2 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	git -C r4 pack-objects --rev --stdout --filter=sparse:oid=master:pattern >filter.pack <<-EOF &&
@@ -402,8 +405,8 @@ test_expect_success 'verify sparse:oid=oid-ish' '
 	EOF
 	git -C r4 index-pack ../filter.pack &&
 
-	git -C r4 verify-pack -v ../filter.pack |
-	grep blob |
+	git -C r4 verify-pack -v ../filter.pack >verify_result &&
+	grep blob verify_result |
 	awk -f print_1.awk |
 	sort >observed &&
 
@@ -414,8 +417,9 @@ test_expect_success 'verify sparse:oid=oid-ish' '
 # This models previously omitted objects that we did not receive.
 
 test_expect_success 'setup r1 - delete loose blobs' '
-	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 |
-	awk -f print_2.awk |
+	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 \
+		>ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	for id in `cat expected | sed "s|..|&/|"`
diff --git a/t/t5616-partial-clone.sh b/t/t5616-partial-clone.sh
index e4d032c9d..fc7aeb1ab 100755
--- a/t/t5616-partial-clone.sh
+++ b/t/t5616-partial-clone.sh
@@ -35,8 +35,8 @@ test_expect_success 'setup bare clone for server' '
 test_expect_success 'do partial clone 1' '
 	git clone --no-checkout --filter=blob:none "file://$(pwd)/srv.bare" pc1 &&
 
-	git -C pc1 rev-list HEAD --quiet --objects --missing=print |
-	awk -f print_1.awk |
+	git -C pc1 rev-list HEAD --quiet --objects --missing=print >revs &&
+	awk -f print_1.awk revs |
 	sed "s/?//" |
 	sort >observed.oids &&
 
@@ -133,16 +133,18 @@ test_expect_success 'push new commits to server for file.3.txt' '
 test_expect_success 'manual prefetch of missing objects' '
 	git -C pc1 fetch --filter=blob:none origin &&
 
-	git -C pc1 rev-list master..origin/master --quiet --objects --missing=print |
-	awk -f print_1.awk |
+	git -C pc1 rev-list master..origin/master --quiet --objects --missing=print \
+		>revs &&
+	awk -f print_1.awk revs |
 	sed "s/?//" |
 	sort >observed.oids &&
 
 	test_line_count = 6 observed.oids &&
 	git -C pc1 fetch-pack --stdin "file://$(pwd)/srv.bare" <observed.oids &&
 
-	git -C pc1 rev-list master..origin/master --quiet --objects --missing=print |
-	awk -f print_1.awk |
+	git -C pc1 rev-list master..origin/master --quiet --objects --missing=print \
+		>revs &&
+	awk -f print_1.awk revs |
 	sed "s/?//" |
 	sort >observed.oids &&
 
diff --git a/t/t6112-rev-list-filters-objects.sh b/t/t6112-rev-list-filters-objects.sh
index ae4402226..b00cf6fa8 100755
--- a/t/t6112-rev-list-filters-objects.sh
+++ b/t/t6112-rev-list-filters-objects.sh
@@ -20,12 +20,13 @@ test_expect_success 'setup r1' '
 '
 
 test_expect_success 'verify blob:none omits all 5 blobs' '
-	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 |
-	awk -f print_2.awk |
+	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 \
+		>ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
-	git -C r1 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:none |
-	awk -f print_1.awk |
+	git -C r1 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:none >revs &&
+	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
 
@@ -33,12 +34,13 @@ test_expect_success 'verify blob:none omits all 5 blobs' '
 '
 
 test_expect_success 'verify emitted+omitted == all' '
-	git -C r1 rev-list HEAD --objects |
-	awk -f print_1.awk |
+	git -C r1 rev-list HEAD --objects >revs &&
+	awk -f print_1.awk revs |
 	sort >expected &&
 
-	git -C r1 rev-list HEAD --objects --filter-print-omitted --filter=blob:none |
-	awk -f print_1.awk |
+	git -C r1 rev-list HEAD --objects --filter-print-omitted --filter=blob:none \
+		>revs &&
+	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
 
@@ -62,12 +64,12 @@ test_expect_success 'setup r2' '
 '
 
 test_expect_success 'verify blob:limit=500 omits all blobs' '
-	git -C r2 ls-files -s large.1000 large.10000 |
-	awk -f print_2.awk |
+	git -C r2 ls-files -s large.1000 large.10000 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
-	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=500 |
-	awk -f print_1.awk |
+	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=500 >revs &&
+	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
 
@@ -75,12 +77,12 @@ test_expect_success 'verify blob:limit=500 omits all blobs' '
 '
 
 test_expect_success 'verify emitted+omitted == all' '
-	git -C r2 rev-list HEAD --objects |
-	awk -f print_1.awk |
+	git -C r2 rev-list HEAD --objects >revs &&
+	awk -f print_1.awk revs |
 	sort >expected &&
 
-	git -C r2 rev-list HEAD --objects --filter-print-omitted --filter=blob:limit=500 |
-	awk -f print_1.awk |
+	git -C r2 rev-list HEAD --objects --filter-print-omitted --filter=blob:limit=500 >revs &&
+	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
 
@@ -88,12 +90,12 @@ test_expect_success 'verify emitted+omitted == all' '
 '
 
 test_expect_success 'verify blob:limit=1000' '
-	git -C r2 ls-files -s large.1000 large.10000 |
-	awk -f print_2.awk |
+	git -C r2 ls-files -s large.1000 large.10000 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
-	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1000 |
-	awk -f print_1.awk |
+	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1000 >revs &&
+	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
 
@@ -101,12 +103,12 @@ test_expect_success 'verify blob:limit=1000' '
 '
 
 test_expect_success 'verify blob:limit=1001' '
-	git -C r2 ls-files -s large.10000 |
-	awk -f print_2.awk |
+	git -C r2 ls-files -s large.10000 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
-	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1001 |
-	awk -f print_1.awk |
+	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1001 >revs &&
+	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
 
@@ -114,12 +116,12 @@ test_expect_success 'verify blob:limit=1001' '
 '
 
 test_expect_success 'verify blob:limit=1k' '
-	git -C r2 ls-files -s large.10000 |
-	awk -f print_2.awk |
+	git -C r2 ls-files -s large.10000 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
-	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1k |
-	awk -f print_1.awk |
+	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1k >revs &&
+	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
 
@@ -127,8 +129,8 @@ test_expect_success 'verify blob:limit=1k' '
 '
 
 test_expect_success 'verify blob:limit=1m' '
-	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1m |
-	awk -f print_1.awk |
+	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1m >revs &&
+	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
 
@@ -156,12 +158,12 @@ test_expect_success 'setup r3' '
 '
 
 test_expect_success 'verify sparse:path=pattern1 omits top-level files' '
-	git -C r3 ls-files -s sparse1 sparse2 |
-	awk -f print_2.awk |
+	git -C r3 ls-files -s sparse1 sparse2 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
-	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:path=../pattern1 |
-	awk -f print_1.awk |
+	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:path=../pattern1 >revs &&
+	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
 
@@ -169,12 +171,12 @@ test_expect_success 'verify sparse:path=pattern1 omits top-level files' '
 '
 
 test_expect_success 'verify sparse:path=pattern2 omits both sparse2 files' '
-	git -C r3 ls-files -s sparse2 dir1/sparse2 |
-	awk -f print_2.awk |
+	git -C r3 ls-files -s sparse2 dir1/sparse2 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
-	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:path=../pattern2 |
-	awk -f print_1.awk |
+	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:path=../pattern2 >revs &&
+	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
 
@@ -192,14 +194,14 @@ test_expect_success 'setup r3 part 2' '
 '
 
 test_expect_success 'verify sparse:oid=OID omits top-level files' '
-	git -C r3 ls-files -s pattern sparse1 sparse2 |
-	awk -f print_2.awk |
+	git -C r3 ls-files -s pattern sparse1 sparse2 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	oid=$(git -C r3 ls-files -s pattern | awk -f print_2.awk) &&
 
-	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:oid=$oid |
-	awk -f print_1.awk |
+	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:oid=$oid >revs &&
+	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
 
@@ -207,12 +209,12 @@ test_expect_success 'verify sparse:oid=OID omits top-level files' '
 '
 
 test_expect_success 'verify sparse:oid=oid-ish omits top-level files' '
-	git -C r3 ls-files -s pattern sparse1 sparse2 |
-	awk -f print_2.awk |
+	git -C r3 ls-files -s pattern sparse1 sparse2 >ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
-	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:oid=master:pattern |
-	awk -f print_1.awk |
+	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:oid=master:pattern >revs &&
+	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
 
@@ -223,8 +225,9 @@ test_expect_success 'verify sparse:oid=oid-ish omits top-level files' '
 # This models previously omitted objects that we did not receive.
 
 test_expect_success 'rev-list W/ --missing=print' '
-	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 |
-	awk -f print_2.awk |
+	git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 \
+		>ls_files_result &&
+	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
 	for id in `cat expected | sed "s|..|&/|"`
@@ -232,8 +235,8 @@ test_expect_success 'rev-list W/ --missing=print' '
 		rm r1/.git/objects/$id
 	done &&
 
-	git -C r1 rev-list --quiet HEAD --missing=print --objects |
-	awk -f print_1.awk |
+	git -C r1 rev-list --quiet HEAD --missing=print --objects >revs &&
+	awk -f print_1.awk revs |
 	sed "s/?//" |
 	sort >observed &&
 
-- 
2.19.0.605.g01d371f741-goog


^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [PATCH v5 6/7] t9109: don't swallow Git errors upstream of pipes
  2018-10-05 21:54 ` [PATCH v5 0/7] subject: Clean up tests for test_cmp arg ordering and pipe placement Matthew DeVore
                     ` (4 preceding siblings ...)
  2018-10-05 21:54   ` [PATCH v5 5/7] tests: don't swallow Git errors upstream of pipes Matthew DeVore
@ 2018-10-05 21:54   ` Matthew DeVore
  2018-10-05 21:54   ` [PATCH v5 7/7] tests: order arguments to git-rev-list properly Matthew DeVore
  2018-10-06 23:53   ` [PATCH v5 0/7] subject: Clean up tests for test_cmp arg ordering and pipe placement Junio C Hamano
  7 siblings, 0 replies; 66+ messages in thread
From: Matthew DeVore @ 2018-10-05 21:54 UTC (permalink / raw)
  To: git; +Cc: Matthew DeVore, peff, jonathantanmy, gitster, jrn, sunshine,
	szeder.dev

'git ... | foo' will mask any errors or crashes in git, so split up such
pipes in this file.

One testcase uses several separate pipe sequences in a row which are
awkward to split up. Wrap the split-up pipe in a function so the
awkwardness is not repeated. Also change that testcase's surrounding
quotes from double to single to avoid premature string interpolation.

Signed-off-by: Matthew DeVore <matvore@google.com>
---
 t/t9101-git-svn-props.sh | 34 +++++++++++++++++++++-------------
 1 file changed, 21 insertions(+), 13 deletions(-)

diff --git a/t/t9101-git-svn-props.sh b/t/t9101-git-svn-props.sh
index 8a5c8dc1a..c26c4b092 100755
--- a/t/t9101-git-svn-props.sh
+++ b/t/t9101-git-svn-props.sh
@@ -174,7 +174,8 @@ test_expect_success 'test create-ignore' "
 	cmp ./deeply/.gitignore create-ignore.expect &&
 	cmp ./deeply/nested/.gitignore create-ignore.expect &&
 	cmp ./deeply/nested/directory/.gitignore create-ignore.expect &&
-	git ls-files -s | grep gitignore | cmp - create-ignore-index.expect
+	git ls-files -s >ls_files_result &&
+	grep gitignore ls_files_result | cmp - create-ignore-index.expect
 	"
 
 cat >prop.expect <<\EOF
@@ -189,17 +190,21 @@ EOF
 # This test can be improved: since all the svn:ignore contain the same
 # pattern, it can pass even though the propget did not execute on the
 # right directory.
-test_expect_success 'test propget' "
-	git svn propget svn:ignore . | cmp - prop.expect &&
+test_expect_success 'test propget' '
+	test_propget () {
+		git svn propget $1 $2 >actual &&
+		cmp $3 actual
+	} &&
+	test_propget svn:ignore . prop.expect &&
 	cd deeply &&
-	git svn propget svn:ignore . | cmp - ../prop.expect &&
-	git svn propget svn:entry:committed-rev nested/directory/.keep \
-	  | cmp - ../prop2.expect &&
-	git svn propget svn:ignore .. | cmp - ../prop.expect &&
-	git svn propget svn:ignore nested/ | cmp - ../prop.expect &&
-	git svn propget svn:ignore ./nested | cmp - ../prop.expect &&
-	git svn propget svn:ignore .././deeply/nested | cmp - ../prop.expect
-	"
+	test_propget svn:ignore . ../prop.expect &&
+	test_propget svn:entry:committed-rev nested/directory/.keep \
+		../prop2.expect &&
+	test_propget svn:ignore .. ../prop.expect &&
+	test_propget svn:ignore nested/ ../prop.expect &&
+	test_propget svn:ignore ./nested ../prop.expect &&
+	test_propget svn:ignore .././deeply/nested ../prop.expect
+	'
 
 cat >prop.expect <<\EOF
 Properties on '.':
@@ -218,8 +223,11 @@ Properties on 'nested/directory/.keep':
 EOF
 
 test_expect_success 'test proplist' "
-	git svn proplist . | cmp - prop.expect &&
-	git svn proplist nested/directory/.keep | cmp - prop2.expect
+	git svn proplist . >actual &&
+	cmp prop.expect actual &&
+
+	git svn proplist nested/directory/.keep >actual &&
+	cmp prop2.expect actual
 	"
 
 test_done
-- 
2.19.0.605.g01d371f741-goog


^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [PATCH v5 7/7] tests: order arguments to git-rev-list properly
  2018-10-05 21:54 ` [PATCH v5 0/7] subject: Clean up tests for test_cmp arg ordering and pipe placement Matthew DeVore
                     ` (5 preceding siblings ...)
  2018-10-05 21:54   ` [PATCH v5 6/7] t9109: " Matthew DeVore
@ 2018-10-05 21:54   ` Matthew DeVore
  2018-10-06 23:53   ` [PATCH v5 0/7] subject: Clean up tests for test_cmp arg ordering and pipe placement Junio C Hamano
  7 siblings, 0 replies; 66+ messages in thread
From: Matthew DeVore @ 2018-10-05 21:54 UTC (permalink / raw)
  To: git; +Cc: Matthew DeVore, peff, jonathantanmy, gitster, jrn, sunshine,
	szeder.dev

It is a common mistake to put positional arguments before flags when
invoking git-rev-list. Order the positional arguments last.

This patch skips git-rev-list invocations which include the --not flag,
since the ordering of flags and positional arguments affects the
behavior. This patch also skips invocations of git-rev-list that occur
in command substitution in which the exit code is discarded, since
fixing those properly will require a more involved cleanup.

Signed-off-by: Matthew DeVore <matvore@google.com>
---
 t/t5616-partial-clone.sh            | 26 +++++++++--------
 t/t5702-protocol-v2.sh              |  4 +--
 t/t6112-rev-list-filters-objects.sh | 43 ++++++++++++++++++-----------
 3 files changed, 44 insertions(+), 29 deletions(-)

diff --git a/t/t5616-partial-clone.sh b/t/t5616-partial-clone.sh
index fc7aeb1ab..6ff614692 100755
--- a/t/t5616-partial-clone.sh
+++ b/t/t5616-partial-clone.sh
@@ -35,7 +35,7 @@ test_expect_success 'setup bare clone for server' '
 test_expect_success 'do partial clone 1' '
 	git clone --no-checkout --filter=blob:none "file://$(pwd)/srv.bare" pc1 &&
 
-	git -C pc1 rev-list HEAD --quiet --objects --missing=print >revs &&
+	git -C pc1 rev-list --quiet --objects --missing=print HEAD >revs &&
 	awk -f print_1.awk revs |
 	sed "s/?//" |
 	sort >observed.oids &&
@@ -48,10 +48,10 @@ test_expect_success 'do partial clone 1' '
 
 # checkout master to force dynamic object fetch of blobs at HEAD.
 test_expect_success 'verify checkout with dynamic object fetch' '
-	git -C pc1 rev-list HEAD --quiet --objects --missing=print >observed &&
+	git -C pc1 rev-list --quiet --objects --missing=print HEAD >observed &&
 	test_line_count = 4 observed &&
 	git -C pc1 checkout master &&
-	git -C pc1 rev-list HEAD --quiet --objects --missing=print >observed &&
+	git -C pc1 rev-list --quiet --objects --missing=print HEAD >observed &&
 	test_line_count = 0 observed
 '
 
@@ -74,7 +74,8 @@ test_expect_success 'push new commits to server' '
 # have the new blobs.
 test_expect_success 'partial fetch inherits filter settings' '
 	git -C pc1 fetch origin &&
-	git -C pc1 rev-list master..origin/master --quiet --objects --missing=print >observed &&
+	git -C pc1 rev-list --quiet --objects --missing=print \
+		master..origin/master >observed &&
 	test_line_count = 5 observed
 '
 
@@ -82,7 +83,8 @@ test_expect_success 'partial fetch inherits filter settings' '
 # we should only get 1 new blob (for the file in origin/master).
 test_expect_success 'verify diff causes dynamic object fetch' '
 	git -C pc1 diff master..origin/master -- file.1.txt &&
-	git -C pc1 rev-list master..origin/master --quiet --objects --missing=print >observed &&
+	git -C pc1 rev-list --quiet --objects --missing=print \
+		 master..origin/master >observed &&
 	test_line_count = 4 observed
 '
 
@@ -91,7 +93,8 @@ test_expect_success 'verify diff causes dynamic object fetch' '
 test_expect_success 'verify blame causes dynamic object fetch' '
 	git -C pc1 blame origin/master -- file.1.txt >observed.blame &&
 	test_cmp expect.blame observed.blame &&
-	git -C pc1 rev-list master..origin/master --quiet --objects --missing=print >observed &&
+	git -C pc1 rev-list --quiet --objects --missing=print \
+		master..origin/master >observed &&
 	test_line_count = 0 observed
 '
 
@@ -111,7 +114,8 @@ test_expect_success 'push new commits to server for file.2.txt' '
 # Verify we have all the new blobs.
 test_expect_success 'override inherited filter-spec using --no-filter' '
 	git -C pc1 fetch --no-filter origin &&
-	git -C pc1 rev-list master..origin/master --quiet --objects --missing=print >observed &&
+	git -C pc1 rev-list --quiet --objects --missing=print \
+		master..origin/master >observed &&
 	test_line_count = 0 observed
 '
 
@@ -133,8 +137,8 @@ test_expect_success 'push new commits to server for file.3.txt' '
 test_expect_success 'manual prefetch of missing objects' '
 	git -C pc1 fetch --filter=blob:none origin &&
 
-	git -C pc1 rev-list master..origin/master --quiet --objects --missing=print \
-		>revs &&
+	git -C pc1 rev-list --quiet --objects --missing=print \
+		 master..origin/master >revs &&
 	awk -f print_1.awk revs |
 	sed "s/?//" |
 	sort >observed.oids &&
@@ -142,8 +146,8 @@ test_expect_success 'manual prefetch of missing objects' '
 	test_line_count = 6 observed.oids &&
 	git -C pc1 fetch-pack --stdin "file://$(pwd)/srv.bare" <observed.oids &&
 
-	git -C pc1 rev-list master..origin/master --quiet --objects --missing=print \
-		>revs &&
+	git -C pc1 rev-list --quiet --objects --missing=print \
+		master..origin/master >revs &&
 	awk -f print_1.awk revs |
 	sed "s/?//" |
 	sort >observed.oids &&
diff --git a/t/t5702-protocol-v2.sh b/t/t5702-protocol-v2.sh
index 54727450b..11a84efff 100755
--- a/t/t5702-protocol-v2.sh
+++ b/t/t5702-protocol-v2.sh
@@ -271,7 +271,7 @@ test_expect_success 'partial clone' '
 	grep "version 2" trace &&
 
 	# Ensure that the old version of the file is missing
-	git -C client rev-list master --quiet --objects --missing=print \
+	git -C client rev-list --quiet --objects --missing=print master \
 		>observed.oids &&
 	grep "$(git -C server rev-parse message1:a.txt)" observed.oids &&
 
@@ -297,7 +297,7 @@ test_expect_success 'partial fetch' '
 	grep "version 2" trace &&
 
 	# Ensure that the old version of the file is missing
-	git -C client rev-list other --quiet --objects --missing=print \
+	git -C client rev-list --quiet --objects --missing=print other \
 		>observed.oids &&
 	grep "$(git -C server rev-parse message1:a.txt)" observed.oids &&
 
diff --git a/t/t6112-rev-list-filters-objects.sh b/t/t6112-rev-list-filters-objects.sh
index b00cf6fa8..53975c572 100755
--- a/t/t6112-rev-list-filters-objects.sh
+++ b/t/t6112-rev-list-filters-objects.sh
@@ -25,7 +25,8 @@ test_expect_success 'verify blob:none omits all 5 blobs' '
 	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
-	git -C r1 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:none >revs &&
+	git -C r1 rev-list --quiet --objects --filter-print-omitted \
+		--filter=blob:none HEAD >revs &&
 	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
@@ -34,12 +35,12 @@ test_expect_success 'verify blob:none omits all 5 blobs' '
 '
 
 test_expect_success 'verify emitted+omitted == all' '
-	git -C r1 rev-list HEAD --objects >revs &&
+	git -C r1 rev-list --objects HEAD >revs &&
 	awk -f print_1.awk revs |
 	sort >expected &&
 
-	git -C r1 rev-list HEAD --objects --filter-print-omitted --filter=blob:none \
-		>revs &&
+	git -C r1 rev-list --objects --filter-print-omitted --filter=blob:none \
+		HEAD >revs &&
 	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
@@ -68,7 +69,8 @@ test_expect_success 'verify blob:limit=500 omits all blobs' '
 	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
-	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=500 >revs &&
+	git -C r2 rev-list --quiet --objects --filter-print-omitted \
+		--filter=blob:limit=500 HEAD >revs &&
 	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
@@ -77,11 +79,12 @@ test_expect_success 'verify blob:limit=500 omits all blobs' '
 '
 
 test_expect_success 'verify emitted+omitted == all' '
-	git -C r2 rev-list HEAD --objects >revs &&
+	git -C r2 rev-list --objects HEAD >revs &&
 	awk -f print_1.awk revs |
 	sort >expected &&
 
-	git -C r2 rev-list HEAD --objects --filter-print-omitted --filter=blob:limit=500 >revs &&
+	git -C r2 rev-list --objects --filter-print-omitted \
+		--filter=blob:limit=500 HEAD >revs &&
 	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
@@ -94,7 +97,8 @@ test_expect_success 'verify blob:limit=1000' '
 	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
-	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1000 >revs &&
+	git -C r2 rev-list --quiet --objects --filter-print-omitted \
+		--filter=blob:limit=1000 HEAD >revs &&
 	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
@@ -107,7 +111,8 @@ test_expect_success 'verify blob:limit=1001' '
 	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
-	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1001 >revs &&
+	git -C r2 rev-list --quiet --objects --filter-print-omitted \
+		--filter=blob:limit=1001 HEAD >revs &&
 	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
@@ -120,7 +125,8 @@ test_expect_success 'verify blob:limit=1k' '
 	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
-	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1k >revs &&
+	git -C r2 rev-list --quiet --objects --filter-print-omitted \
+		--filter=blob:limit=1k HEAD >revs &&
 	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
@@ -129,7 +135,8 @@ test_expect_success 'verify blob:limit=1k' '
 '
 
 test_expect_success 'verify blob:limit=1m' '
-	git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1m >revs &&
+	git -C r2 rev-list --quiet --objects --filter-print-omitted \
+		--filter=blob:limit=1m HEAD >revs &&
 	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
@@ -162,7 +169,8 @@ test_expect_success 'verify sparse:path=pattern1 omits top-level files' '
 	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
-	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:path=../pattern1 >revs &&
+	git -C r3 rev-list --quiet --objects --filter-print-omitted \
+		--filter=sparse:path=../pattern1 HEAD >revs &&
 	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
@@ -175,7 +183,8 @@ test_expect_success 'verify sparse:path=pattern2 omits both sparse2 files' '
 	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
-	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:path=../pattern2 >revs &&
+	git -C r3 rev-list --quiet --objects --filter-print-omitted \
+		--filter=sparse:path=../pattern2 HEAD >revs &&
 	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
@@ -200,7 +209,8 @@ test_expect_success 'verify sparse:oid=OID omits top-level files' '
 
 	oid=$(git -C r3 ls-files -s pattern | awk -f print_2.awk) &&
 
-	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:oid=$oid >revs &&
+	git -C r3 rev-list --quiet --objects --filter-print-omitted \
+		--filter=sparse:oid=$oid HEAD >revs &&
 	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
@@ -213,7 +223,8 @@ test_expect_success 'verify sparse:oid=oid-ish omits top-level files' '
 	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
-	git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:oid=master:pattern >revs &&
+	git -C r3 rev-list --quiet --objects --filter-print-omitted \
+		--filter=sparse:oid=master:pattern HEAD >revs &&
 	awk -f print_1.awk revs |
 	sed "s/~//" |
 	sort >observed &&
@@ -235,7 +246,7 @@ test_expect_success 'rev-list W/ --missing=print' '
 		rm r1/.git/objects/$id
 	done &&
 
-	git -C r1 rev-list --quiet HEAD --missing=print --objects >revs &&
+	git -C r1 rev-list --quiet --missing=print --objects HEAD >revs &&
 	awk -f print_1.awk revs |
 	sed "s/?//" |
 	sort >observed &&
-- 
2.19.0.605.g01d371f741-goog


^ permalink raw reply related	[flat|nested] 66+ messages in thread

* Re: [PATCH v5 0/7] subject: Clean up tests for test_cmp arg ordering and pipe placement
  2018-10-05 21:54 ` [PATCH v5 0/7] subject: Clean up tests for test_cmp arg ordering and pipe placement Matthew DeVore
                     ` (6 preceding siblings ...)
  2018-10-05 21:54   ` [PATCH v5 7/7] tests: order arguments to git-rev-list properly Matthew DeVore
@ 2018-10-06 23:53   ` Junio C Hamano
  7 siblings, 0 replies; 66+ messages in thread
From: Junio C Hamano @ 2018-10-06 23:53 UTC (permalink / raw)
  To: Matthew DeVore; +Cc: git, peff, jonathantanmy, jrn, sunshine, szeder.dev

Matthew DeVore <matvore@google.com> writes:

> This version of the patchset fixes some wording and formatting issues
> pointed out by Junio. The commit message in the first patch has also
> been reworded.


Thanks.

If no further major issues are raised, let's merge it to 'next'.



^ permalink raw reply	[flat|nested] 66+ messages in thread

end of thread, other threads:[~2018-10-06 23:53 UTC | newest]

Thread overview: 66+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-15  0:02 [PATCH v1 0/2] Cleanup tests for test_cmp argument ordering and "|" placement Matthew DeVore
2018-09-15  0:02 ` [PATCH v1 1/2] t/*: fix pipe placement and remove \'s Matthew DeVore
2018-09-17 16:31   ` Jonathan Nieder
2018-09-17 21:47     ` Matthew DeVore
2018-09-15  0:02 ` [PATCH v1 2/2] t/*: fix ordering of expected/observed arguments Matthew DeVore
2018-09-17 12:56   ` Matthew DeVore
2018-09-15 15:55 ` [PATCH v1 0/2] Cleanup tests for test_cmp argument ordering and "|" placement Junio C Hamano
2018-09-17 22:24 ` [PATCH v2 0/6] Clean up tests for test_cmp arg ordering and pipe placement Matthew DeVore
2018-09-17 22:24   ` [PATCH v2 4/6] tests: Add linter check for pipe placement style Matthew DeVore
2018-09-18  0:34     ` Eric Sunshine
2018-09-19 17:39       ` Matthew DeVore
     [not found] ` <cover.1537223021.git.matvore@google.com>
2018-09-17 22:24   ` [PATCH v2 1/6] CodingGuidelines: add shell piping guidelines Matthew DeVore
2018-09-18  0:16     ` Eric Sunshine
2018-09-19  2:11       ` Matthew DeVore
2018-09-19 12:36         ` Eric Sunshine
2018-09-19 14:24         ` Junio C Hamano
2018-09-19 20:06           ` Matthew DeVore
2018-09-17 22:24   ` [PATCH v2 2/6] tests: standardize pipe placement Matthew DeVore
2018-09-17 22:24   ` [PATCH v2 3/6] t/*: fix ordering of expected/observed arguments Matthew DeVore
2018-09-17 22:24   ` [PATCH v2 4/6] tests: add linter check for pipe placement style Matthew DeVore
2018-09-17 22:24   ` [PATCH v2 5/6] tests: split up pipes Matthew DeVore
2018-09-18  1:30     ` Eric Sunshine
2018-09-19  2:33       ` Matthew DeVore
2018-09-17 22:24   ` [PATCH v2 6/6] t9109-git-svn-props.sh: split up several pipes Matthew DeVore
2018-09-18  1:56     ` Eric Sunshine
2018-09-19  2:56       ` Matthew DeVore
2018-09-19 12:50         ` Eric Sunshine
2018-09-19 18:43           ` Matthew DeVore
2018-09-21  1:43 ` [PATCH v3 0/5] Clean up tests for test_cmp arg ordering and pipe placement Matthew DeVore
2018-09-21  1:43   ` [PATCH v3 1/5] CodingGuidelines: add shell piping guidelines Matthew DeVore
2018-09-21  2:06     ` Eric Sunshine
2018-09-21 21:03       ` Matthew DeVore
2018-09-24 21:03     ` SZEDER Gábor
2018-09-25 21:58       ` Matthew DeVore
2018-09-27 21:18         ` SZEDER Gábor
2018-10-01 23:07           ` Matthew DeVore
2018-09-21  1:43   ` [PATCH v3 2/5] tests: standardize pipe placement Matthew DeVore
2018-09-21  1:43   ` [PATCH v3 3/5] t/*: fix ordering of expected/observed arguments Matthew DeVore
2018-09-21  1:43   ` [PATCH v3 4/5] tests: don't swallow Git errors upstream of pipes Matthew DeVore
2018-09-21  1:43   ` [PATCH v3 5/5] t9109: " Matthew DeVore
2018-10-03 16:25 ` [PATCH v4 0/7] Clean up tests for test_cmp arg ordering and pipe placement Matthew DeVore
2018-10-03 16:25   ` [PATCH v4 1/7] t/README: reformat Do, Don't, Keep in mind lists Matthew DeVore
2018-10-05  6:15     ` Junio C Hamano
2018-10-05 14:57       ` Matthew DeVore
2018-10-03 16:26   ` [PATCH v4 2/7] Documentation: add shell guidelines Matthew DeVore
2018-10-05 16:48     ` Junio C Hamano
2018-10-05 18:21       ` Matthew DeVore
2018-10-03 16:26   ` [PATCH v4 3/7] tests: standardize pipe placement Matthew DeVore
2018-10-03 16:26   ` [PATCH v4 4/7] t/*: fix ordering of expected/observed arguments Matthew DeVore
2018-10-03 16:26   ` [PATCH v4 5/7] tests: don't swallow Git errors upstream of pipes Matthew DeVore
2018-10-05 16:48     ` Junio C Hamano
2018-10-05 17:54       ` Matthew DeVore
2018-10-05 18:12         ` Matthew DeVore
2018-10-03 16:26   ` [PATCH v4 6/7] t9109: " Matthew DeVore
2018-10-03 16:26   ` [PATCH v4 7/7] tests: order arguments to git-rev-list properly Matthew DeVore
2018-10-03 16:33     ` Matthew DeVore
2018-10-05  8:16       ` Junio C Hamano
2018-10-05 21:54 ` [PATCH v5 0/7] subject: Clean up tests for test_cmp arg ordering and pipe placement Matthew DeVore
2018-10-05 21:54   ` [PATCH v5 1/7] t/README: reformat Do, Don't, Keep in mind lists Matthew DeVore
2018-10-05 21:54   ` [PATCH v5 2/7] Documentation: add shell guidelines Matthew DeVore
2018-10-05 21:54   ` [PATCH v5 3/7] tests: standardize pipe placement Matthew DeVore
2018-10-05 21:54   ` [PATCH v5 4/7] t/*: fix ordering of expected/observed arguments Matthew DeVore
2018-10-05 21:54   ` [PATCH v5 5/7] tests: don't swallow Git errors upstream of pipes Matthew DeVore
2018-10-05 21:54   ` [PATCH v5 6/7] t9109: " Matthew DeVore
2018-10-05 21:54   ` [PATCH v5 7/7] tests: order arguments to git-rev-list properly Matthew DeVore
2018-10-06 23:53   ` [PATCH v5 0/7] subject: Clean up tests for test_cmp arg ordering and pipe placement Junio C Hamano

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).