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

Re: [PATCH 2/2] t4205: indent here documents

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 27, 2016, 19:28 UTC
Message-ID
<xmqqbn1ix4mp.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20160727185523.GB6626@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 11 quoted lines
> Our usual style in the test scripts is to indent here
> documents with tabs, and use "<<-" to strip the tabs. The
> result is easier to read.
>
> This old test script did not do so in its inception, and
> further tests added onto it followed the local style. Let's
> bring it in line with our usual style.
>
> Some of the tests actually care quite a bit about
> whitespace, but none of them do so at the beginning of the
> line (because they things like qz_to_tab_space to avoid
I'll do s/they things/they use things/ here while queuing.
Thanks.
Show 583 quoted lines
> depending on the literal whitespace), so we can do a fairly
> mechanical conversion.
>
> Most of the here-docs also use interpolation, so they have
> been left as "<<-EOF". In a few cases, though, where
> interpolation was not in use, I've converted them to
> "<<-\EOF" to match our usual "don't interpolate unless you
> need to" style.
>
> Signed-off-by: Jeff King <peff@peff.net>
> ---
>  t/t4205-log-pretty-formats.sh | 392 +++++++++++++++++++++---------------------
>  1 file changed, 196 insertions(+), 196 deletions(-)
>
> diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
> index d6518fa..f5435fd 100755
> --- a/t/t4205-log-pretty-formats.sh
> +++ b/t/t4205-log-pretty-formats.sh
> @@ -145,199 +145,199 @@ test_expect_success 'setup more commits' '
>  
>  test_expect_success 'left alignment formatting' '
>  	git log --pretty="tformat:%<(40)%s" >actual &&
> -	qz_to_tab_space <<EOF >expected &&
> -message two                            Z
> -message one                            Z
> -add bar                                Z
> -$(commit_msg)                    Z
> -EOF
> +	qz_to_tab_space <<-EOF >expected &&
> +	message two                            Z
> +	message one                            Z
> +	add bar                                Z
> +	$(commit_msg)                    Z
> +	EOF
>  	test_cmp expected actual
>  '
>  
>  test_expect_success 'left alignment formatting. i18n.logOutputEncoding' '
>  	git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%<(40)%s" >actual &&
> -	qz_to_tab_space <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
> -message two                            Z
> -message one                            Z
> -add bar                                Z
> -$(commit_msg)                    Z
> -EOF
> +	qz_to_tab_space <<-EOF | iconv -f utf-8 -t $test_encoding >expected &&
> +	message two                            Z
> +	message one                            Z
> +	add bar                                Z
> +	$(commit_msg)                    Z
> +	EOF
>  	test_cmp expected actual
>  '
>  
>  test_expect_success 'left alignment formatting at the nth column' '
>  	git log --pretty="tformat:%h %<|(40)%s" >actual &&
> -	qz_to_tab_space <<EOF >expected &&
> -$head1 message two                    Z
> -$head2 message one                    Z
> -$head3 add bar                        Z
> -$head4 $(commit_msg)            Z
> -EOF
> +	qz_to_tab_space <<-EOF >expected &&
> +	$head1 message two                    Z
> +	$head2 message one                    Z
> +	$head3 add bar                        Z
> +	$head4 $(commit_msg)            Z
> +	EOF
>  	test_cmp expected actual
>  '
>  
>  test_expect_success 'left alignment formatting at the nth column' '
>  	COLUMNS=50 git log --pretty="tformat:%h %<|(-10)%s" >actual &&
> -	qz_to_tab_space <<EOF >expected &&
> -$head1 message two                    Z
> -$head2 message one                    Z
> -$head3 add bar                        Z
> -$head4 $(commit_msg)            Z
> -EOF
> +	qz_to_tab_space <<-EOF >expected &&
> +	$head1 message two                    Z
> +	$head2 message one                    Z
> +	$head3 add bar                        Z
> +	$head4 $(commit_msg)            Z
> +	EOF
>  	test_cmp expected actual
>  '
>  
>  test_expect_success 'left alignment formatting at the nth column. i18n.logOutputEncoding' '
>  	git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%h %<|(40)%s" >actual &&
> -	qz_to_tab_space <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
> -$head1 message two                    Z
> -$head2 message one                    Z
> -$head3 add bar                        Z
> -$head4 $(commit_msg)            Z
> -EOF
> +	qz_to_tab_space <<-EOF | iconv -f utf-8 -t $test_encoding >expected &&
> +	$head1 message two                    Z
> +	$head2 message one                    Z
> +	$head3 add bar                        Z
> +	$head4 $(commit_msg)            Z
> +	EOF
>  	test_cmp expected actual
>  '
>  
>  test_expect_success 'left alignment formatting with no padding' '
>  	git log --pretty="tformat:%<(1)%s" >actual &&
> -	cat <<EOF >expected &&
> -message two
> -message one
> -add bar
> -$(commit_msg)
> -EOF
> +	cat <<-EOF >expected &&
> +	message two
> +	message one
> +	add bar
> +	$(commit_msg)
> +	EOF
>  	test_cmp expected actual
>  '
>  
>  test_expect_success 'left alignment formatting with no padding. i18n.logOutputEncoding' '
>  	git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%<(1)%s" >actual &&
> -	cat <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
> -message two
> -message one
> -add bar
> -$(commit_msg)
> -EOF
> +	cat <<-EOF | iconv -f utf-8 -t $test_encoding >expected &&
> +	message two
> +	message one
> +	add bar
> +	$(commit_msg)
> +	EOF
>  	test_cmp expected actual
>  '
>  
>  test_expect_success 'left alignment formatting with trunc' '
>  	git log --pretty="tformat:%<(10,trunc)%s" >actual &&
> -	qz_to_tab_space <<EOF >expected &&
> -message ..
> -message ..
> -add bar  Z
> -initial...
> -EOF
> +	qz_to_tab_space <<-\EOF >expected &&
> +	message ..
> +	message ..
> +	add bar  Z
> +	initial...
> +	EOF
>  	test_cmp expected actual
>  '
>  
>  test_expect_success 'left alignment formatting with trunc. i18n.logOutputEncoding' '
>  	git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%<(10,trunc)%s" >actual &&
> -	qz_to_tab_space <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
> -message ..
> -message ..
> -add bar  Z
> -initial...
> -EOF
> +	qz_to_tab_space <<-\EOF | iconv -f utf-8 -t $test_encoding >expected &&
> +	message ..
> +	message ..
> +	add bar  Z
> +	initial...
> +	EOF
>  	test_cmp expected actual
>  '
>  
>  test_expect_success 'left alignment formatting with ltrunc' '
>  	git log --pretty="tformat:%<(10,ltrunc)%s" >actual &&
> -	qz_to_tab_space <<EOF >expected &&
> -..sage two
> -..sage one
> -add bar  Z
> -..${sample_utf8_part}lich
> -EOF
> +	qz_to_tab_space <<-EOF >expected &&
> +	..sage two
> +	..sage one
> +	add bar  Z
> +	..${sample_utf8_part}lich
> +	EOF
>  	test_cmp expected actual
>  '
>  
>  test_expect_success 'left alignment formatting with ltrunc. i18n.logOutputEncoding' '
>  	git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%<(10,ltrunc)%s" >actual &&
> -	qz_to_tab_space <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
> -..sage two
> -..sage one
> -add bar  Z
> -..${sample_utf8_part}lich
> -EOF
> +	qz_to_tab_space <<-EOF | iconv -f utf-8 -t $test_encoding >expected &&
> +	..sage two
> +	..sage one
> +	add bar  Z
> +	..${sample_utf8_part}lich
> +	EOF
>  	test_cmp expected actual
>  '
>  
>  test_expect_success 'left alignment formatting with mtrunc' '
>  	git log --pretty="tformat:%<(10,mtrunc)%s" >actual &&
> -	qz_to_tab_space <<EOF >expected &&
> -mess.. two
> -mess.. one
> -add bar  Z
> -init..lich
> -EOF
> +	qz_to_tab_space <<-\EOF >expected &&
> +	mess.. two
> +	mess.. one
> +	add bar  Z
> +	init..lich
> +	EOF
>  	test_cmp expected actual
>  '
>  
>  test_expect_success 'left alignment formatting with mtrunc. i18n.logOutputEncoding' '
>  	git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%<(10,mtrunc)%s" >actual &&
> -	qz_to_tab_space <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
> -mess.. two
> -mess.. one
> -add bar  Z
> -init..lich
> -EOF
> +	qz_to_tab_space <<-\EOF | iconv -f utf-8 -t $test_encoding >expected &&
> +	mess.. two
> +	mess.. one
> +	add bar  Z
> +	init..lich
> +	EOF
>  	test_cmp expected actual
>  '
>  
>  test_expect_success 'right alignment formatting' '
>  	git log --pretty="tformat:%>(40)%s" >actual &&
> -	qz_to_tab_space <<EOF >expected &&
> -Z                            message two
> -Z                            message one
> -Z                                add bar
> -Z                    $(commit_msg)
> -EOF
> +	qz_to_tab_space <<-EOF >expected &&
> +	Z                            message two
> +	Z                            message one
> +	Z                                add bar
> +	Z                    $(commit_msg)
> +	EOF
>  	test_cmp expected actual
>  '
>  
>  test_expect_success 'right alignment formatting. i18n.logOutputEncoding' '
>  	git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%>(40)%s" >actual &&
> -	qz_to_tab_space <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
> -Z                            message two
> -Z                            message one
> -Z                                add bar
> -Z                    $(commit_msg)
> -EOF
> +	qz_to_tab_space <<-EOF | iconv -f utf-8 -t $test_encoding >expected &&
> +	Z                            message two
> +	Z                            message one
> +	Z                                add bar
> +	Z                    $(commit_msg)
> +	EOF
>  	test_cmp expected actual
>  '
>  
>  test_expect_success 'right alignment formatting at the nth column' '
>  	git log --pretty="tformat:%h %>|(40)%s" >actual &&
> -	qz_to_tab_space <<EOF >expected &&
> -$head1                      message two
> -$head2                      message one
> -$head3                          add bar
> -$head4              $(commit_msg)
> -EOF
> +	qz_to_tab_space <<-EOF >expected &&
> +	$head1                      message two
> +	$head2                      message one
> +	$head3                          add bar
> +	$head4              $(commit_msg)
> +	EOF
>  	test_cmp expected actual
>  '
>  
>  test_expect_success 'right alignment formatting at the nth column' '
>  	COLUMNS=50 git log --pretty="tformat:%h %>|(-10)%s" >actual &&
> -	qz_to_tab_space <<EOF >expected &&
> -$head1                      message two
> -$head2                      message one
> -$head3                          add bar
> -$head4              $(commit_msg)
> -EOF
> +	qz_to_tab_space <<-EOF >expected &&
> +	$head1                      message two
> +	$head2                      message one
> +	$head3                          add bar
> +	$head4              $(commit_msg)
> +	EOF
>  	test_cmp expected actual
>  '
>  
>  test_expect_success 'right alignment formatting at the nth column. i18n.logOutputEncoding' '
>  	git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%h %>|(40)%s" >actual &&
> -	qz_to_tab_space <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
> -$head1                      message two
> -$head2                      message one
> -$head3                          add bar
> -$head4              $(commit_msg)
> -EOF
> +	qz_to_tab_space <<-EOF | iconv -f utf-8 -t $test_encoding >expected &&
> +	$head1                      message two
> +	$head2                      message one
> +	$head3                          add bar
> +	$head4              $(commit_msg)
> +	EOF
>  	test_cmp expected actual
>  '
>  
> @@ -345,110 +345,110 @@ EOF
>  # as in previous test.
>  test_expect_success 'right alignment formatting at the nth column with --graph. i18n.logOutputEncoding' '
>  	git -c i18n.logOutputEncoding=$test_encoding log --graph --pretty="tformat:%h %>|(40)%s" >actual &&
> -	iconv -f utf-8 -t $test_encoding >expected <<EOF&&
> -* $head1                    message two
> -* $head2                    message one
> -* $head3                        add bar
> -* $head4            $(commit_msg)
> -EOF
> +	iconv -f utf-8 -t $test_encoding >expected <<-EOF &&
> +	* $head1                    message two
> +	* $head2                    message one
> +	* $head3                        add bar
> +	* $head4            $(commit_msg)
> +	EOF
>  	test_cmp expected actual
>  '
>  
>  test_expect_success 'right alignment formatting with no padding' '
>  	git log --pretty="tformat:%>(1)%s" >actual &&
> -	cat <<EOF >expected &&
> -message two
> -message one
> -add bar
> -$(commit_msg)
> -EOF
> +	cat <<-EOF >expected &&
> +	message two
> +	message one
> +	add bar
> +	$(commit_msg)
> +	EOF
>  	test_cmp expected actual
>  '
>  
>  test_expect_success 'right alignment formatting with no padding and with --graph' '
>  	git log --graph --pretty="tformat:%>(1)%s" >actual &&
> -	cat <<EOF >expected &&
> -* message two
> -* message one
> -* add bar
> -* $(commit_msg)
> -EOF
> +	cat <<-EOF >expected &&
> +	* message two
> +	* message one
> +	* add bar
> +	* $(commit_msg)
> +	EOF
>  	test_cmp expected actual
>  '
>  
>  test_expect_success 'right alignment formatting with no padding. i18n.logOutputEncoding' '
>  	git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%>(1)%s" >actual &&
> -	cat <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
> -message two
> -message one
> -add bar
> -$(commit_msg)
> -EOF
> +	cat <<-EOF | iconv -f utf-8 -t $test_encoding >expected &&
> +	message two
> +	message one
> +	add bar
> +	$(commit_msg)
> +	EOF
>  	test_cmp expected actual
>  '
>  
>  test_expect_success 'center alignment formatting' '
>  	git log --pretty="tformat:%><(40)%s" >actual &&
> -	qz_to_tab_space <<EOF >expected &&
> -Z             message two              Z
> -Z             message one              Z
> -Z               add bar                Z
> -Z         $(commit_msg)          Z
> -EOF
> +	qz_to_tab_space <<-EOF >expected &&
> +	Z             message two              Z
> +	Z             message one              Z
> +	Z               add bar                Z
> +	Z         $(commit_msg)          Z
> +	EOF
>  	test_cmp expected actual
>  '
>  
>  test_expect_success 'center alignment formatting. i18n.logOutputEncoding' '
>  	git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%><(40)%s" >actual &&
> -	qz_to_tab_space <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
> -Z             message two              Z
> -Z             message one              Z
> -Z               add bar                Z
> -Z         $(commit_msg)          Z
> -EOF
> +	qz_to_tab_space <<-EOF | iconv -f utf-8 -t $test_encoding >expected &&
> +	Z             message two              Z
> +	Z             message one              Z
> +	Z               add bar                Z
> +	Z         $(commit_msg)          Z
> +	EOF
>  	test_cmp expected actual
>  '
>  test_expect_success 'center alignment formatting at the nth column' '
>  	git log --pretty="tformat:%h %><|(40)%s" >actual &&
> -	qz_to_tab_space <<EOF >expected &&
> -$head1           message two          Z
> -$head2           message one          Z
> -$head3             add bar            Z
> -$head4       $(commit_msg)      Z
> -EOF
> +	qz_to_tab_space <<-EOF >expected &&
> +	$head1           message two          Z
> +	$head2           message one          Z
> +	$head3             add bar            Z
> +	$head4       $(commit_msg)      Z
> +	EOF
>  	test_cmp expected actual
>  '
>  
>  test_expect_success 'center alignment formatting at the nth column' '
>  	COLUMNS=70 git log --pretty="tformat:%h %><|(-30)%s" >actual &&
> -	qz_to_tab_space <<EOF >expected &&
> -$head1           message two          Z
> -$head2           message one          Z
> -$head3             add bar            Z
> -$head4       $(commit_msg)      Z
> -EOF
> +	qz_to_tab_space <<-EOF >expected &&
> +	$head1           message two          Z
> +	$head2           message one          Z
> +	$head3             add bar            Z
> +	$head4       $(commit_msg)      Z
> +	EOF
>  	test_cmp expected actual
>  '
>  
>  test_expect_success 'center alignment formatting at the nth column. i18n.logOutputEncoding' '
>  	git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%h %><|(40)%s" >actual &&
> -	qz_to_tab_space <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
> -$head1           message two          Z
> -$head2           message one          Z
> -$head3             add bar            Z
> -$head4       $(commit_msg)      Z
> -EOF
> +	qz_to_tab_space <<-EOF | iconv -f utf-8 -t $test_encoding >expected &&
> +	$head1           message two          Z
> +	$head2           message one          Z
> +	$head3             add bar            Z
> +	$head4       $(commit_msg)      Z
> +	EOF
>  	test_cmp expected actual
>  '
>  
>  test_expect_success 'center alignment formatting with no padding' '
>  	git log --pretty="tformat:%><(1)%s" >actual &&
> -	cat <<EOF >expected &&
> -message two
> -message one
> -add bar
> -$(commit_msg)
> -EOF
> +	cat <<-EOF >expected &&
> +	message two
> +	message one
> +	add bar
> +	$(commit_msg)
> +	EOF
>  	test_cmp expected actual
>  '
>  
> @@ -457,34 +457,34 @@ EOF
>  old_head1=$(git rev-parse --verify HEAD~0)
>  test_expect_success 'center alignment formatting with no padding. i18n.logOutputEncoding' '
>  	git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%><(1)%s" >actual &&
> -	cat <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
> -message two
> -message one
> -add bar
> -$(commit_msg)
> -EOF
> +	cat <<-EOF | iconv -f utf-8 -t $test_encoding >expected &&
> +	message two
> +	message one
> +	add bar
> +	$(commit_msg)
> +	EOF
>  	test_cmp expected actual
>  '
>  
>  test_expect_success 'left/right alignment formatting with stealing' '
>  	git commit --amend -m short --author "long long long <long@me.com>" &&
>  	git log --pretty="tformat:%<(10,trunc)%s%>>(10,ltrunc)% an" >actual &&
> -	cat <<EOF >expected &&
> -short long  long long
> -message ..   A U Thor
> -add bar      A U Thor
> -initial...   A U Thor
> -EOF
> +	cat <<-\EOF >expected &&
> +	short long  long long
> +	message ..   A U Thor
> +	add bar      A U Thor
> +	initial...   A U Thor
> +	EOF
>  	test_cmp expected actual
>  '
>  test_expect_success 'left/right alignment formatting with stealing. i18n.logOutputEncoding' '
>  	git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%<(10,trunc)%s%>>(10,ltrunc)% an" >actual &&
> -	cat <<EOF | iconv -f utf-8 -t $test_encoding >expected &&
> -short long  long long
> -message ..   A U Thor
> -add bar      A U Thor
> -initial...   A U Thor
> -EOF
> +	cat <<-\EOF | iconv -f utf-8 -t $test_encoding >expected &&
> +	short long  long long
> +	message ..   A U Thor
> +	add bar      A U Thor
> +	initial...   A U Thor
> +	EOF
>  	test_cmp expected actual
>  '
>  
> @@ -515,22 +515,22 @@ test_expect_success 'log decoration properly follows tag chain' '
>  	git tag -d tag1 &&
>  	git commit --amend -m shorter &&
>  	git log --no-walk --tags --pretty="%H %d" --decorate=full >actual &&
> -	cat <<EOF >expected &&
> -$head1  (tag: refs/tags/tag2)
> -$head2  (tag: refs/tags/message-one)
> -$old_head1  (tag: refs/tags/message-two)
> -EOF
> +	cat <<-EOF >expected &&
> +	$head1  (tag: refs/tags/tag2)
> +	$head2  (tag: refs/tags/message-one)
> +	$old_head1  (tag: refs/tags/message-two)
> +	EOF
>  	sort actual >actual1 &&
>  	test_cmp expected actual1
>  '
>  
>  test_expect_success 'clean log decoration' '
>  	git log --no-walk --tags --pretty="%H %D" --decorate=full >actual &&
> -	cat >expected <<EOF &&
> -$head1 tag: refs/tags/tag2
> -$head2 tag: refs/tags/message-one
> -$old_head1 tag: refs/tags/message-two
> -EOF
> +	cat >expected <<-EOF &&
> +	$head1 tag: refs/tags/tag2
> +	$head2 tag: refs/tags/message-one
> +	$old_head1 tag: refs/tags/message-two
> +	EOF
>  	sort actual >actual1 &&
>  	test_cmp expected actual1
>  '
Previous: Jeff KingNext: Jeff King
Message 17 of 20 in “pretty format string support for reflog times”
  1. pretty format string support for reflog timesPhil Pennock, Jul 27, 2016
  2. Phil PennockJul 27, 2016
  3. Jeff KingJul 27, 2016
  4. Phil PennockJul 27, 2016
  5. Junio C HamanoJul 27, 2016
  6. Jeff KingJul 27, 2016
  7. Junio C HamanoJul 27, 2016
  8. Jeff KingJul 27, 2016
  9. Junio C HamanoJul 27, 2016
  10. Jeff KingJul 27, 2016
  11. Jeff KingJul 27, 2016
  12. Phil PennockJul 27, 2016
  13. Jeff KingJul 27, 2016
  14. 0/2 t4205 style fixesJeff King, Jul 27, 2016
  15. 1/2 t4205: drop top-level &&-chainingJeff King, Jul 27, 2016
  16. 2/2 t4205: indent here documentsJeff King, Jul 27, 2016
  17. Junio C HamanoJul 27, 2016
  18. Jeff KingJul 27, 2016
  19. Phil PennockJul 27, 2016
  20. Jeff KingJul 27, 2016

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.