git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCHv2 5/5] t6300 (for-each-ref): modernize style

From
Tom Grennan <tmgrennan@gmail.com>
Date
Mar 3, 2012, 02:15 UTC
Message-ID
<1330740942-25130-6-git-send-email-tmgrennan@gmail.com>
In-Reply-To
<1330740942-25130-1-git-send-email-tmgrennan@gmail.com>
- Guard setup with test_expect_success
- Unwound one loop to stay within the test_expect_success guard
Signed-off-by: Tom Grennan <tmgrennan@gmail.com>
---
 t/t6300-for-each-ref.sh |  186 +++++++++++++++++++++++------------------------
 1 files changed, 92 insertions(+), 94 deletions(-)
diff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh
index 1721784..ebba7d1 100755
--- a/t/t6300-for-each-ref.sh
+++ b/t/t6300-for-each-ref.sh
@@ -138,12 +138,13 @@ test_expect_success 'Check invalid format specifiers are errors' '
 	test_must_fail git for-each-ref --format="%(authordate:INVALID)" refs/heads
 '
 
-cat >expected <<\EOF
-'refs/heads/master' 'Mon Jul 3 17:18:43 2006 +0200' 'Mon Jul 3 17:18:44 2006 +0200'
-'refs/tags/testtag' 'Mon Jul 3 17:18:45 2006 +0200'
-EOF
-
 test_expect_success 'Check unformatted date fields output' '
+	'"
+	cat >expected <<-EOF &&
+		'refs/heads/master' 'Mon Jul 3 17:18:43 2006 +0200' 'Mon Jul 3 17:18:44 2006 +0200'
+		'refs/tags/testtag' 'Mon Jul 3 17:18:45 2006 +0200'
+	EOF
+	"'
 	(git for-each-ref --shell --format="%(refname) %(committerdate) %(authordate)" refs/heads &&
 	git for-each-ref --shell --format="%(refname) %(taggerdate)" refs/tags) >actual &&
 	test_cmp expected actual
@@ -171,84 +172,85 @@ test_expect_success 'Check format "relative" date fields output' '
 	git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual
 '
 
-cat >expected <<\EOF
-'refs/heads/master' '2006-07-03' '2006-07-03'
-'refs/tags/testtag' '2006-07-03'
-EOF
-
 test_expect_success 'Check format "short" date fields output' '
+	'"
+	cat >expected <<-EOF
+		'refs/heads/master' '2006-07-03' '2006-07-03'
+		'refs/tags/testtag' '2006-07-03'
+	EOF
+	"'
 	f=short &&
 	(git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads &&
 	git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual &&
 	test_cmp expected actual
 '
 
-cat >expected <<\EOF
-'refs/heads/master' 'Mon Jul 3 15:18:43 2006' 'Mon Jul 3 15:18:44 2006'
-'refs/tags/testtag' 'Mon Jul 3 15:18:45 2006'
-EOF
-
 test_expect_success 'Check format "local" date fields output' '
-	f=local &&
-	(git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads &&
-	git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual &&
+	'"
+	cat >expected <<-EOF
+		'refs/heads/master' 'Mon Jul 3 15:18:43 2006' 'Mon Jul 3 15:18:44 2006'
+		'refs/tags/testtag' 'Mon Jul 3 15:18:45 2006'
+	EOF
+	"'
+	(git for-each-ref --shell --format="%(refname) %(committerdate:local) %(authordate:local)" refs/heads &&
+	 git for-each-ref --shell --format="%(refname) %(taggerdate:local)" refs/tags) >actual &&
 	test_cmp expected actual
 '
 
-cat >expected <<\EOF
-'refs/heads/master' '2006-07-03 17:18:43 +0200' '2006-07-03 17:18:44 +0200'
-'refs/tags/testtag' '2006-07-03 17:18:45 +0200'
-EOF
-
 test_expect_success 'Check format "iso8601" date fields output' '
+	'"
+	cat >expected <<-EOF
+		'refs/heads/master' '2006-07-03 17:18:43 +0200' '2006-07-03 17:18:44 +0200'
+		'refs/tags/testtag' '2006-07-03 17:18:45 +0200'
+	EOF
+	"'
 	f=iso8601 &&
 	(git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads &&
 	git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual &&
 	test_cmp expected actual
 '
 
-cat >expected <<\EOF
-'refs/heads/master' 'Mon, 3 Jul 2006 17:18:43 +0200' 'Mon, 3 Jul 2006 17:18:44 +0200'
-'refs/tags/testtag' 'Mon, 3 Jul 2006 17:18:45 +0200'
-EOF
-
 test_expect_success 'Check format "rfc2822" date fields output' '
+	'"
+	cat >expected <<-EOF
+		'refs/heads/master' 'Mon, 3 Jul 2006 17:18:43 +0200' 'Mon, 3 Jul 2006 17:18:44 +0200'
+		'refs/tags/testtag' 'Mon, 3 Jul 2006 17:18:45 +0200'
+	EOF
+	"'
 	f=rfc2822 &&
 	(git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads &&
 	git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual &&
 	test_cmp expected actual
 '
 
-cat >expected <<\EOF
-refs/heads/master
-refs/remotes/origin/master
-refs/tags/testtag
-EOF
-
 test_expect_success 'Verify ascending sort' '
+	cat >expected <<-EOF
+		refs/heads/master
+		refs/remotes/origin/master
+		refs/tags/testtag
+	EOF
 	git for-each-ref --format="%(refname)" --sort=refname >actual &&
 	test_cmp expected actual
 '
 
-
-cat >expected <<\EOF
-refs/tags/testtag
-refs/remotes/origin/master
-refs/heads/master
-EOF
-
 test_expect_success 'Verify descending sort' '
+	cat >expected <<-EOF
+		refs/tags/testtag
+		refs/remotes/origin/master
+		refs/heads/master
+	EOF
 	git for-each-ref --format="%(refname)" --sort=-refname >actual &&
 	test_cmp expected actual
 '
 
-cat >expected <<\EOF
-'refs/heads/master'
-'refs/remotes/origin/master'
-'refs/tags/testtag'
-EOF
-
 test_expect_success 'Quoting style: shell' '
+	'"
+	cat >expected <<-EOF
+		'refs/heads/master'
+		'refs/remotes/origin/master'
+		'refs/tags/testtag'
+	EOF
+	"'
 	git for-each-ref --shell --format="%(refname)" >actual &&
 	test_cmp expected actual
 '
@@ -263,52 +265,51 @@ test_expect_success 'Quoting style: python' '
 	test_cmp expected actual
 '
 
-cat >expected <<\EOF
-"refs/heads/master"
-"refs/remotes/origin/master"
-"refs/tags/testtag"
-EOF
-
 test_expect_success 'Quoting style: tcl' '
+	cat >expected <<-EOF
+		"refs/heads/master"
+		"refs/remotes/origin/master"
+		"refs/tags/testtag"
+	EOF
 	git for-each-ref --tcl --format="%(refname)" >actual &&
 	test_cmp expected actual
 '
 
-for i in "--perl --shell" "-s --python" "--python --tcl" "--tcl --perl"; do
-	test_expect_success "more than one quoting style: $i" "
-		git for-each-ref $i 2>&1 | (read line &&
-		case \$line in
-		\"error: more than one quoting style\"*) : happy;;
-		*) false
-		esac)
-	"
-done
-
-cat >expected <<\EOF
-master
-testtag
-EOF
-
+test_expect_success 'more than one quoting styles' '
+	cat >expected <<-EOF
+		error: more than one quoting style?
+	EOF
+	git for-each-ref --perl --shell 2>&1 | head -n 1 >actual &&
+	test_cmp expected actual &&
+	git for-each-ref -s --python 2>&1 | head -n 1 >actual &&
+	test_cmp expected actual &&
+	git for-each-ref --python --tcl 2>&1 | head -n 1 >actual &&
+	test_cmp expected actual &&
+	git for-each-ref --tcl --perl 2>&1 | head -n 1 >actual &&
+	test_cmp expected actual
+'
 test_expect_success 'Check short refname format' '
+	cat >expected <<-EOF
+		master
+		testtag
+	EOF
 	(git for-each-ref --format="%(refname:short)" refs/heads &&
 	git for-each-ref --format="%(refname:short)" refs/tags) >actual &&
 	test_cmp expected actual
 '
 
-cat >expected <<EOF
-origin/master
-EOF
-
 test_expect_success 'Check short upstream format' '
+	cat >expected <<-EOF
+		origin/master
+	EOF
 	git for-each-ref --format="%(upstream:short)" refs/heads >actual &&
 	test_cmp expected actual
 '
 
-cat >expected <<EOF
-67a36f1
-EOF
-
 test_expect_success 'Check short objectname format' '
+	cat >expected <<-EOF
+		67a36f1
+	EOF
 	git for-each-ref --format="%(objectname:short)" refs/heads >actual &&
 	test_cmp expected actual
 '
@@ -317,12 +318,11 @@ test_expect_success 'Check for invalid refname format' '
 	test_must_fail git for-each-ref --format="%(refname:INVALID)"
 '
 
-cat >expected <<\EOF
-heads/master
-tags/master
-EOF
-
 test_expect_success 'Check ambiguous head and tag refs (strict)' '
+	cat >expected <<-EOF
+		heads/master
+		tags/master
+	EOF
 	git config --bool core.warnambiguousrefs true &&
 	git checkout -b newtag &&
 	echo "Using $datestamp" > one &&
@@ -334,23 +334,21 @@ test_expect_success 'Check ambiguous head and tag refs (strict)' '
 	test_cmp expected actual
 '
 
-cat >expected <<\EOF
-heads/master
-master
-EOF
-
 test_expect_success 'Check ambiguous head and tag refs (loose)' '
+	cat >expected <<-EOF
+		heads/master
+		master
+	EOF
 	git config --bool core.warnambiguousrefs false &&
 	git for-each-ref --format "%(refname:short)" refs/heads/master refs/tags/master >actual &&
 	test_cmp expected actual
 '
 
-cat >expected <<\EOF
-heads/ambiguous
-ambiguous
-EOF
-
 test_expect_success 'Check ambiguous head and tag refs II (loose)' '
+	cat >expected <<-EOF
+		heads/ambiguous
+		ambiguous
+	EOF
 	git checkout master &&
 	git tag ambiguous testtag^0 &&
 	git branch ambiguous testtag^0 &&
@@ -369,7 +367,7 @@ test_expect_success 'an unusual tag with an incomplete line' '
 '
 
 test_expect_success 'create tag with subject and body content' '
-	cat >>msg <<-\EOF &&
+	cat >msg <<-\EOF &&
 		the subject line
 
 		first body line
@@ -417,9 +415,9 @@ test_expect_success GPG 'create signed tags' '
 	git tag -s -m "" signed-empty &&
 	git tag -s -m "subject line" signed-short &&
 	cat >msg <<-\EOF &&
-	subject line
+		subject line
 
-	body contents
+		body contents
 	EOF
 	git tag -s -F msg signed-long
 '
-- 
1.7.8
Previous: Tom GrennanNext: Tom Grennan
Message 74 of 83 in “tag: make list exclude !<pattern>”
  1. tag: make list exclude !<pattern>Tom Grennan, Feb 9, 2012
  2. tag: make list exclude !<pattern>Tom Grennan, Feb 9, 2012
  3. Tom GrennanFeb 10, 2012
  4. Nguyen Thai Ngoc DuyFeb 10, 2012
  5. Tom GrennanFeb 10, 2012
  6. Tom GrennanFeb 11, 2012
  7. 1/4 refs: add common refname_match_patterns()Tom Grennan, Feb 11, 2012
  8. Michael HaggertyFeb 11, 2012
  9. Tom GrennanFeb 11, 2012
  10. Michael HaggertyFeb 13, 2012
  11. Tom GrennanFeb 13, 2012
  12. Junio C HamanoFeb 11, 2012
  13. Tom GrennanFeb 11, 2012
  14. Junio C HamanoFeb 11, 2012
  15. Tom GrennanFeb 13, 2012
  16. 2/4 tag: use refs.c:refname_match_patterns()Tom Grennan, Feb 11, 2012
  17. 3/4 branch: use refs.c:refname_match_patterns()Tom Grennan, Feb 11, 2012
  18. 4/4 for-each-ref: use refs.c:refname_match_patterns()Tom Grennan, Feb 11, 2012
  19. Junio C HamanoFeb 11, 2012
  20. Junio C HamanoFeb 11, 2012
  21. Jakub NarebskiFeb 11, 2012
  22. Nguyen Thai Ngoc DuyFeb 11, 2012
  23. Junio C HamanoFeb 11, 2012
  24. Tom GrennanFeb 11, 2012
  25. Michael HaggertyFeb 11, 2012
  26. Junio C HamanoFeb 11, 2012
  27. Michael HaggertyFeb 13, 2012
  28. Junio C HamanoFeb 13, 2012
  29. Michael HaggertyFeb 13, 2012
  30. Junio C HamanoFeb 13, 2012
  31. Michael HaggertyFeb 13, 2012
  32. Junio C HamanoFeb 13, 2012
  33. Tom GrennanFeb 11, 2012
  34. 0/5 Re: tag: make list exclude !<pattern>Tom Grennan, Feb 22, 2012
  35. 1/5 refs: add match_pattern()Tom Grennan, Feb 22, 2012
  36. Junio C HamanoFeb 22, 2012
  37. Tom GrennanFeb 22, 2012
  38. Junio C HamanoFeb 23, 2012
  39. Tom GrennanFeb 23, 2012
  40. 2/5 tag --points-at option wrapperTom Grennan, Feb 22, 2012
  41. 3/5 tag --exclude optionTom Grennan, Feb 22, 2012
  42. Junio C HamanoFeb 22, 2012
  43. Tom GrennanFeb 23, 2012
  44. Junio C HamanoFeb 23, 2012
  45. 0/5 modernize test styleTom Grennan, Mar 1, 2012
  46. 1/5 t6300 (for-each-ref): modernize styleTom Grennan, Mar 1, 2012
  47. Johannes SixtMar 1, 2012
  48. Tom GrennanMar 1, 2012
  49. 2/5 t5512 (ls-remote): modernize styleTom Grennan, Mar 1, 2012
  50. Thomas RastMar 1, 2012
  51. 3/5 t3200 (branch): modernize styleTom Grennan, Mar 1, 2012
  52. 4/5 t0040 (parse-options): modernize styleTom Grennan, Mar 1, 2012
  53. 5/5 t7004 (tag): modernize styleTom Grennan, Mar 1, 2012
  54. 101/105 t6300 (for-each-ref): modernize styleTom Grennan, Mar 1, 2012
  55. Junio C HamanoMar 1, 2012
  56. Tom GrennanMar 1, 2012
  57. Junio C HamanoMar 1, 2012
  58. Tom GrennanMar 1, 2012
  59. Tom GrennanMar 1, 2012
  60. Thomas RastMar 1, 2012
  61. Tom GrennanMar 1, 2012
  62. 102/105 t5512 (ls-remote): modernize styleTom Grennan, Mar 1, 2012
  63. 103/105 t3200 (branch): modernize styleTom Grennan, Mar 1, 2012
  64. 104/105 t0040 (parse-options): modernize styleTom Grennan, Mar 1, 2012
  65. 105/105 t7004 (tag): modernize styleTom Grennan, Mar 1, 2012
  66. 0/5 modernize test styleTom Grennan, Mar 3, 2012
  67. 1/5 t7004 (tag): modernize styleTom Grennan, Mar 3, 2012
  68. Johannes SixtMar 3, 2012
  69. 2/5 t5512 (ls-remote): modernize styleTom Grennan, Mar 3, 2012
  70. Junio C HamanoMar 3, 2012
  71. Tom GrennanMar 3, 2012
  72. 3/5 t3200 (branch): modernize styleTom Grennan, Mar 3, 2012
  73. 4/5 t0040 (parse-options): modernize styleTom Grennan, Mar 3, 2012
  74. 5/5 t6300 (for-each-ref): modernize styleTom Grennan, Mar 3, 2012
  75. 101/105 t7004 (tag): modernize styleTom Grennan, Mar 3, 2012
  76. 102/105 t5512 (ls-remote): modernize styleTom Grennan, Mar 3, 2012
  77. 103/105 t3200 (branch): modernize styleTom Grennan, Mar 3, 2012
  78. 104/105 t0040 (parse-options): modernize styleTom Grennan, Mar 3, 2012
  79. 105/105 t6300 (for-each-ref): modernize styleTom Grennan, Mar 3, 2012
  80. Junio C HamanoMar 3, 2012
  81. Tom GrennanMar 3, 2012
  82. 4/5 branch --exclude optionTom Grennan, Feb 22, 2012
  83. 5/5 for-each-ref --exclude optionTom Grennan, Feb 22, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.