git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH 0/3] suppress trailing whitespace on empty "notes" lines
@ 2021-08-30  7:21 Eric Sunshine
  2021-08-30  7:21 ` [PATCH 1/3] t3301: tolerate minor notes-related presentation changes Eric Sunshine
                   ` (3 more replies)
  0 siblings, 4 replies; 25+ messages in thread
From: Eric Sunshine @ 2021-08-30  7:21 UTC (permalink / raw)
  To: git; +Cc: Eric Sunshine

This patch series fixes a problem in which `git format-patch --notes`
and `git log` unconditionally indent _all_ "notes" lines, including
those which are empty, which ends up leaving (unwanted) trailing
whitespace on the previously empty lines. The first couple patches
adjust some existing notes-related tests -- which undesirably hard-code
those indented blank notes lines -- to be less brittle since they would
otherwise break by the change made in the final patch which fixes the
actual problem.

Eric Sunshine (3):
  t3301: tolerate minor notes-related presentation changes
  t3303/t9301: make `notes` tests less brittle
  notes: don't indent empty lines

 notes.c                      |   2 +-
 t/t3301-notes.sh             | 321 ++++++++++++++++++-----------------
 t/t3303-notes-subtrees.sh    |  13 +-
 t/t4014-format-patch.sh      |  17 ++
 t/t9301-fast-import-notes.sh |  36 ++--
 5 files changed, 207 insertions(+), 182 deletions(-)

-- 
2.33.0.153.gba50c8fa24


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

* [PATCH 1/3] t3301: tolerate minor notes-related presentation changes
  2021-08-30  7:21 [PATCH 0/3] suppress trailing whitespace on empty "notes" lines Eric Sunshine
@ 2021-08-30  7:21 ` Eric Sunshine
  2021-08-30 17:09   ` Junio C Hamano
  2021-08-30  7:21 ` [PATCH 2/3] t3303/t9301: make `notes` tests less brittle Eric Sunshine
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 25+ messages in thread
From: Eric Sunshine @ 2021-08-30  7:21 UTC (permalink / raw)
  To: git; +Cc: Eric Sunshine

These tests care about whether intended notes-related functionality
occurred and that `git log` presents the notes in the expected fashion
(or, in some cases, that `git log` suppresses the notes). However, the
tests hard-code the precise indentation of notes by the default `git
log` output, which makes them somewhat brittle since they won't be able
to tolerate even minor changes to the presentation. Make the tests a bit
more robust by ignoring indentation.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
---
 t/t3301-notes.sh | 321 ++++++++++++++++++++++++-----------------------
 1 file changed, 162 insertions(+), 159 deletions(-)

diff --git a/t/t3301-notes.sh b/t/t3301-notes.sh
index d742be8840..955b2670a7 100755
--- a/t/t3301-notes.sh
+++ b/t/t3301-notes.sh
@@ -7,6 +7,11 @@ test_description='Test commit notes'
 
 . ./test-lib.sh
 
+lognotes () {
+	git log "$@" >lognotes.out &&
+	sed 's/^[ 	]*//' lognotes.out
+}
+
 write_script fake_editor <<\EOF
 echo "$MSG" >"$1"
 echo "$MSG" >&2
@@ -14,8 +19,6 @@ EOF
 GIT_EDITOR=./fake_editor
 export GIT_EDITOR
 
-indent="    "
-
 test_expect_success 'cannot annotate non-existing HEAD' '
 	test_must_fail env MSG=3 git notes add
 '
@@ -158,14 +161,14 @@ test_expect_success 'show notes' '
 		Author: A U Thor <author@example.com>
 		Date:   Thu Apr 7 15:14:13 2005 -0700
 
-		${indent}2nd
+		2nd
 
 		Notes:
-		${indent}b1
+		b1
 	EOF
 	git cat-file commit HEAD >commits &&
 	! grep b1 commits &&
-	git log -1 >actual &&
+	lognotes -1 >actual &&
 	test_cmp expect actual
 '
 
@@ -178,16 +181,16 @@ test_expect_success 'show multi-line notes' '
 		Author: A U Thor <author@example.com>
 		Date:   Thu Apr 7 15:15:13 2005 -0700
 
-		${indent}3rd
+		3rd
 
 		Notes:
-		${indent}b3
-		${indent}c3c3c3c3
-		${indent}d3d3d3
+		b3
+		c3c3c3c3
+		d3d3d3
 
 	EOF
 	cat expect >>expect-multiline &&
-	git log -2 >actual &&
+	lognotes -2 >actual &&
 	test_cmp expect-multiline actual
 '
 
@@ -201,21 +204,21 @@ test_expect_success 'show -F notes' '
 		Author: A U Thor <author@example.com>
 		Date:   Thu Apr 7 15:16:13 2005 -0700
 
-		${indent}4th
+		4th
 
 		Notes:
-		${indent}xyzzy
+		xyzzy
 
 	EOF
 	cat expect-multiline >>expect-F &&
-	git log -3 >actual &&
+	lognotes -3 >actual &&
 	test_cmp expect-F actual
 '
 
 test_expect_success 'Re-adding -F notes without -f fails' '
 	echo "zyxxy" >note5 &&
 	test_must_fail git notes add -F note5 &&
-	git log -3 >actual &&
+	lognotes -3 >actual &&
 	test_cmp expect-F actual
 '
 
@@ -230,9 +233,9 @@ test_expect_success 'git log --pretty=raw does not show notes' '
 		author A U Thor <author@example.com> 1112912173 -0700
 		committer C O Mitter <committer@example.com> 1112912173 -0700
 
-		${indent}4th
+		4th
 	EOF
-	git log -1 --pretty=raw >actual &&
+	lognotes -1 --pretty=raw >actual &&
 	test_cmp expect actual
 '
 
@@ -240,14 +243,14 @@ test_expect_success 'git log --show-notes' '
 	cat >>expect <<-EOF &&
 
 	Notes:
-	${indent}xyzzy
+	xyzzy
 	EOF
-	git log -1 --pretty=raw --show-notes >actual &&
+	lognotes -1 --pretty=raw --show-notes >actual &&
 	test_cmp expect actual
 '
 
 test_expect_success 'git log --no-notes' '
-	git log -1 --no-notes >actual &&
+	lognotes -1 --no-notes >actual &&
 	! grep xyzzy actual
 '
 
@@ -280,25 +283,25 @@ test_expect_success 'setup alternate notes ref' '
 '
 
 test_expect_success 'git log --notes shows default notes' '
-	git log -1 --notes >actual &&
+	lognotes -1 --notes >actual &&
 	grep xyzzy actual &&
 	! grep alternate actual
 '
 
 test_expect_success 'git log --notes=X shows only X' '
-	git log -1 --notes=alternate >actual &&
+	lognotes -1 --notes=alternate >actual &&
 	! grep xyzzy actual &&
 	grep alternate actual
 '
 
 test_expect_success 'git log --notes --notes=X shows both' '
-	git log -1 --notes --notes=alternate >actual &&
+	lognotes -1 --notes --notes=alternate >actual &&
 	grep xyzzy actual &&
 	grep alternate actual
 '
 
 test_expect_success 'git log --no-notes resets default state' '
-	git log -1 --notes --notes=alternate \
+	lognotes -1 --notes --notes=alternate \
 		--no-notes --notes=alternate \
 		>actual &&
 	! grep xyzzy actual &&
@@ -306,7 +309,7 @@ test_expect_success 'git log --no-notes resets default state' '
 '
 
 test_expect_success 'git log --no-notes resets ref list' '
-	git log -1 --notes --notes=alternate \
+	lognotes -1 --notes --notes=alternate \
 		--no-notes --notes \
 		>actual &&
 	grep xyzzy actual &&
@@ -322,18 +325,18 @@ test_expect_success 'show -m notes' '
 		Author: A U Thor <author@example.com>
 		Date:   Thu Apr 7 15:17:13 2005 -0700
 
-		${indent}5th
+		5th
 
 		Notes:
-		${indent}spam
-		${indent}
-		${indent}foo
-		${indent}bar
-		${indent}baz
+		spam
+
+		foo
+		bar
+		baz
 
 	EOF
 	cat expect-F >>expect-m &&
-	git log -4 >actual &&
+	lognotes -4 >actual &&
 	test_cmp expect-m actual
 '
 
@@ -345,18 +348,18 @@ test_expect_success 'remove note with add -f -F /dev/null' '
 		Author: A U Thor <author@example.com>
 		Date:   Thu Apr 7 15:17:13 2005 -0700
 
-		${indent}5th
+		5th
 
 	EOF
 	cat expect-F >>expect-rm-F &&
-	git log -4 >actual &&
+	lognotes -4 >actual &&
 	test_cmp expect-rm-F actual &&
 	test_must_fail git notes show
 '
 
 test_expect_success 'do not create empty note with -m ""' '
 	git notes add -m "" &&
-	git log -4 >actual &&
+	lognotes -4 >actual &&
 	test_cmp expect-rm-F actual &&
 	test_must_fail git notes show
 '
@@ -390,17 +393,17 @@ test_expect_success 'remove note with "git notes remove"' '
 		Author: A U Thor <author@example.com>
 		Date:   Thu Apr 7 15:17:13 2005 -0700
 
-		${indent}5th
+		5th
 
 		commit $parent
 		Author: A U Thor <author@example.com>
 		Date:   Thu Apr 7 15:16:13 2005 -0700
 
-		${indent}4th
+		4th
 
 	EOF
 	cat expect-multiline >>expect-rm-remove &&
-	git log -4 >actual &&
+	lognotes -4 >actual &&
 	test_cmp expect-rm-remove actual &&
 	test_must_fail git notes show HEAD^
 '
@@ -570,35 +573,35 @@ test_expect_success 'create other note on a different notes ref (setup)' '
 		Author: A U Thor <author@example.com>
 		Date:   Thu Apr 7 15:18:13 2005 -0700
 
-		${indent}6th
+		6th
 	EOF
 	cp expect-not-other expect-other &&
 	cat >>expect-other <<-EOF
 
 		Notes (other):
-		${indent}other note
+		other note
 	EOF
 '
 
 test_expect_success 'Do not show note on other ref by default' '
-	git log -1 >actual &&
+	lognotes -1 >actual &&
 	test_cmp expect-not-other actual
 '
 
 test_expect_success 'Do show note when ref is given in GIT_NOTES_REF' '
-	GIT_NOTES_REF="refs/notes/other" git log -1 >actual &&
+	test_env GIT_NOTES_REF="refs/notes/other" lognotes -1 >actual &&
 	test_cmp expect-other actual
 '
 
 test_expect_success 'Do show note when ref is given in core.notesRef config' '
 	test_config core.notesRef "refs/notes/other" &&
-	git log -1 >actual &&
+	lognotes -1 >actual &&
 	test_cmp expect-other actual
 '
 
 test_expect_success 'Do not show note when core.notesRef is overridden' '
 	test_config core.notesRef "refs/notes/other" &&
-	GIT_NOTES_REF="refs/notes/wrong" git log -1 >actual &&
+	test_env GIT_NOTES_REF="refs/notes/wrong" lognotes -1 >actual &&
 	test_cmp expect-not-other actual
 '
 
@@ -610,36 +613,36 @@ test_expect_success 'Show all notes when notes.displayRef=refs/notes/*' '
 		Author: A U Thor <author@example.com>
 		Date:   Thu Apr 7 15:18:13 2005 -0700
 
-		${indent}6th
+		6th
 
 		Notes:
-		${indent}order test
+		order test
 
 		Notes (other):
-		${indent}other note
+		other note
 
 		commit $parent
 		Author: A U Thor <author@example.com>
 		Date:   Thu Apr 7 15:17:13 2005 -0700
 
-		${indent}5th
+		5th
 
 		Notes:
-		${indent}replacement for deleted note
+		replacement for deleted note
 	EOF
 	GIT_NOTES_REF=refs/notes/commits git notes add \
 		-m"replacement for deleted note" HEAD^ &&
 	GIT_NOTES_REF=refs/notes/commits git notes add -m"order test" &&
 	test_unconfig core.notesRef &&
 	test_config notes.displayRef "refs/notes/*" &&
-	git log -2 >actual &&
+	lognotes -2 >actual &&
 	test_cmp expect-both actual
 '
 
 test_expect_success 'core.notesRef is implicitly in notes.displayRef' '
 	test_config core.notesRef refs/notes/commits &&
 	test_config notes.displayRef refs/notes/other &&
-	git log -2 >actual &&
+	lognotes -2 >actual &&
 	test_cmp expect-both actual
 '
 
@@ -647,7 +650,7 @@ test_expect_success 'notes.displayRef can be given more than once' '
 	test_unconfig core.notesRef &&
 	test_config notes.displayRef refs/notes/commits &&
 	git config --add notes.displayRef refs/notes/other &&
-	git log -2 >actual &&
+	lognotes -2 >actual &&
 	test_cmp expect-both actual
 '
 
@@ -658,17 +661,17 @@ test_expect_success 'notes.displayRef respects order' '
 		Author: A U Thor <author@example.com>
 		Date:   Thu Apr 7 15:18:13 2005 -0700
 
-		${indent}6th
+		6th
 
 		Notes (other):
-		${indent}other note
+		other note
 
 		Notes:
-		${indent}order test
+		order test
 	EOF
 	test_config core.notesRef refs/notes/other &&
 	test_config notes.displayRef refs/notes/commits &&
-	git log -1 >actual &&
+	lognotes -1 >actual &&
 	test_cmp expect-both-reversed actual
 '
 
@@ -678,8 +681,8 @@ test_expect_success 'notes.displayRef with no value handled gracefully' '
 '
 
 test_expect_success 'GIT_NOTES_DISPLAY_REF works' '
-	GIT_NOTES_DISPLAY_REF=refs/notes/commits:refs/notes/other \
-		git log -2 >actual &&
+	test_env GIT_NOTES_DISPLAY_REF=refs/notes/commits:refs/notes/other \
+		lognotes -2 >actual &&
 	test_cmp expect-both actual
 '
 
@@ -691,21 +694,21 @@ test_expect_success 'GIT_NOTES_DISPLAY_REF overrides config' '
 		Author: A U Thor <author@example.com>
 		Date:   Thu Apr 7 15:18:13 2005 -0700
 
-		${indent}6th
+		6th
 
 		commit $parent
 		Author: A U Thor <author@example.com>
 		Date:   Thu Apr 7 15:17:13 2005 -0700
 
-		${indent}5th
+		5th
 	EOF
 	test_config notes.displayRef "refs/notes/*" &&
-	GIT_NOTES_REF= GIT_NOTES_DISPLAY_REF= git log -2 >actual &&
+	test_env GIT_NOTES_REF= GIT_NOTES_DISPLAY_REF= lognotes -2 >actual &&
 	test_cmp expect-none actual
 '
 
 test_expect_success '--show-notes=* adds to GIT_NOTES_DISPLAY_REF' '
-	GIT_NOTES_REF= GIT_NOTES_DISPLAY_REF= git log --show-notes=* -2 >actual &&
+	test_env GIT_NOTES_REF= GIT_NOTES_DISPLAY_REF= lognotes --show-notes=* -2 >actual &&
 	test_cmp expect-both actual
 '
 
@@ -716,24 +719,24 @@ test_expect_success '--no-standard-notes' '
 		Author: A U Thor <author@example.com>
 		Date:   Thu Apr 7 15:18:13 2005 -0700
 
-		${indent}6th
+		6th
 
 		Notes:
-		${indent}order test
+		order test
 	EOF
-	git log --no-standard-notes --show-notes=commits -1 >actual &&
+	lognotes --no-standard-notes --show-notes=commits -1 >actual &&
 	test_cmp expect-commits actual
 '
 
 test_expect_success '--standard-notes' '
 	test_config notes.displayRef "refs/notes/*" &&
-	git log --no-standard-notes --show-notes=commits \
+	lognotes --no-standard-notes --show-notes=commits \
 		--standard-notes -2 >actual &&
 	test_cmp expect-both actual
 '
 
 test_expect_success '--show-notes=ref accumulates' '
-	git log --show-notes=other --show-notes=commits \
+	lognotes --show-notes=other --show-notes=commits \
 		 --no-standard-notes -1 >actual &&
 	test_cmp expect-both-reversed actual
 '
@@ -765,14 +768,14 @@ test_expect_success 'create note from other note with "git notes add -C"' '
 		Author: A U Thor <author@example.com>
 		Date:   Thu Apr 7 15:19:13 2005 -0700
 
-		${indent}7th
+		7th
 
 		Notes:
-		${indent}order test
+		order test
 	EOF
 	note=$(git notes list HEAD^) &&
 	git notes add -C $note &&
-	git log -1 >actual &&
+	lognotes -1 >actual &&
 	test_cmp expect actual &&
 	git notes list HEAD^ >expect &&
 	git notes list HEAD >actual &&
@@ -800,14 +803,14 @@ test_expect_success 'create note from blob with "git notes add -C" reuses blob i
 		Author: A U Thor <author@example.com>
 		Date:   Thu Apr 7 15:20:13 2005 -0700
 
-		${indent}8th
+		8th
 
 		Notes:
-		${indent}This is a blob object
+		This is a blob object
 	EOF
 	echo "This is a blob object" | git hash-object -w --stdin >blob &&
 	git notes add -C $(cat blob) &&
-	git log -1 >actual &&
+	lognotes -1 >actual &&
 	test_cmp expect actual &&
 	git notes list HEAD >actual &&
 	test_cmp blob actual
@@ -821,14 +824,14 @@ test_expect_success 'create note from other note with "git notes add -c"' '
 		Author: A U Thor <author@example.com>
 		Date:   Thu Apr 7 15:21:13 2005 -0700
 
-		${indent}9th
+		9th
 
 		Notes:
-		${indent}yet another note
+		yet another note
 	EOF
 	note=$(git notes list HEAD^^) &&
 	MSG="yet another note" git notes add -c $note &&
-	git log -1 >actual &&
+	lognotes -1 >actual &&
 	test_cmp expect actual
 '
 
@@ -845,16 +848,16 @@ test_expect_success 'append to note from other note with "git notes append -C"'
 		Author: A U Thor <author@example.com>
 		Date:   Thu Apr 7 15:21:13 2005 -0700
 
-		${indent}9th
+		9th
 
 		Notes:
-		${indent}yet another note
-		${indent}
-		${indent}yet another note
+		yet another note
+
+		yet another note
 	EOF
 	note=$(git notes list HEAD^) &&
 	git notes append -C $note HEAD^ &&
-	git log -1 HEAD^ >actual &&
+	lognotes -1 HEAD^ >actual &&
 	test_cmp expect actual
 '
 
@@ -865,14 +868,14 @@ test_expect_success 'create note from other note with "git notes append -c"' '
 		Author: A U Thor <author@example.com>
 		Date:   Thu Apr 7 15:22:13 2005 -0700
 
-		${indent}10th
+		10th
 
 		Notes:
-		${indent}other note
+		other note
 	EOF
 	note=$(git notes list HEAD^) &&
 	MSG="other note" git notes append -c $note &&
-	git log -1 >actual &&
+	lognotes -1 >actual &&
 	test_cmp expect actual
 '
 
@@ -883,16 +886,16 @@ test_expect_success 'append to note from other note with "git notes append -c"'
 		Author: A U Thor <author@example.com>
 		Date:   Thu Apr 7 15:22:13 2005 -0700
 
-		${indent}10th
+		10th
 
 		Notes:
-		${indent}other note
-		${indent}
-		${indent}yet another note
+		other note
+
+		yet another note
 	EOF
 	note=$(git notes list HEAD) &&
 	MSG="yet another note" git notes append -c $note &&
-	git log -1 >actual &&
+	lognotes -1 >actual &&
 	test_cmp expect actual
 '
 
@@ -903,13 +906,13 @@ test_expect_success 'copy note with "git notes copy"' '
 		Author: A U Thor <author@example.com>
 		Date:   Thu Apr 7 15:16:13 2005 -0700
 
-		${indent}4th
+		4th
 
 		Notes:
-		${indent}This is a blob object
+		This is a blob object
 	EOF
 	git notes copy 8th 4th &&
-	git log 3rd..4th >actual &&
+	lognotes 3rd..4th >actual &&
 	test_cmp expect actual &&
 	git notes list 4th >expect &&
 	git notes list 8th >actual &&
@@ -924,15 +927,15 @@ test_expect_success 'copy note with "git notes copy" with default' '
 		Author: A U Thor <author@example.com>
 		Date:   Thu Apr 7 15:23:13 2005 -0700
 
-		${indent}11th
+		11th
 
 		Notes:
-		${indent}other note
-		${indent}
-		${indent}yet another note
+		other note
+
+		yet another note
 	EOF
 	git notes copy HEAD^ &&
-	git log -1 >actual &&
+	lognotes -1 >actual &&
 	test_cmp expect actual &&
 	git notes list HEAD^ >expect &&
 	git notes list HEAD >actual &&
@@ -946,14 +949,14 @@ test_expect_success 'prevent overwrite with "git notes copy"' '
 		Author: A U Thor <author@example.com>
 		Date:   Thu Apr 7 15:23:13 2005 -0700
 
-		${indent}11th
+		11th
 
 		Notes:
-		${indent}other note
-		${indent}
-		${indent}yet another note
+		other note
+
+		yet another note
 	EOF
-	git log -1 >actual &&
+	lognotes -1 >actual &&
 	test_cmp expect actual &&
 	git notes list HEAD^ >expect &&
 	git notes list HEAD >actual &&
@@ -967,13 +970,13 @@ test_expect_success 'allow overwrite with "git notes copy -f"' '
 		Author: A U Thor <author@example.com>
 		Date:   Thu Apr 7 15:23:13 2005 -0700
 
-		${indent}11th
+		11th
 
 		Notes:
-		${indent}This is a blob object
+		This is a blob object
 	EOF
 	git notes copy -f HEAD~3 HEAD &&
-	git log -1 >actual &&
+	lognotes -1 >actual &&
 	test_cmp expect actual &&
 	git notes list HEAD~3 >expect &&
 	git notes list HEAD >actual &&
@@ -987,15 +990,15 @@ test_expect_success 'allow overwrite with "git notes copy -f" with default' '
 		Author: A U Thor <author@example.com>
 		Date:   Thu Apr 7 15:23:13 2005 -0700
 
-		${indent}11th
+		11th
 
 		Notes:
-		${indent}yet another note
-		${indent}
-		${indent}yet another note
+		yet another note
+
+		yet another note
 	EOF
 	git notes copy -f HEAD~2 &&
-	git log -1 >actual &&
+	lognotes -1 >actual &&
 	test_cmp expect actual &&
 	git notes list HEAD~2 >expect &&
 	git notes list HEAD >actual &&
@@ -1016,23 +1019,23 @@ test_expect_success 'git notes copy --stdin' '
 		Author: A U Thor <author@example.com>
 		Date:   Thu Apr 7 15:25:13 2005 -0700
 
-		${indent}13th
+		13th
 
 		Notes:
-		${indent}yet another note
-		${indent}
-		${indent}yet another note
+		yet another note
+
+		yet another note
 
 		commit $parent
 		Author: A U Thor <author@example.com>
 		Date:   Thu Apr 7 15:24:13 2005 -0700
 
-		${indent}12th
+		12th
 
 		Notes:
-		${indent}other note
-		${indent}
-		${indent}yet another note
+		other note
+
+		yet another note
 	EOF
 	from=$(git rev-parse HEAD~3) &&
 	to=$(git rev-parse HEAD^) &&
@@ -1041,7 +1044,7 @@ test_expect_success 'git notes copy --stdin' '
 	to=$(git rev-parse HEAD) &&
 	echo "$from" "$to" >>copy &&
 	git notes copy --stdin <copy &&
-	git log -2 >actual &&
+	lognotes -2 >actual &&
 	test_cmp expect actual &&
 	git notes list HEAD~2 >expect &&
 	git notes list HEAD >actual &&
@@ -1061,13 +1064,13 @@ test_expect_success 'git notes copy --for-rewrite (unconfigured)' '
 		Author: A U Thor <author@example.com>
 		Date:   Thu Apr 7 15:27:13 2005 -0700
 
-		${indent}15th
+		15th
 
 		commit $parent
 		Author: A U Thor <author@example.com>
 		Date:   Thu Apr 7 15:26:13 2005 -0700
 
-		${indent}14th
+		14th
 	EOF
 	from=$(git rev-parse HEAD~3) &&
 	to=$(git rev-parse HEAD^) &&
@@ -1076,7 +1079,7 @@ test_expect_success 'git notes copy --for-rewrite (unconfigured)' '
 	to=$(git rev-parse HEAD) &&
 	echo "$from" "$to" >>copy &&
 	git notes copy --for-rewrite=foo <copy &&
-	git log -2 >actual &&
+	lognotes -2 >actual &&
 	test_cmp expect actual
 '
 
@@ -1088,23 +1091,23 @@ test_expect_success 'git notes copy --for-rewrite (enabled)' '
 		Author: A U Thor <author@example.com>
 		Date:   Thu Apr 7 15:27:13 2005 -0700
 
-		${indent}15th
+		15th
 
 		Notes:
-		${indent}yet another note
-		${indent}
-		${indent}yet another note
+		yet another note
+
+		yet another note
 
 		commit $parent
 		Author: A U Thor <author@example.com>
 		Date:   Thu Apr 7 15:26:13 2005 -0700
 
-		${indent}14th
+		14th
 
 		Notes:
-		${indent}other note
-		${indent}
-		${indent}yet another note
+		other note
+
+		yet another note
 	EOF
 	test_config notes.rewriteMode overwrite &&
 	test_config notes.rewriteRef "refs/notes/*" &&
@@ -1115,7 +1118,7 @@ test_expect_success 'git notes copy --for-rewrite (enabled)' '
 	to=$(git rev-parse HEAD) &&
 	echo "$from" "$to" >>copy &&
 	git notes copy --for-rewrite=foo <copy &&
-	git log -2 >actual &&
+	lognotes -2 >actual &&
 	test_cmp expect actual
 '
 
@@ -1125,7 +1128,7 @@ test_expect_success 'git notes copy --for-rewrite (disabled)' '
 	to=$(git rev-parse HEAD) &&
 	echo "$from" "$to" >copy &&
 	git notes copy --for-rewrite=bar <copy &&
-	git log -2 >actual &&
+	lognotes -2 >actual &&
 	test_cmp expect actual
 '
 
@@ -1136,10 +1139,10 @@ test_expect_success 'git notes copy --for-rewrite (overwrite)' '
 		Author: A U Thor <author@example.com>
 		Date:   Thu Apr 7 15:27:13 2005 -0700
 
-		${indent}15th
+		15th
 
 		Notes:
-		${indent}a fresh note
+		a fresh note
 	EOF
 	git notes add -f -m"a fresh note" HEAD^ &&
 	test_config notes.rewriteMode overwrite &&
@@ -1148,7 +1151,7 @@ test_expect_success 'git notes copy --for-rewrite (overwrite)' '
 	to=$(git rev-parse HEAD) &&
 	echo "$from" "$to" >copy &&
 	git notes copy --for-rewrite=foo <copy &&
-	git log -1 >actual &&
+	lognotes -1 >actual &&
 	test_cmp expect actual
 '
 
@@ -1159,7 +1162,7 @@ test_expect_success 'git notes copy --for-rewrite (ignore)' '
 	to=$(git rev-parse HEAD) &&
 	echo "$from" "$to" >copy &&
 	git notes copy --for-rewrite=foo <copy &&
-	git log -1 >actual &&
+	lognotes -1 >actual &&
 	test_cmp expect actual
 '
 
@@ -1170,12 +1173,12 @@ test_expect_success 'git notes copy --for-rewrite (append)' '
 		Author: A U Thor <author@example.com>
 		Date:   Thu Apr 7 15:27:13 2005 -0700
 
-		${indent}15th
+		15th
 
 		Notes:
-		${indent}a fresh note
-		${indent}
-		${indent}another fresh note
+		a fresh note
+
+		another fresh note
 	EOF
 	git notes add -f -m"another fresh note" HEAD^ &&
 	test_config notes.rewriteMode concatenate &&
@@ -1184,7 +1187,7 @@ test_expect_success 'git notes copy --for-rewrite (append)' '
 	to=$(git rev-parse HEAD) &&
 	echo "$from" "$to" >copy &&
 	git notes copy --for-rewrite=foo <copy &&
-	git log -1 >actual &&
+	lognotes -1 >actual &&
 	test_cmp expect actual
 '
 
@@ -1195,16 +1198,16 @@ test_expect_success 'git notes copy --for-rewrite (append two to one)' '
 		Author: A U Thor <author@example.com>
 		Date:   Thu Apr 7 15:27:13 2005 -0700
 
-		${indent}15th
+		15th
 
 		Notes:
-		${indent}a fresh note
-		${indent}
-		${indent}another fresh note
-		${indent}
-		${indent}append 1
-		${indent}
-		${indent}append 2
+		a fresh note
+
+		another fresh note
+
+		append 1
+
+		append 2
 	EOF
 	git notes add -f -m"append 1" HEAD^ &&
 	git notes add -f -m"append 2" HEAD^^ &&
@@ -1217,7 +1220,7 @@ test_expect_success 'git notes copy --for-rewrite (append two to one)' '
 	to=$(git rev-parse HEAD) &&
 	echo "$from" "$to" >>copy &&
 	git notes copy --for-rewrite=foo <copy &&
-	git log -1 >actual &&
+	lognotes -1 >actual &&
 	test_cmp expect actual
 '
 
@@ -1229,7 +1232,7 @@ test_expect_success 'git notes copy --for-rewrite (append empty)' '
 	to=$(git rev-parse HEAD) &&
 	echo "$from" "$to" >copy &&
 	git notes copy --for-rewrite=foo <copy &&
-	git log -1 >actual &&
+	lognotes -1 >actual &&
 	test_cmp expect actual
 '
 
@@ -1240,10 +1243,10 @@ test_expect_success 'GIT_NOTES_REWRITE_MODE works' '
 		Author: A U Thor <author@example.com>
 		Date:   Thu Apr 7 15:27:13 2005 -0700
 
-		${indent}15th
+		15th
 
 		Notes:
-		${indent}replacement note 1
+		replacement note 1
 	EOF
 	test_config notes.rewriteMode concatenate &&
 	test_config notes.rewriteRef "refs/notes/*" &&
@@ -1252,7 +1255,7 @@ test_expect_success 'GIT_NOTES_REWRITE_MODE works' '
 	to=$(git rev-parse HEAD) &&
 	echo "$from" "$to" >copy &&
 	GIT_NOTES_REWRITE_MODE=overwrite git notes copy --for-rewrite=foo <copy &&
-	git log -1 >actual &&
+	lognotes -1 >actual &&
 	test_cmp expect actual
 '
 
@@ -1263,10 +1266,10 @@ test_expect_success 'GIT_NOTES_REWRITE_REF works' '
 		Author: A U Thor <author@example.com>
 		Date:   Thu Apr 7 15:27:13 2005 -0700
 
-		${indent}15th
+		15th
 
 		Notes:
-		${indent}replacement note 2
+		replacement note 2
 	EOF
 	git notes add -f -m"replacement note 2" HEAD^ &&
 	test_config notes.rewriteMode overwrite &&
@@ -1276,7 +1279,7 @@ test_expect_success 'GIT_NOTES_REWRITE_REF works' '
 	echo "$from" "$to" >copy &&
 	GIT_NOTES_REWRITE_REF=refs/notes/commits:refs/notes/other \
 		git notes copy --for-rewrite=foo <copy &&
-	git log -1 >actual &&
+	lognotes -1 >actual &&
 	test_cmp expect actual
 '
 
@@ -1289,7 +1292,7 @@ test_expect_success 'GIT_NOTES_REWRITE_REF overrides config' '
 	echo "$from" "$to" >copy &&
 	GIT_NOTES_REWRITE_REF=refs/notes/commits \
 		git notes copy --for-rewrite=foo <copy &&
-	git log -1 >actual &&
+	lognotes -1 >actual &&
 	grep "replacement note 3" actual
 '
 
@@ -1372,13 +1375,13 @@ EOF
 
 test_expect_success 'empty notes are displayed by git log' '
 	test_commit 17th &&
-	git log -1 >expect &&
+	lognotes -1 >expect &&
 	cat >>expect <<-EOF &&
 
 		Notes:
 	EOF
 	git notes add -C "$empty_blob" --allow-empty &&
-	git log -1 >actual &&
+	lognotes -1 >actual &&
 	test_cmp expect actual
 '
 
-- 
2.33.0.153.gba50c8fa24


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

* [PATCH 2/3] t3303/t9301: make `notes` tests less brittle
  2021-08-30  7:21 [PATCH 0/3] suppress trailing whitespace on empty "notes" lines Eric Sunshine
  2021-08-30  7:21 ` [PATCH 1/3] t3301: tolerate minor notes-related presentation changes Eric Sunshine
@ 2021-08-30  7:21 ` Eric Sunshine
  2021-08-30  7:21 ` [PATCH 3/3] notes: don't indent empty lines Eric Sunshine
  2021-08-30 10:47 ` [RFC PATCH v2 0/2] suppress trailing whitespace on empty "notes" lines Ævar Arnfjörð Bjarmason
  3 siblings, 0 replies; 25+ messages in thread
From: Eric Sunshine @ 2021-08-30  7:21 UTC (permalink / raw)
  To: git; +Cc: Eric Sunshine

These tests care about whether intended notes-related functionality
occurred, but they check for the expected result in a brittle way by
consulting the default output of `git log` which is intended for human,
not machine, consumption. Make the tests more robust by requesting the
desired information in a stable machine-consumable format.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
---
 t/t3303-notes-subtrees.sh    | 13 ++++++++-----
 t/t9301-fast-import-notes.sh | 36 +++++++++++++++++++-----------------
 2 files changed, 27 insertions(+), 22 deletions(-)

diff --git a/t/t3303-notes-subtrees.sh b/t/t3303-notes-subtrees.sh
index d47ce00f69..abffa10564 100755
--- a/t/t3303-notes-subtrees.sh
+++ b/t/t3303-notes-subtrees.sh
@@ -171,13 +171,16 @@ INPUT_END
 }
 
 verify_concatenated_notes () {
-	git log | grep "^    " > output &&
+	git log --format="tformat:%B%N" >output &&
 	i=$number_of_commits &&
 	while [ $i -gt 0 ]; do
-		echo "    commit #$i" &&
-		echo "    first note for commit #$i" &&
-		echo "    " &&
-		echo "    second note for commit #$i" &&
+		cat <<-EOF &&
+		commit #$i
+		first note for commit #$i
+
+		second note for commit #$i
+
+		EOF
 		i=$(($i-1));
 	done > expect &&
 	test_cmp expect output
diff --git a/t/t9301-fast-import-notes.sh b/t/t9301-fast-import-notes.sh
index 1ae4d7c0d3..123323b2bb 100755
--- a/t/t9301-fast-import-notes.sh
+++ b/t/t9301-fast-import-notes.sh
@@ -259,29 +259,31 @@ EOF
 
 INPUT_END
 
-whitespace="    "
-
 cat >expect <<EXPECT_END
-    fourth commit
-    pre-prefix of note for fourth commit
-$whitespace
-    prefix of note for fourth commit
-$whitespace
-    third note for fourth commit
-    third commit
-    prefix of note for third commit
-$whitespace
-    third note for third commit
-    second commit
-    third note for second commit
-    first commit
-    third note for first commit
+fourth commit
+pre-prefix of note for fourth commit
+
+prefix of note for fourth commit
+
+third note for fourth commit
+
+third commit
+prefix of note for third commit
+
+third note for third commit
+
+second commit
+third note for second commit
+
+first commit
+third note for first commit
+
 EXPECT_END
 
 test_expect_success 'add concatenation notes with M command' '
 
 	git fast-import <input &&
-	GIT_NOTES_REF=refs/notes/test git log | grep "^    " > actual &&
+	GIT_NOTES_REF=refs/notes/test git log --format="tformat:%B%N" >actual &&
 	test_cmp expect actual
 
 '
-- 
2.33.0.153.gba50c8fa24


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

* [PATCH 3/3] notes: don't indent empty lines
  2021-08-30  7:21 [PATCH 0/3] suppress trailing whitespace on empty "notes" lines Eric Sunshine
  2021-08-30  7:21 ` [PATCH 1/3] t3301: tolerate minor notes-related presentation changes Eric Sunshine
  2021-08-30  7:21 ` [PATCH 2/3] t3303/t9301: make `notes` tests less brittle Eric Sunshine
@ 2021-08-30  7:21 ` Eric Sunshine
  2021-08-30 17:10   ` Junio C Hamano
  2021-08-30 10:47 ` [RFC PATCH v2 0/2] suppress trailing whitespace on empty "notes" lines Ævar Arnfjörð Bjarmason
  3 siblings, 1 reply; 25+ messages in thread
From: Eric Sunshine @ 2021-08-30  7:21 UTC (permalink / raw)
  To: git; +Cc: Eric Sunshine

Like other Git commands, `git notes` takes care to call `stripspace` on
the user-supplied note content, thereby ensuring that it has no trailing
whitespace, among other cleanups. However, when notes are inserted into
a patch via `git format-patch --notes`, all lines of the note are
indented unconditionally, including empty lines, which leaves trailing
whitespace on lines which previously were empty, thus negating the
normalization done earlier. Fix this shortcoming.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
---
 notes.c                 |  2 +-
 t/t4014-format-patch.sh | 17 +++++++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/notes.c b/notes.c
index f87dac4068..25e0a59899 100644
--- a/notes.c
+++ b/notes.c
@@ -1295,7 +1295,7 @@ static void format_note(struct notes_tree *t, const struct object_id *object_oid
 	for (msg_p = msg; msg_p < msg + msglen; msg_p += linelen + 1) {
 		linelen = strchrnul(msg_p, '\n') - msg_p;
 
-		if (!raw)
+		if (!raw && linelen)
 			strbuf_addstr(sb, "    ");
 		strbuf_add(sb, msg_p, linelen);
 		strbuf_addch(sb, '\n');
diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
index 712d4b5ddf..7406e5fe99 100755
--- a/t/t4014-format-patch.sh
+++ b/t/t4014-format-patch.sh
@@ -906,6 +906,23 @@ test_expect_success 'format-patch with multiple notes refs in config' '
 	grep "this is note 2" out
 '
 
+test_expect_success 'format-patch --notes does not indent empty lines' '
+	git notes add --file=- HEAD <<-\EOF &&
+	paragraph 1
+
+	paragraph 2
+	EOF
+	test_when_finished "git notes remove HEAD" &&
+	git format-patch -1 --stdout --notes >out &&
+	sed -n "/^[ 	]*paragraph 1$/,/^[ 	]*paragraph 2$/{s/^[ 	][ 	]*/[indent]/;p;}" out >actual &&
+	cat >expect <<-\EOF &&
+	[indent]paragraph 1
+
+	[indent]paragraph 2
+	EOF
+	test_cmp expect actual
+'
+
 echo "fatal: --name-only does not make sense" >expect.name-only
 echo "fatal: --name-status does not make sense" >expect.name-status
 echo "fatal: --check does not make sense" >expect.check
-- 
2.33.0.153.gba50c8fa24


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

* [RFC PATCH v2 0/2] suppress trailing whitespace on empty "notes" lines
  2021-08-30  7:21 [PATCH 0/3] suppress trailing whitespace on empty "notes" lines Eric Sunshine
                   ` (2 preceding siblings ...)
  2021-08-30  7:21 ` [PATCH 3/3] notes: don't indent empty lines Eric Sunshine
@ 2021-08-30 10:47 ` Ævar Arnfjörð Bjarmason
  2021-08-30 10:47   ` [RFC PATCH v2 1/2] t3303/t9301: make `notes` tests less brittle Ævar Arnfjörð Bjarmason
                     ` (3 more replies)
  3 siblings, 4 replies; 25+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2021-08-30 10:47 UTC (permalink / raw)
  To: git; +Cc: Eric Sunshine, Ævar Arnfjörð Bjarmason

This is a review of Eric Sunshin's
<20210830072118.91921-1-sunshine@sunshineco.com> series.

Side note:

    I'm generally trying to see if just sending a "proposed vX" is
    more productive for everyone than patch feedback effectively
    describing it in prose. I don't mean for this thing to be picked
    up as-is by Junio without the consent of the submitter, and don't
    have any desire to "pick up" the series myself.

    My review workflow is just applying the patches locally, fiddling
    with them, so it seems like the most straightforward and helpful
    thing to send the result of that local end-state, rather than
    describing the changes I made in prose, and expect the original
    submitter to reverse engineer that state if they're interested in
    trying it out locally themselves.

I really like the end goal of
<20210830072118.91921-1-sunshine@sunshineco.com> series, but this
seems like a more straightforward way to get to that goal.

I.e. the original 1/3 and 2/3 starts out by making the tests
whitespace-independent. If we just skip that 1/3, and then in 3/3
tweak the relevant failing tests for the code change we won't even
need a new test, all the existing tests previously made
whitespace-independent in 1/3 will assert this new behavior.

Eric Sunshine (2):
  t3303/t9301: make `notes` tests less brittle
  notes: don't indent empty lines

 notes.c                      |  2 +-
 t/t3301-notes.sh             | 28 ++++++++++++++--------------
 t/t3303-notes-subtrees.sh    | 13 ++++++++-----
 t/t9301-fast-import-notes.sh | 36 +++++++++++++++++++-----------------
 4 files changed, 42 insertions(+), 37 deletions(-)

Range-diff against v1:
1:  d2915b20aee < -:  ----------- t3301: tolerate minor notes-related presentation changes
2:  478d8b8d104 ! 1:  5a1ddd30859 t3303/t9301: make `notes` tests less brittle
    @@ Commit message
         desired information in a stable machine-consumable format.
     
         Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
    +    Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
     
      ## t/t3303-notes-subtrees.sh ##
     @@ t/t3303-notes-subtrees.sh: INPUT_END
3:  56d05862a67 < -:  ----------- notes: don't indent empty lines
-:  ----------- > 2:  4b546b83fd7 notes: don't indent empty lines
-- 
2.33.0.737.g0eefde7d76


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

* [RFC PATCH v2 1/2] t3303/t9301: make `notes` tests less brittle
  2021-08-30 10:47 ` [RFC PATCH v2 0/2] suppress trailing whitespace on empty "notes" lines Ævar Arnfjörð Bjarmason
@ 2021-08-30 10:47   ` Ævar Arnfjörð Bjarmason
  2021-08-30 10:47   ` [RFC PATCH v2 2/2] notes: don't indent empty lines Ævar Arnfjörð Bjarmason
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 25+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2021-08-30 10:47 UTC (permalink / raw)
  To: git; +Cc: Eric Sunshine, Ævar Arnfjörð Bjarmason

From: Eric Sunshine <sunshine@sunshineco.com>

These tests care about whether intended notes-related functionality
occurred, but they check for the expected result in a brittle way by
consulting the default output of `git log` which is intended for human,
not machine, consumption. Make the tests more robust by requesting the
desired information in a stable machine-consumable format.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 t/t3303-notes-subtrees.sh    | 13 ++++++++-----
 t/t9301-fast-import-notes.sh | 36 +++++++++++++++++++-----------------
 2 files changed, 27 insertions(+), 22 deletions(-)

diff --git a/t/t3303-notes-subtrees.sh b/t/t3303-notes-subtrees.sh
index d47ce00f694..abffa105645 100755
--- a/t/t3303-notes-subtrees.sh
+++ b/t/t3303-notes-subtrees.sh
@@ -171,13 +171,16 @@ INPUT_END
 }
 
 verify_concatenated_notes () {
-	git log | grep "^    " > output &&
+	git log --format="tformat:%B%N" >output &&
 	i=$number_of_commits &&
 	while [ $i -gt 0 ]; do
-		echo "    commit #$i" &&
-		echo "    first note for commit #$i" &&
-		echo "    " &&
-		echo "    second note for commit #$i" &&
+		cat <<-EOF &&
+		commit #$i
+		first note for commit #$i
+
+		second note for commit #$i
+
+		EOF
 		i=$(($i-1));
 	done > expect &&
 	test_cmp expect output
diff --git a/t/t9301-fast-import-notes.sh b/t/t9301-fast-import-notes.sh
index 1ae4d7c0d37..123323b2bbb 100755
--- a/t/t9301-fast-import-notes.sh
+++ b/t/t9301-fast-import-notes.sh
@@ -259,29 +259,31 @@ EOF
 
 INPUT_END
 
-whitespace="    "
-
 cat >expect <<EXPECT_END
-    fourth commit
-    pre-prefix of note for fourth commit
-$whitespace
-    prefix of note for fourth commit
-$whitespace
-    third note for fourth commit
-    third commit
-    prefix of note for third commit
-$whitespace
-    third note for third commit
-    second commit
-    third note for second commit
-    first commit
-    third note for first commit
+fourth commit
+pre-prefix of note for fourth commit
+
+prefix of note for fourth commit
+
+third note for fourth commit
+
+third commit
+prefix of note for third commit
+
+third note for third commit
+
+second commit
+third note for second commit
+
+first commit
+third note for first commit
+
 EXPECT_END
 
 test_expect_success 'add concatenation notes with M command' '
 
 	git fast-import <input &&
-	GIT_NOTES_REF=refs/notes/test git log | grep "^    " > actual &&
+	GIT_NOTES_REF=refs/notes/test git log --format="tformat:%B%N" >actual &&
 	test_cmp expect actual
 
 '
-- 
2.33.0.737.g0eefde7d76


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

* [RFC PATCH v2 2/2] notes: don't indent empty lines
  2021-08-30 10:47 ` [RFC PATCH v2 0/2] suppress trailing whitespace on empty "notes" lines Ævar Arnfjörð Bjarmason
  2021-08-30 10:47   ` [RFC PATCH v2 1/2] t3303/t9301: make `notes` tests less brittle Ævar Arnfjörð Bjarmason
@ 2021-08-30 10:47   ` Ævar Arnfjörð Bjarmason
  2021-08-30 16:45   ` [RFC PATCH v2 0/2] suppress trailing whitespace on empty "notes" lines Eric Sunshine
  2021-08-30 17:04   ` Junio C Hamano
  3 siblings, 0 replies; 25+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2021-08-30 10:47 UTC (permalink / raw)
  To: git; +Cc: Eric Sunshine, Ævar Arnfjörð Bjarmason

From: Eric Sunshine <sunshine@sunshineco.com>

Like other Git commands, `git notes` takes care to call `stripspace` on
the user-supplied note content, thereby ensuring that it has no trailing
whitespace, among other cleanups. However, when notes are inserted into
a patch via `git format-patch --notes`, all lines of the note are
indented unconditionally, including empty lines, which leaves trailing
whitespace on lines which previously were empty, thus negating the
normalization done earlier. Fix this shortcoming.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 notes.c          |  2 +-
 t/t3301-notes.sh | 28 ++++++++++++++--------------
 2 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/notes.c b/notes.c
index f87dac40684..25e0a598996 100644
--- a/notes.c
+++ b/notes.c
@@ -1295,7 +1295,7 @@ static void format_note(struct notes_tree *t, const struct object_id *object_oid
 	for (msg_p = msg; msg_p < msg + msglen; msg_p += linelen + 1) {
 		linelen = strchrnul(msg_p, '\n') - msg_p;
 
-		if (!raw)
+		if (!raw && linelen)
 			strbuf_addstr(sb, "    ");
 		strbuf_add(sb, msg_p, linelen);
 		strbuf_addch(sb, '\n');
diff --git a/t/t3301-notes.sh b/t/t3301-notes.sh
index d742be88402..74e5bfbc863 100755
--- a/t/t3301-notes.sh
+++ b/t/t3301-notes.sh
@@ -326,7 +326,7 @@ test_expect_success 'show -m notes' '
 
 		Notes:
 		${indent}spam
-		${indent}
+
 		${indent}foo
 		${indent}bar
 		${indent}baz
@@ -849,7 +849,7 @@ test_expect_success 'append to note from other note with "git notes append -C"'
 
 		Notes:
 		${indent}yet another note
-		${indent}
+
 		${indent}yet another note
 	EOF
 	note=$(git notes list HEAD^) &&
@@ -887,7 +887,7 @@ test_expect_success 'append to note from other note with "git notes append -c"'
 
 		Notes:
 		${indent}other note
-		${indent}
+
 		${indent}yet another note
 	EOF
 	note=$(git notes list HEAD) &&
@@ -928,7 +928,7 @@ test_expect_success 'copy note with "git notes copy" with default' '
 
 		Notes:
 		${indent}other note
-		${indent}
+
 		${indent}yet another note
 	EOF
 	git notes copy HEAD^ &&
@@ -950,7 +950,7 @@ test_expect_success 'prevent overwrite with "git notes copy"' '
 
 		Notes:
 		${indent}other note
-		${indent}
+
 		${indent}yet another note
 	EOF
 	git log -1 >actual &&
@@ -991,7 +991,7 @@ test_expect_success 'allow overwrite with "git notes copy -f" with default' '
 
 		Notes:
 		${indent}yet another note
-		${indent}
+
 		${indent}yet another note
 	EOF
 	git notes copy -f HEAD~2 &&
@@ -1020,7 +1020,7 @@ test_expect_success 'git notes copy --stdin' '
 
 		Notes:
 		${indent}yet another note
-		${indent}
+
 		${indent}yet another note
 
 		commit $parent
@@ -1031,7 +1031,7 @@ test_expect_success 'git notes copy --stdin' '
 
 		Notes:
 		${indent}other note
-		${indent}
+
 		${indent}yet another note
 	EOF
 	from=$(git rev-parse HEAD~3) &&
@@ -1092,7 +1092,7 @@ test_expect_success 'git notes copy --for-rewrite (enabled)' '
 
 		Notes:
 		${indent}yet another note
-		${indent}
+
 		${indent}yet another note
 
 		commit $parent
@@ -1103,7 +1103,7 @@ test_expect_success 'git notes copy --for-rewrite (enabled)' '
 
 		Notes:
 		${indent}other note
-		${indent}
+
 		${indent}yet another note
 	EOF
 	test_config notes.rewriteMode overwrite &&
@@ -1174,7 +1174,7 @@ test_expect_success 'git notes copy --for-rewrite (append)' '
 
 		Notes:
 		${indent}a fresh note
-		${indent}
+
 		${indent}another fresh note
 	EOF
 	git notes add -f -m"another fresh note" HEAD^ &&
@@ -1199,11 +1199,11 @@ test_expect_success 'git notes copy --for-rewrite (append two to one)' '
 
 		Notes:
 		${indent}a fresh note
-		${indent}
+
 		${indent}another fresh note
-		${indent}
+
 		${indent}append 1
-		${indent}
+
 		${indent}append 2
 	EOF
 	git notes add -f -m"append 1" HEAD^ &&
-- 
2.33.0.737.g0eefde7d76


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

* Re: [RFC PATCH v2 0/2] suppress trailing whitespace on empty "notes" lines
  2021-08-30 10:47 ` [RFC PATCH v2 0/2] suppress trailing whitespace on empty "notes" lines Ævar Arnfjörð Bjarmason
  2021-08-30 10:47   ` [RFC PATCH v2 1/2] t3303/t9301: make `notes` tests less brittle Ævar Arnfjörð Bjarmason
  2021-08-30 10:47   ` [RFC PATCH v2 2/2] notes: don't indent empty lines Ævar Arnfjörð Bjarmason
@ 2021-08-30 16:45   ` Eric Sunshine
  2021-08-30 16:50     ` Eric Sunshine
  2021-08-30 17:04   ` Junio C Hamano
  3 siblings, 1 reply; 25+ messages in thread
From: Eric Sunshine @ 2021-08-30 16:45 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason; +Cc: Git List

On Mon, Aug 30, 2021 at 6:47 AM Ævar Arnfjörð Bjarmason
<avarab@gmail.com> wrote:
> Side note:
>
>     I'm generally trying to see if just sending a "proposed vX" is
>     more productive for everyone than patch feedback effectively
>     describing it in prose. I don't mean for this thing to be picked
>     up as-is by Junio without the consent of the submitter, and don't
>     have any desire to "pick up" the series myself.
>
> I really like the end goal of
> <20210830072118.91921-1-sunshine@sunshineco.com> series, but this
> seems like a more straightforward way to get to that goal.
>
> I.e. the original 1/3 and 2/3 starts out by making the tests
> whitespace-independent. If we just skip that 1/3, and then in 3/3
> tweak the relevant failing tests for the code change we won't even
> need a new test, all the existing tests previously made
> whitespace-independent in 1/3 will assert this new behavior.

It probably won't surprise you that this fix to `notes` started out as
a single patch which made the change to `notes.c` and adjusted the
existing tests to account for it. In particular, my original changes
to t3301 were exactly the same changes you made (i.e. merely dropping
the empty-line `${indent}` from the few necessary places). I wasn't
happy about the additional complexity I had to add to t3303 and t9301
to continue plucking the notes out of the default git-log output, thus
simplified by making those tests less brittle. That, of course,
deserved its own patch. I wavered quite a bit about whether to make
t3301 less brittle too, or to simply apply the minimal changes which I
had already made (and which you made independently). Eventually, I
decided to split that out as a brittle-fixing patch, as well, to
better future-proof it, but perhaps that's terribly important.

I don't have strong feelings between my v1 and your v2 of this series,
and would be happy to see Junio pick up either version.

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

* Re: [RFC PATCH v2 0/2] suppress trailing whitespace on empty "notes" lines
  2021-08-30 16:45   ` [RFC PATCH v2 0/2] suppress trailing whitespace on empty "notes" lines Eric Sunshine
@ 2021-08-30 16:50     ` Eric Sunshine
  0 siblings, 0 replies; 25+ messages in thread
From: Eric Sunshine @ 2021-08-30 16:50 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason; +Cc: Git List

On Mon, Aug 30, 2021 at 12:45 PM Eric Sunshine <sunshine@sunshineco.com> wrote:
> It probably won't surprise you that this fix to `notes` started out as
> a single patch which made the change to `notes.c` and adjusted the
> existing tests to account for it. In particular, my original changes
> to t3301 were exactly the same changes you made (i.e. merely dropping
> the empty-line `${indent}` from the few necessary places). I wasn't
> happy about the additional complexity I had to add to t3303 and t9301
> to continue plucking the notes out of the default git-log output, thus
> simplified by making those tests less brittle. That, of course,
> deserved its own patch. I wavered quite a bit about whether to make
> t3301 less brittle too, or to simply apply the minimal changes which I
> had already made (and which you made independently). Eventually, I
> decided to split that out as a brittle-fixing patch, as well, to
> better future-proof it, but perhaps that's terribly important.

...that's NOT terribly important.

(last-second editing mistake strikes again)

> I don't have strong feelings between my v1 and your v2 of this series,
> and would be happy to see Junio pick up either version.

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

* Re: [RFC PATCH v2 0/2] suppress trailing whitespace on empty "notes" lines
  2021-08-30 10:47 ` [RFC PATCH v2 0/2] suppress trailing whitespace on empty "notes" lines Ævar Arnfjörð Bjarmason
                     ` (2 preceding siblings ...)
  2021-08-30 16:45   ` [RFC PATCH v2 0/2] suppress trailing whitespace on empty "notes" lines Eric Sunshine
@ 2021-08-30 17:04   ` Junio C Hamano
  3 siblings, 0 replies; 25+ messages in thread
From: Junio C Hamano @ 2021-08-30 17:04 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason; +Cc: git, Eric Sunshine

Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:

> This is a review of Eric Sunshin's
> <20210830072118.91921-1-sunshine@sunshineco.com> series.
>
> Side note:
>
>     I'm generally trying to see if just sending a "proposed vX" is
>     more productive for everyone than patch feedback effectively
>     describing it in prose. I don't mean for this thing to be picked
>     up as-is by Junio without the consent of the submitter, and don't
>     have any desire to "pick up" the series myself.

It is impossible to read the rationale behind the change between v1
and "proposed v2" in such arrangement, simply because there is no
place in the "proposed v2" patch to write it down.  Proposed commit
log for it should not refer to what "v1" said, proposed postimage of
the patch should not refer to what "v1" did.  Worse, it is harder to
pick good bits from "proposed v2" and reject the others.

It is not a good way to give a feedback on "v1".  It does not help
the original author.

It certainly does not help the maintainer, who now has to read two
competing series, sort out the numbering mess.

I do not know if it helps other reviewers, but offhand I do not know
how it would, compared to the in-line comments on "v1", which is how
we usually do reviews.

>     My review workflow is just applying the patches locally, fiddling
>     with them, so it seems like the most straightforward and helpful
>     thing to send the result of that local end-state, rather than
>     describing the changes I made in prose, and expect the original
>     submitter to reverse engineer that state if they're interested in
>     trying it out locally themselves.

The end-state as an additional reference material attached as the
end note of the review may be helpful, but the in-line comments on
"v1" is a much better way to convey the reason why the change is
suggested, I would think.

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

* Re: [PATCH 1/3] t3301: tolerate minor notes-related presentation changes
  2021-08-30  7:21 ` [PATCH 1/3] t3301: tolerate minor notes-related presentation changes Eric Sunshine
@ 2021-08-30 17:09   ` Junio C Hamano
  2021-08-30 18:16     ` Eric Sunshine
  0 siblings, 1 reply; 25+ messages in thread
From: Junio C Hamano @ 2021-08-30 17:09 UTC (permalink / raw)
  To: Eric Sunshine; +Cc: git

Eric Sunshine <sunshine@sunshineco.com> writes:

> These tests care about whether intended notes-related functionality
> occurred and that `git log` presents the notes in the expected fashion
> (or, in some cases, that `git log` suppresses the notes). However, the
> tests hard-code the precise indentation of notes by the default `git
> log` output, which makes them somewhat brittle since they won't be able
> to tolerate even minor changes to the presentation. Make the tests a bit
> more robust by ignoring indentation.

Isn't this losing too much information?  If we lose all, or gain
random number of, leading whitespaces, the test won't notice.

> Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
> ---
>  t/t3301-notes.sh | 321 ++++++++++++++++++++++++-----------------------
>  1 file changed, 162 insertions(+), 159 deletions(-)
>
> diff --git a/t/t3301-notes.sh b/t/t3301-notes.sh
> index d742be8840..955b2670a7 100755
> --- a/t/t3301-notes.sh
> +++ b/t/t3301-notes.sh
> @@ -7,6 +7,11 @@ test_description='Test commit notes'
>  
>  . ./test-lib.sh
>  
> +lognotes () {
> +	git log "$@" >lognotes.out &&
> +	sed 's/^[ 	]*//' lognotes.out
> +}
> +
>  write_script fake_editor <<\EOF
>  echo "$MSG" >"$1"
>  echo "$MSG" >&2
> @@ -14,8 +19,6 @@ EOF
>  GIT_EDITOR=./fake_editor
>  export GIT_EDITOR
>  
> -indent="    "
> -
>  test_expect_success 'cannot annotate non-existing HEAD' '
>  	test_must_fail env MSG=3 git notes add
>  '
> @@ -158,14 +161,14 @@ test_expect_success 'show notes' '
>  		Author: A U Thor <author@example.com>
>  		Date:   Thu Apr 7 15:14:13 2005 -0700
>  
> -		${indent}2nd
> +		2nd
>  
>  		Notes:
> -		${indent}b1
> +		b1
>  	EOF
>  	git cat-file commit HEAD >commits &&
>  	! grep b1 commits &&
> -	git log -1 >actual &&
> +	lognotes -1 >actual &&
>  	test_cmp expect actual
>  '
>  
> @@ -178,16 +181,16 @@ test_expect_success 'show multi-line notes' '
>  		Author: A U Thor <author@example.com>
>  		Date:   Thu Apr 7 15:15:13 2005 -0700
>  
> -		${indent}3rd
> +		3rd
>  
>  		Notes:
> -		${indent}b3
> -		${indent}c3c3c3c3
> -		${indent}d3d3d3
> +		b3
> +		c3c3c3c3
> +		d3d3d3
>  
>  	EOF
>  	cat expect >>expect-multiline &&
> -	git log -2 >actual &&
> +	lognotes -2 >actual &&
>  	test_cmp expect-multiline actual
>  '
>  
> @@ -201,21 +204,21 @@ test_expect_success 'show -F notes' '
>  		Author: A U Thor <author@example.com>
>  		Date:   Thu Apr 7 15:16:13 2005 -0700
>  
> -		${indent}4th
> +		4th
>  
>  		Notes:
> -		${indent}xyzzy
> +		xyzzy
>  
>  	EOF
>  	cat expect-multiline >>expect-F &&
> -	git log -3 >actual &&
> +	lognotes -3 >actual &&
>  	test_cmp expect-F actual
>  '
>  
>  test_expect_success 'Re-adding -F notes without -f fails' '
>  	echo "zyxxy" >note5 &&
>  	test_must_fail git notes add -F note5 &&
> -	git log -3 >actual &&
> +	lognotes -3 >actual &&
>  	test_cmp expect-F actual
>  '
>  
> @@ -230,9 +233,9 @@ test_expect_success 'git log --pretty=raw does not show notes' '
>  		author A U Thor <author@example.com> 1112912173 -0700
>  		committer C O Mitter <committer@example.com> 1112912173 -0700
>  
> -		${indent}4th
> +		4th
>  	EOF
> -	git log -1 --pretty=raw >actual &&
> +	lognotes -1 --pretty=raw >actual &&
>  	test_cmp expect actual
>  '
>  
> @@ -240,14 +243,14 @@ test_expect_success 'git log --show-notes' '
>  	cat >>expect <<-EOF &&
>  
>  	Notes:
> -	${indent}xyzzy
> +	xyzzy
>  	EOF
> -	git log -1 --pretty=raw --show-notes >actual &&
> +	lognotes -1 --pretty=raw --show-notes >actual &&
>  	test_cmp expect actual
>  '
>  
>  test_expect_success 'git log --no-notes' '
> -	git log -1 --no-notes >actual &&
> +	lognotes -1 --no-notes >actual &&
>  	! grep xyzzy actual
>  '
>  
> @@ -280,25 +283,25 @@ test_expect_success 'setup alternate notes ref' '
>  '
>  
>  test_expect_success 'git log --notes shows default notes' '
> -	git log -1 --notes >actual &&
> +	lognotes -1 --notes >actual &&
>  	grep xyzzy actual &&
>  	! grep alternate actual
>  '
>  
>  test_expect_success 'git log --notes=X shows only X' '
> -	git log -1 --notes=alternate >actual &&
> +	lognotes -1 --notes=alternate >actual &&
>  	! grep xyzzy actual &&
>  	grep alternate actual
>  '
>  
>  test_expect_success 'git log --notes --notes=X shows both' '
> -	git log -1 --notes --notes=alternate >actual &&
> +	lognotes -1 --notes --notes=alternate >actual &&
>  	grep xyzzy actual &&
>  	grep alternate actual
>  '
>  
>  test_expect_success 'git log --no-notes resets default state' '
> -	git log -1 --notes --notes=alternate \
> +	lognotes -1 --notes --notes=alternate \
>  		--no-notes --notes=alternate \
>  		>actual &&
>  	! grep xyzzy actual &&
> @@ -306,7 +309,7 @@ test_expect_success 'git log --no-notes resets default state' '
>  '
>  
>  test_expect_success 'git log --no-notes resets ref list' '
> -	git log -1 --notes --notes=alternate \
> +	lognotes -1 --notes --notes=alternate \
>  		--no-notes --notes \
>  		>actual &&
>  	grep xyzzy actual &&
> @@ -322,18 +325,18 @@ test_expect_success 'show -m notes' '
>  		Author: A U Thor <author@example.com>
>  		Date:   Thu Apr 7 15:17:13 2005 -0700
>  
> -		${indent}5th
> +		5th
>  
>  		Notes:
> -		${indent}spam
> -		${indent}
> -		${indent}foo
> -		${indent}bar
> -		${indent}baz
> +		spam
> +
> +		foo
> +		bar
> +		baz
>  
>  	EOF
>  	cat expect-F >>expect-m &&
> -	git log -4 >actual &&
> +	lognotes -4 >actual &&
>  	test_cmp expect-m actual
>  '
>  
> @@ -345,18 +348,18 @@ test_expect_success 'remove note with add -f -F /dev/null' '
>  		Author: A U Thor <author@example.com>
>  		Date:   Thu Apr 7 15:17:13 2005 -0700
>  
> -		${indent}5th
> +		5th
>  
>  	EOF
>  	cat expect-F >>expect-rm-F &&
> -	git log -4 >actual &&
> +	lognotes -4 >actual &&
>  	test_cmp expect-rm-F actual &&
>  	test_must_fail git notes show
>  '
>  
>  test_expect_success 'do not create empty note with -m ""' '
>  	git notes add -m "" &&
> -	git log -4 >actual &&
> +	lognotes -4 >actual &&
>  	test_cmp expect-rm-F actual &&
>  	test_must_fail git notes show
>  '
> @@ -390,17 +393,17 @@ test_expect_success 'remove note with "git notes remove"' '
>  		Author: A U Thor <author@example.com>
>  		Date:   Thu Apr 7 15:17:13 2005 -0700
>  
> -		${indent}5th
> +		5th
>  
>  		commit $parent
>  		Author: A U Thor <author@example.com>
>  		Date:   Thu Apr 7 15:16:13 2005 -0700
>  
> -		${indent}4th
> +		4th
>  
>  	EOF
>  	cat expect-multiline >>expect-rm-remove &&
> -	git log -4 >actual &&
> +	lognotes -4 >actual &&
>  	test_cmp expect-rm-remove actual &&
>  	test_must_fail git notes show HEAD^
>  '
> @@ -570,35 +573,35 @@ test_expect_success 'create other note on a different notes ref (setup)' '
>  		Author: A U Thor <author@example.com>
>  		Date:   Thu Apr 7 15:18:13 2005 -0700
>  
> -		${indent}6th
> +		6th
>  	EOF
>  	cp expect-not-other expect-other &&
>  	cat >>expect-other <<-EOF
>  
>  		Notes (other):
> -		${indent}other note
> +		other note
>  	EOF
>  '
>  
>  test_expect_success 'Do not show note on other ref by default' '
> -	git log -1 >actual &&
> +	lognotes -1 >actual &&
>  	test_cmp expect-not-other actual
>  '
>  
>  test_expect_success 'Do show note when ref is given in GIT_NOTES_REF' '
> -	GIT_NOTES_REF="refs/notes/other" git log -1 >actual &&
> +	test_env GIT_NOTES_REF="refs/notes/other" lognotes -1 >actual &&
>  	test_cmp expect-other actual
>  '
>  
>  test_expect_success 'Do show note when ref is given in core.notesRef config' '
>  	test_config core.notesRef "refs/notes/other" &&
> -	git log -1 >actual &&
> +	lognotes -1 >actual &&
>  	test_cmp expect-other actual
>  '
>  
>  test_expect_success 'Do not show note when core.notesRef is overridden' '
>  	test_config core.notesRef "refs/notes/other" &&
> -	GIT_NOTES_REF="refs/notes/wrong" git log -1 >actual &&
> +	test_env GIT_NOTES_REF="refs/notes/wrong" lognotes -1 >actual &&
>  	test_cmp expect-not-other actual
>  '
>  
> @@ -610,36 +613,36 @@ test_expect_success 'Show all notes when notes.displayRef=refs/notes/*' '
>  		Author: A U Thor <author@example.com>
>  		Date:   Thu Apr 7 15:18:13 2005 -0700
>  
> -		${indent}6th
> +		6th
>  
>  		Notes:
> -		${indent}order test
> +		order test
>  
>  		Notes (other):
> -		${indent}other note
> +		other note
>  
>  		commit $parent
>  		Author: A U Thor <author@example.com>
>  		Date:   Thu Apr 7 15:17:13 2005 -0700
>  
> -		${indent}5th
> +		5th
>  
>  		Notes:
> -		${indent}replacement for deleted note
> +		replacement for deleted note
>  	EOF
>  	GIT_NOTES_REF=refs/notes/commits git notes add \
>  		-m"replacement for deleted note" HEAD^ &&
>  	GIT_NOTES_REF=refs/notes/commits git notes add -m"order test" &&
>  	test_unconfig core.notesRef &&
>  	test_config notes.displayRef "refs/notes/*" &&
> -	git log -2 >actual &&
> +	lognotes -2 >actual &&
>  	test_cmp expect-both actual
>  '
>  
>  test_expect_success 'core.notesRef is implicitly in notes.displayRef' '
>  	test_config core.notesRef refs/notes/commits &&
>  	test_config notes.displayRef refs/notes/other &&
> -	git log -2 >actual &&
> +	lognotes -2 >actual &&
>  	test_cmp expect-both actual
>  '
>  
> @@ -647,7 +650,7 @@ test_expect_success 'notes.displayRef can be given more than once' '
>  	test_unconfig core.notesRef &&
>  	test_config notes.displayRef refs/notes/commits &&
>  	git config --add notes.displayRef refs/notes/other &&
> -	git log -2 >actual &&
> +	lognotes -2 >actual &&
>  	test_cmp expect-both actual
>  '
>  
> @@ -658,17 +661,17 @@ test_expect_success 'notes.displayRef respects order' '
>  		Author: A U Thor <author@example.com>
>  		Date:   Thu Apr 7 15:18:13 2005 -0700
>  
> -		${indent}6th
> +		6th
>  
>  		Notes (other):
> -		${indent}other note
> +		other note
>  
>  		Notes:
> -		${indent}order test
> +		order test
>  	EOF
>  	test_config core.notesRef refs/notes/other &&
>  	test_config notes.displayRef refs/notes/commits &&
> -	git log -1 >actual &&
> +	lognotes -1 >actual &&
>  	test_cmp expect-both-reversed actual
>  '
>  
> @@ -678,8 +681,8 @@ test_expect_success 'notes.displayRef with no value handled gracefully' '
>  '
>  
>  test_expect_success 'GIT_NOTES_DISPLAY_REF works' '
> -	GIT_NOTES_DISPLAY_REF=refs/notes/commits:refs/notes/other \
> -		git log -2 >actual &&
> +	test_env GIT_NOTES_DISPLAY_REF=refs/notes/commits:refs/notes/other \
> +		lognotes -2 >actual &&
>  	test_cmp expect-both actual
>  '
>  
> @@ -691,21 +694,21 @@ test_expect_success 'GIT_NOTES_DISPLAY_REF overrides config' '
>  		Author: A U Thor <author@example.com>
>  		Date:   Thu Apr 7 15:18:13 2005 -0700
>  
> -		${indent}6th
> +		6th
>  
>  		commit $parent
>  		Author: A U Thor <author@example.com>
>  		Date:   Thu Apr 7 15:17:13 2005 -0700
>  
> -		${indent}5th
> +		5th
>  	EOF
>  	test_config notes.displayRef "refs/notes/*" &&
> -	GIT_NOTES_REF= GIT_NOTES_DISPLAY_REF= git log -2 >actual &&
> +	test_env GIT_NOTES_REF= GIT_NOTES_DISPLAY_REF= lognotes -2 >actual &&
>  	test_cmp expect-none actual
>  '
>  
>  test_expect_success '--show-notes=* adds to GIT_NOTES_DISPLAY_REF' '
> -	GIT_NOTES_REF= GIT_NOTES_DISPLAY_REF= git log --show-notes=* -2 >actual &&
> +	test_env GIT_NOTES_REF= GIT_NOTES_DISPLAY_REF= lognotes --show-notes=* -2 >actual &&
>  	test_cmp expect-both actual
>  '
>  
> @@ -716,24 +719,24 @@ test_expect_success '--no-standard-notes' '
>  		Author: A U Thor <author@example.com>
>  		Date:   Thu Apr 7 15:18:13 2005 -0700
>  
> -		${indent}6th
> +		6th
>  
>  		Notes:
> -		${indent}order test
> +		order test
>  	EOF
> -	git log --no-standard-notes --show-notes=commits -1 >actual &&
> +	lognotes --no-standard-notes --show-notes=commits -1 >actual &&
>  	test_cmp expect-commits actual
>  '
>  
>  test_expect_success '--standard-notes' '
>  	test_config notes.displayRef "refs/notes/*" &&
> -	git log --no-standard-notes --show-notes=commits \
> +	lognotes --no-standard-notes --show-notes=commits \
>  		--standard-notes -2 >actual &&
>  	test_cmp expect-both actual
>  '
>  
>  test_expect_success '--show-notes=ref accumulates' '
> -	git log --show-notes=other --show-notes=commits \
> +	lognotes --show-notes=other --show-notes=commits \
>  		 --no-standard-notes -1 >actual &&
>  	test_cmp expect-both-reversed actual
>  '
> @@ -765,14 +768,14 @@ test_expect_success 'create note from other note with "git notes add -C"' '
>  		Author: A U Thor <author@example.com>
>  		Date:   Thu Apr 7 15:19:13 2005 -0700
>  
> -		${indent}7th
> +		7th
>  
>  		Notes:
> -		${indent}order test
> +		order test
>  	EOF
>  	note=$(git notes list HEAD^) &&
>  	git notes add -C $note &&
> -	git log -1 >actual &&
> +	lognotes -1 >actual &&
>  	test_cmp expect actual &&
>  	git notes list HEAD^ >expect &&
>  	git notes list HEAD >actual &&
> @@ -800,14 +803,14 @@ test_expect_success 'create note from blob with "git notes add -C" reuses blob i
>  		Author: A U Thor <author@example.com>
>  		Date:   Thu Apr 7 15:20:13 2005 -0700
>  
> -		${indent}8th
> +		8th
>  
>  		Notes:
> -		${indent}This is a blob object
> +		This is a blob object
>  	EOF
>  	echo "This is a blob object" | git hash-object -w --stdin >blob &&
>  	git notes add -C $(cat blob) &&
> -	git log -1 >actual &&
> +	lognotes -1 >actual &&
>  	test_cmp expect actual &&
>  	git notes list HEAD >actual &&
>  	test_cmp blob actual
> @@ -821,14 +824,14 @@ test_expect_success 'create note from other note with "git notes add -c"' '
>  		Author: A U Thor <author@example.com>
>  		Date:   Thu Apr 7 15:21:13 2005 -0700
>  
> -		${indent}9th
> +		9th
>  
>  		Notes:
> -		${indent}yet another note
> +		yet another note
>  	EOF
>  	note=$(git notes list HEAD^^) &&
>  	MSG="yet another note" git notes add -c $note &&
> -	git log -1 >actual &&
> +	lognotes -1 >actual &&
>  	test_cmp expect actual
>  '
>  
> @@ -845,16 +848,16 @@ test_expect_success 'append to note from other note with "git notes append -C"'
>  		Author: A U Thor <author@example.com>
>  		Date:   Thu Apr 7 15:21:13 2005 -0700
>  
> -		${indent}9th
> +		9th
>  
>  		Notes:
> -		${indent}yet another note
> -		${indent}
> -		${indent}yet another note
> +		yet another note
> +
> +		yet another note
>  	EOF
>  	note=$(git notes list HEAD^) &&
>  	git notes append -C $note HEAD^ &&
> -	git log -1 HEAD^ >actual &&
> +	lognotes -1 HEAD^ >actual &&
>  	test_cmp expect actual
>  '
>  
> @@ -865,14 +868,14 @@ test_expect_success 'create note from other note with "git notes append -c"' '
>  		Author: A U Thor <author@example.com>
>  		Date:   Thu Apr 7 15:22:13 2005 -0700
>  
> -		${indent}10th
> +		10th
>  
>  		Notes:
> -		${indent}other note
> +		other note
>  	EOF
>  	note=$(git notes list HEAD^) &&
>  	MSG="other note" git notes append -c $note &&
> -	git log -1 >actual &&
> +	lognotes -1 >actual &&
>  	test_cmp expect actual
>  '
>  
> @@ -883,16 +886,16 @@ test_expect_success 'append to note from other note with "git notes append -c"'
>  		Author: A U Thor <author@example.com>
>  		Date:   Thu Apr 7 15:22:13 2005 -0700
>  
> -		${indent}10th
> +		10th
>  
>  		Notes:
> -		${indent}other note
> -		${indent}
> -		${indent}yet another note
> +		other note
> +
> +		yet another note
>  	EOF
>  	note=$(git notes list HEAD) &&
>  	MSG="yet another note" git notes append -c $note &&
> -	git log -1 >actual &&
> +	lognotes -1 >actual &&
>  	test_cmp expect actual
>  '
>  
> @@ -903,13 +906,13 @@ test_expect_success 'copy note with "git notes copy"' '
>  		Author: A U Thor <author@example.com>
>  		Date:   Thu Apr 7 15:16:13 2005 -0700
>  
> -		${indent}4th
> +		4th
>  
>  		Notes:
> -		${indent}This is a blob object
> +		This is a blob object
>  	EOF
>  	git notes copy 8th 4th &&
> -	git log 3rd..4th >actual &&
> +	lognotes 3rd..4th >actual &&
>  	test_cmp expect actual &&
>  	git notes list 4th >expect &&
>  	git notes list 8th >actual &&
> @@ -924,15 +927,15 @@ test_expect_success 'copy note with "git notes copy" with default' '
>  		Author: A U Thor <author@example.com>
>  		Date:   Thu Apr 7 15:23:13 2005 -0700
>  
> -		${indent}11th
> +		11th
>  
>  		Notes:
> -		${indent}other note
> -		${indent}
> -		${indent}yet another note
> +		other note
> +
> +		yet another note
>  	EOF
>  	git notes copy HEAD^ &&
> -	git log -1 >actual &&
> +	lognotes -1 >actual &&
>  	test_cmp expect actual &&
>  	git notes list HEAD^ >expect &&
>  	git notes list HEAD >actual &&
> @@ -946,14 +949,14 @@ test_expect_success 'prevent overwrite with "git notes copy"' '
>  		Author: A U Thor <author@example.com>
>  		Date:   Thu Apr 7 15:23:13 2005 -0700
>  
> -		${indent}11th
> +		11th
>  
>  		Notes:
> -		${indent}other note
> -		${indent}
> -		${indent}yet another note
> +		other note
> +
> +		yet another note
>  	EOF
> -	git log -1 >actual &&
> +	lognotes -1 >actual &&
>  	test_cmp expect actual &&
>  	git notes list HEAD^ >expect &&
>  	git notes list HEAD >actual &&
> @@ -967,13 +970,13 @@ test_expect_success 'allow overwrite with "git notes copy -f"' '
>  		Author: A U Thor <author@example.com>
>  		Date:   Thu Apr 7 15:23:13 2005 -0700
>  
> -		${indent}11th
> +		11th
>  
>  		Notes:
> -		${indent}This is a blob object
> +		This is a blob object
>  	EOF
>  	git notes copy -f HEAD~3 HEAD &&
> -	git log -1 >actual &&
> +	lognotes -1 >actual &&
>  	test_cmp expect actual &&
>  	git notes list HEAD~3 >expect &&
>  	git notes list HEAD >actual &&
> @@ -987,15 +990,15 @@ test_expect_success 'allow overwrite with "git notes copy -f" with default' '
>  		Author: A U Thor <author@example.com>
>  		Date:   Thu Apr 7 15:23:13 2005 -0700
>  
> -		${indent}11th
> +		11th
>  
>  		Notes:
> -		${indent}yet another note
> -		${indent}
> -		${indent}yet another note
> +		yet another note
> +
> +		yet another note
>  	EOF
>  	git notes copy -f HEAD~2 &&
> -	git log -1 >actual &&
> +	lognotes -1 >actual &&
>  	test_cmp expect actual &&
>  	git notes list HEAD~2 >expect &&
>  	git notes list HEAD >actual &&
> @@ -1016,23 +1019,23 @@ test_expect_success 'git notes copy --stdin' '
>  		Author: A U Thor <author@example.com>
>  		Date:   Thu Apr 7 15:25:13 2005 -0700
>  
> -		${indent}13th
> +		13th
>  
>  		Notes:
> -		${indent}yet another note
> -		${indent}
> -		${indent}yet another note
> +		yet another note
> +
> +		yet another note
>  
>  		commit $parent
>  		Author: A U Thor <author@example.com>
>  		Date:   Thu Apr 7 15:24:13 2005 -0700
>  
> -		${indent}12th
> +		12th
>  
>  		Notes:
> -		${indent}other note
> -		${indent}
> -		${indent}yet another note
> +		other note
> +
> +		yet another note
>  	EOF
>  	from=$(git rev-parse HEAD~3) &&
>  	to=$(git rev-parse HEAD^) &&
> @@ -1041,7 +1044,7 @@ test_expect_success 'git notes copy --stdin' '
>  	to=$(git rev-parse HEAD) &&
>  	echo "$from" "$to" >>copy &&
>  	git notes copy --stdin <copy &&
> -	git log -2 >actual &&
> +	lognotes -2 >actual &&
>  	test_cmp expect actual &&
>  	git notes list HEAD~2 >expect &&
>  	git notes list HEAD >actual &&
> @@ -1061,13 +1064,13 @@ test_expect_success 'git notes copy --for-rewrite (unconfigured)' '
>  		Author: A U Thor <author@example.com>
>  		Date:   Thu Apr 7 15:27:13 2005 -0700
>  
> -		${indent}15th
> +		15th
>  
>  		commit $parent
>  		Author: A U Thor <author@example.com>
>  		Date:   Thu Apr 7 15:26:13 2005 -0700
>  
> -		${indent}14th
> +		14th
>  	EOF
>  	from=$(git rev-parse HEAD~3) &&
>  	to=$(git rev-parse HEAD^) &&
> @@ -1076,7 +1079,7 @@ test_expect_success 'git notes copy --for-rewrite (unconfigured)' '
>  	to=$(git rev-parse HEAD) &&
>  	echo "$from" "$to" >>copy &&
>  	git notes copy --for-rewrite=foo <copy &&
> -	git log -2 >actual &&
> +	lognotes -2 >actual &&
>  	test_cmp expect actual
>  '
>  
> @@ -1088,23 +1091,23 @@ test_expect_success 'git notes copy --for-rewrite (enabled)' '
>  		Author: A U Thor <author@example.com>
>  		Date:   Thu Apr 7 15:27:13 2005 -0700
>  
> -		${indent}15th
> +		15th
>  
>  		Notes:
> -		${indent}yet another note
> -		${indent}
> -		${indent}yet another note
> +		yet another note
> +
> +		yet another note
>  
>  		commit $parent
>  		Author: A U Thor <author@example.com>
>  		Date:   Thu Apr 7 15:26:13 2005 -0700
>  
> -		${indent}14th
> +		14th
>  
>  		Notes:
> -		${indent}other note
> -		${indent}
> -		${indent}yet another note
> +		other note
> +
> +		yet another note
>  	EOF
>  	test_config notes.rewriteMode overwrite &&
>  	test_config notes.rewriteRef "refs/notes/*" &&
> @@ -1115,7 +1118,7 @@ test_expect_success 'git notes copy --for-rewrite (enabled)' '
>  	to=$(git rev-parse HEAD) &&
>  	echo "$from" "$to" >>copy &&
>  	git notes copy --for-rewrite=foo <copy &&
> -	git log -2 >actual &&
> +	lognotes -2 >actual &&
>  	test_cmp expect actual
>  '
>  
> @@ -1125,7 +1128,7 @@ test_expect_success 'git notes copy --for-rewrite (disabled)' '
>  	to=$(git rev-parse HEAD) &&
>  	echo "$from" "$to" >copy &&
>  	git notes copy --for-rewrite=bar <copy &&
> -	git log -2 >actual &&
> +	lognotes -2 >actual &&
>  	test_cmp expect actual
>  '
>  
> @@ -1136,10 +1139,10 @@ test_expect_success 'git notes copy --for-rewrite (overwrite)' '
>  		Author: A U Thor <author@example.com>
>  		Date:   Thu Apr 7 15:27:13 2005 -0700
>  
> -		${indent}15th
> +		15th
>  
>  		Notes:
> -		${indent}a fresh note
> +		a fresh note
>  	EOF
>  	git notes add -f -m"a fresh note" HEAD^ &&
>  	test_config notes.rewriteMode overwrite &&
> @@ -1148,7 +1151,7 @@ test_expect_success 'git notes copy --for-rewrite (overwrite)' '
>  	to=$(git rev-parse HEAD) &&
>  	echo "$from" "$to" >copy &&
>  	git notes copy --for-rewrite=foo <copy &&
> -	git log -1 >actual &&
> +	lognotes -1 >actual &&
>  	test_cmp expect actual
>  '
>  
> @@ -1159,7 +1162,7 @@ test_expect_success 'git notes copy --for-rewrite (ignore)' '
>  	to=$(git rev-parse HEAD) &&
>  	echo "$from" "$to" >copy &&
>  	git notes copy --for-rewrite=foo <copy &&
> -	git log -1 >actual &&
> +	lognotes -1 >actual &&
>  	test_cmp expect actual
>  '
>  
> @@ -1170,12 +1173,12 @@ test_expect_success 'git notes copy --for-rewrite (append)' '
>  		Author: A U Thor <author@example.com>
>  		Date:   Thu Apr 7 15:27:13 2005 -0700
>  
> -		${indent}15th
> +		15th
>  
>  		Notes:
> -		${indent}a fresh note
> -		${indent}
> -		${indent}another fresh note
> +		a fresh note
> +
> +		another fresh note
>  	EOF
>  	git notes add -f -m"another fresh note" HEAD^ &&
>  	test_config notes.rewriteMode concatenate &&
> @@ -1184,7 +1187,7 @@ test_expect_success 'git notes copy --for-rewrite (append)' '
>  	to=$(git rev-parse HEAD) &&
>  	echo "$from" "$to" >copy &&
>  	git notes copy --for-rewrite=foo <copy &&
> -	git log -1 >actual &&
> +	lognotes -1 >actual &&
>  	test_cmp expect actual
>  '
>  
> @@ -1195,16 +1198,16 @@ test_expect_success 'git notes copy --for-rewrite (append two to one)' '
>  		Author: A U Thor <author@example.com>
>  		Date:   Thu Apr 7 15:27:13 2005 -0700
>  
> -		${indent}15th
> +		15th
>  
>  		Notes:
> -		${indent}a fresh note
> -		${indent}
> -		${indent}another fresh note
> -		${indent}
> -		${indent}append 1
> -		${indent}
> -		${indent}append 2
> +		a fresh note
> +
> +		another fresh note
> +
> +		append 1
> +
> +		append 2
>  	EOF
>  	git notes add -f -m"append 1" HEAD^ &&
>  	git notes add -f -m"append 2" HEAD^^ &&
> @@ -1217,7 +1220,7 @@ test_expect_success 'git notes copy --for-rewrite (append two to one)' '
>  	to=$(git rev-parse HEAD) &&
>  	echo "$from" "$to" >>copy &&
>  	git notes copy --for-rewrite=foo <copy &&
> -	git log -1 >actual &&
> +	lognotes -1 >actual &&
>  	test_cmp expect actual
>  '
>  
> @@ -1229,7 +1232,7 @@ test_expect_success 'git notes copy --for-rewrite (append empty)' '
>  	to=$(git rev-parse HEAD) &&
>  	echo "$from" "$to" >copy &&
>  	git notes copy --for-rewrite=foo <copy &&
> -	git log -1 >actual &&
> +	lognotes -1 >actual &&
>  	test_cmp expect actual
>  '
>  
> @@ -1240,10 +1243,10 @@ test_expect_success 'GIT_NOTES_REWRITE_MODE works' '
>  		Author: A U Thor <author@example.com>
>  		Date:   Thu Apr 7 15:27:13 2005 -0700
>  
> -		${indent}15th
> +		15th
>  
>  		Notes:
> -		${indent}replacement note 1
> +		replacement note 1
>  	EOF
>  	test_config notes.rewriteMode concatenate &&
>  	test_config notes.rewriteRef "refs/notes/*" &&
> @@ -1252,7 +1255,7 @@ test_expect_success 'GIT_NOTES_REWRITE_MODE works' '
>  	to=$(git rev-parse HEAD) &&
>  	echo "$from" "$to" >copy &&
>  	GIT_NOTES_REWRITE_MODE=overwrite git notes copy --for-rewrite=foo <copy &&
> -	git log -1 >actual &&
> +	lognotes -1 >actual &&
>  	test_cmp expect actual
>  '
>  
> @@ -1263,10 +1266,10 @@ test_expect_success 'GIT_NOTES_REWRITE_REF works' '
>  		Author: A U Thor <author@example.com>
>  		Date:   Thu Apr 7 15:27:13 2005 -0700
>  
> -		${indent}15th
> +		15th
>  
>  		Notes:
> -		${indent}replacement note 2
> +		replacement note 2
>  	EOF
>  	git notes add -f -m"replacement note 2" HEAD^ &&
>  	test_config notes.rewriteMode overwrite &&
> @@ -1276,7 +1279,7 @@ test_expect_success 'GIT_NOTES_REWRITE_REF works' '
>  	echo "$from" "$to" >copy &&
>  	GIT_NOTES_REWRITE_REF=refs/notes/commits:refs/notes/other \
>  		git notes copy --for-rewrite=foo <copy &&
> -	git log -1 >actual &&
> +	lognotes -1 >actual &&
>  	test_cmp expect actual
>  '
>  
> @@ -1289,7 +1292,7 @@ test_expect_success 'GIT_NOTES_REWRITE_REF overrides config' '
>  	echo "$from" "$to" >copy &&
>  	GIT_NOTES_REWRITE_REF=refs/notes/commits \
>  		git notes copy --for-rewrite=foo <copy &&
> -	git log -1 >actual &&
> +	lognotes -1 >actual &&
>  	grep "replacement note 3" actual
>  '
>  
> @@ -1372,13 +1375,13 @@ EOF
>  
>  test_expect_success 'empty notes are displayed by git log' '
>  	test_commit 17th &&
> -	git log -1 >expect &&
> +	lognotes -1 >expect &&
>  	cat >>expect <<-EOF &&
>  
>  		Notes:
>  	EOF
>  	git notes add -C "$empty_blob" --allow-empty &&
> -	git log -1 >actual &&
> +	lognotes -1 >actual &&
>  	test_cmp expect actual
>  '

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

* Re: [PATCH 3/3] notes: don't indent empty lines
  2021-08-30  7:21 ` [PATCH 3/3] notes: don't indent empty lines Eric Sunshine
@ 2021-08-30 17:10   ` Junio C Hamano
  2021-08-30 17:41     ` Eric Sunshine
  0 siblings, 1 reply; 25+ messages in thread
From: Junio C Hamano @ 2021-08-30 17:10 UTC (permalink / raw)
  To: Eric Sunshine; +Cc: git

Eric Sunshine <sunshine@sunshineco.com> writes:

> Like other Git commands, `git notes` takes care to call `stripspace` on
> the user-supplied note content, thereby ensuring that it has no trailing
> whitespace, among other cleanups. However, when notes are inserted into
> a patch via `git format-patch --notes`, all lines of the note are
> indented unconditionally, including empty lines, which leaves trailing
> whitespace on lines which previously were empty, thus negating the
> normalization done earlier. Fix this shortcoming.

Playing the devil's advocate, it can be argued that using the same
leading whitespace on a paragraph break line is actually a good
thing.  Leaving them in would give the consumer an easy way to see
which part was inserted from a note.

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

* Re: [PATCH 3/3] notes: don't indent empty lines
  2021-08-30 17:10   ` Junio C Hamano
@ 2021-08-30 17:41     ` Eric Sunshine
  2021-08-30 17:56       ` Junio C Hamano
  0 siblings, 1 reply; 25+ messages in thread
From: Eric Sunshine @ 2021-08-30 17:41 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git List

On Mon, Aug 30, 2021 at 1:10 PM Junio C Hamano <gitster@pobox.com> wrote:
> Eric Sunshine <sunshine@sunshineco.com> writes:
> > Like other Git commands, `git notes` takes care to call `stripspace` on
> > the user-supplied note content, thereby ensuring that it has no trailing
> > whitespace, among other cleanups. However, when notes are inserted into
> > a patch via `git format-patch --notes`, all lines of the note are
> > indented unconditionally, including empty lines, which leaves trailing
> > whitespace on lines which previously were empty, thus negating the
> > normalization done earlier. Fix this shortcoming.
>
> Playing the devil's advocate, it can be argued that using the same
> leading whitespace on a paragraph break line is actually a good
> thing.  Leaving them in would give the consumer an easy way to see
> which part was inserted from a note.

The, um, angel's response: `git format-patch --notes` is a convenience
for the _submitter_ of a series. It is difficult to imagine a
scenario[1] in which the _consumer_ of a series would care or need to
know whether patch commentary was written by hand, inserted
mechanically (by `--notes`), or inserted mechanically and then
hand-edited.

The trailing whitespace is unusual within the Git sphere, as well as
unsightly if you happen to have your editor configured to highlight
trailing whitespace, and just "feels" sloppy.

[1]: I suppose mechanical extraction of notes may be one such
scenario, allowing for simple-minded (not necessarily robust)
extraction mechanics; i.e. start extracting after the /^Notes:$/ line
and stop at the first line not indented with four blanks.

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

* Re: [PATCH 3/3] notes: don't indent empty lines
  2021-08-30 17:41     ` Eric Sunshine
@ 2021-08-30 17:56       ` Junio C Hamano
  2021-08-30 18:04         ` Eric Sunshine
  0 siblings, 1 reply; 25+ messages in thread
From: Junio C Hamano @ 2021-08-30 17:56 UTC (permalink / raw)
  To: Eric Sunshine; +Cc: Git List

Eric Sunshine <sunshine@sunshineco.com> writes:

> The trailing whitespace is unusual within the Git sphere, as well as
> unsightly if you happen to have your editor configured to highlight
> trailing whitespace, and just "feels" sloppy.

But we are discussing this in the context of format-patch output,
where patches that change lines near a blank line will have a line
with a single SP on it in common context ;-)

I do not feel very strongly either way, though.

> [1]: I suppose mechanical extraction of notes may be one such
> scenario, allowing for simple-minded (not necessarily robust)
> extraction mechanics; i.e. start extracting after the /^Notes:$/ line
> and stop at the first line not indented with four blanks.

Yup, that was what I had in mind.

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

* Re: [PATCH 3/3] notes: don't indent empty lines
  2021-08-30 17:56       ` Junio C Hamano
@ 2021-08-30 18:04         ` Eric Sunshine
  2021-09-10  5:18           ` Eric Sunshine
  0 siblings, 1 reply; 25+ messages in thread
From: Eric Sunshine @ 2021-08-30 18:04 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git List

On Mon, Aug 30, 2021 at 1:56 PM Junio C Hamano <gitster@pobox.com> wrote:
> Eric Sunshine <sunshine@sunshineco.com> writes:
> > [1]: I suppose mechanical extraction of notes may be one such
> > scenario, allowing for simple-minded (not necessarily robust)
> > extraction mechanics; i.e. start extracting after the /^Notes:$/ line
> > and stop at the first line not indented with four blanks.
>
> Yup, that was what I had in mind.

In the general case, such an extraction mechanism would be far too
fragile since there are no guarantees that the commentary in the
"Notes:" section hasn't been hand-edited after patch-generation.
However, it's certainly possible that such a simple-minded extraction
technique might be applicable in some well-controlled development
pipeline somewhere.

If we are worried about that, then we can drop this patch series.

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

* Re: [PATCH 1/3] t3301: tolerate minor notes-related presentation changes
  2021-08-30 17:09   ` Junio C Hamano
@ 2021-08-30 18:16     ` Eric Sunshine
  0 siblings, 0 replies; 25+ messages in thread
From: Eric Sunshine @ 2021-08-30 18:16 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git List

On Mon, Aug 30, 2021 at 1:09 PM Junio C Hamano <gitster@pobox.com> wrote:
> Eric Sunshine <sunshine@sunshineco.com> writes:
> > These tests care about whether intended notes-related functionality
> > occurred and that `git log` presents the notes in the expected fashion
> > (or, in some cases, that `git log` suppresses the notes). However, the
> > tests hard-code the precise indentation of notes by the default `git
> > log` output, which makes them somewhat brittle since they won't be able
> > to tolerate even minor changes to the presentation. Make the tests a bit
> > more robust by ignoring indentation.
>
> Isn't this losing too much information?  If we lose all, or gain
> random number of, leading whitespaces, the test won't notice.

That was the idea. The precise amount of indentation -- whether four
spaces or one TAB or whatever -- seems pretty much immaterial in the
wide view [1], and it is not inconceivable that the exact amount of
indentation might change in the future, thus this future-proofs the
tests against minor indentation changes.

However, as mentioned in my response to Ævar, I wavered quite a bit on
whether or not to make this change since, although the justification
of "future-proofing" the tests isn't exactly hand-wavy, we don't need
the change either. It may be a case of YAGNI. So, as I also mentioned
in that response, I don't mind at all dropping this patch and going
with Ævar's version.

[1]: mechanical extraction aside...

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

* Re: [PATCH 3/3] notes: don't indent empty lines
  2021-08-30 18:04         ` Eric Sunshine
@ 2021-09-10  5:18           ` Eric Sunshine
  2021-09-10  5:21             ` Eric Sunshine
  2021-09-10 18:33             ` Junio C Hamano
  0 siblings, 2 replies; 25+ messages in thread
From: Eric Sunshine @ 2021-09-10  5:18 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git List, Ævar Arnfjörð Bjarmason

On Mon, Aug 30, 2021 at 2:04 PM Eric Sunshine <sunshine@sunshineco.com> wrote:
> In the general case, such an extraction mechanism would be far too
> fragile since there are no guarantees that the commentary in the
> "Notes:" section hasn't been hand-edited after patch-generation.
> However, it's certainly possible that such a simple-minded extraction
> technique might be applicable in some well-controlled development
> pipeline somewhere.
>
> If we are worried about that, then we can drop this patch series.

Have we made a decision about whether this patch series -- which
avoids indenting blank notes lines -- is desirable? Or are we worried
about backward-compatibility? If we think there is value in this
series, then I can re-roll with Ævar suggestions. If not, perhaps I
can re-submit just patch [1/3] which makes a few tests less brittle.
Or, since those brittle tests aren't necessarily hurting anything, we
can just let this series die.

Thoughts?

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

* Re: [PATCH 3/3] notes: don't indent empty lines
  2021-09-10  5:18           ` Eric Sunshine
@ 2021-09-10  5:21             ` Eric Sunshine
  2021-09-10 18:33             ` Junio C Hamano
  1 sibling, 0 replies; 25+ messages in thread
From: Eric Sunshine @ 2021-09-10  5:21 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git List, Ævar Arnfjörð Bjarmason

On Fri, Sep 10, 2021 at 1:18 AM Eric Sunshine <sunshine@sunshineco.com> wrote:
> Have we made a decision about whether this patch series -- which
> avoids indenting blank notes lines -- is desirable? Or are we worried
> about backward-compatibility? If we think there is value in this
> series, then I can re-roll with Ævar suggestions. If not, perhaps I
> can re-submit just patch [1/3] which makes a few tests less brittle.
> Or, since those brittle tests aren't necessarily hurting anything, we
> can just let this series die.

I meant [2/3], not [1/3], as a possibility for a standalone
re-submission. That's the patch in which a few tests in t3303 and
t9301 which care only whether notes are present (or not) are made less
brittle by removing dependence upon the default output format of
git-log.

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

* Re: [PATCH 3/3] notes: don't indent empty lines
  2021-09-10  5:18           ` Eric Sunshine
  2021-09-10  5:21             ` Eric Sunshine
@ 2021-09-10 18:33             ` Junio C Hamano
  2021-09-10 20:31               ` Eric Sunshine
  1 sibling, 1 reply; 25+ messages in thread
From: Junio C Hamano @ 2021-09-10 18:33 UTC (permalink / raw)
  To: Eric Sunshine; +Cc: Git List, Ævar Arnfjörð Bjarmason

Eric Sunshine <sunshine@sunshineco.com> writes:

> Have we made a decision about whether this patch series -- which
> avoids indenting blank notes lines -- is desirable? Or are we worried
> about backward-compatibility?

I do not know about "have we made" part of the question, but an
input from me to come to an answer to the question is that, while I
can see why it may be desirable in some cases, I do not view it as
compelling enough to risk any unforeseen breakage to other peoples'
workflow.  My opinion is based on an assumption that it is desirable
because it would squelch "here is a trailing whitespace" noise in an
editor and/or a pager that is appropriately configured and allow the
user to spot whitespace breakages in the payload more easily and for
no other reason.  If there are other reasons that make this change
desirable, they might influence my opinion.

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

* Re: [PATCH 3/3] notes: don't indent empty lines
  2021-09-10 18:33             ` Junio C Hamano
@ 2021-09-10 20:31               ` Eric Sunshine
  2021-09-11  1:53                 ` Ævar Arnfjörð Bjarmason
  0 siblings, 1 reply; 25+ messages in thread
From: Eric Sunshine @ 2021-09-10 20:31 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git List, Ævar Arnfjörð Bjarmason

On Fri, Sep 10, 2021 at 2:33 PM Junio C Hamano <gitster@pobox.com> wrote:
> Eric Sunshine <sunshine@sunshineco.com> writes:
> > Have we made a decision about whether this patch series -- which
> > avoids indenting blank notes lines -- is desirable? Or are we worried
> > about backward-compatibility?
>
> I do not know about "have we made" part of the question, but an
> input from me to come to an answer to the question is that, while I
> can see why it may be desirable in some cases, I do not view it as
> compelling enough to risk any unforeseen breakage to other peoples'
> workflow.  My opinion is based on an assumption that it is desirable
> because it would squelch "here is a trailing whitespace" noise in an
> editor and/or a pager that is appropriately configured and allow the
> user to spot whitespace breakages in the payload more easily and for
> no other reason.  If there are other reasons that make this change
> desirable, they might influence my opinion.

Thank you for the response. I didn't have any other reason beyond
squelching "here is trailing whitespace" noise when submitting the
series. Thus, I can't provide any other reasons to promote the change
as desirable.

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

* Re: [PATCH 3/3] notes: don't indent empty lines
  2021-09-10 20:31               ` Eric Sunshine
@ 2021-09-11  1:53                 ` Ævar Arnfjörð Bjarmason
  2021-09-11  9:15                   ` Eric Sunshine
  0 siblings, 1 reply; 25+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2021-09-11  1:53 UTC (permalink / raw)
  To: Eric Sunshine; +Cc: Junio C Hamano, Git List


On Fri, Sep 10 2021, Eric Sunshine wrote:

> On Fri, Sep 10, 2021 at 2:33 PM Junio C Hamano <gitster@pobox.com> wrote:
>> Eric Sunshine <sunshine@sunshineco.com> writes:
>> > Have we made a decision about whether this patch series -- which
>> > avoids indenting blank notes lines -- is desirable? Or are we worried
>> > about backward-compatibility?
>>
>> I do not know about "have we made" part of the question, but an
>> input from me to come to an answer to the question is that, while I
>> can see why it may be desirable in some cases, I do not view it as
>> compelling enough to risk any unforeseen breakage to other peoples'
>> workflow.  My opinion is based on an assumption that it is desirable
>> because it would squelch "here is a trailing whitespace" noise in an
>> editor and/or a pager that is appropriately configured and allow the
>> user to spot whitespace breakages in the payload more easily and for
>> no other reason.  If there are other reasons that make this change
>> desirable, they might influence my opinion.
>
> Thank you for the response. I didn't have any other reason beyond
> squelching "here is trailing whitespace" noise when submitting the
> series. Thus, I can't provide any other reasons to promote the change
> as desirable.

This change per-se seems nice, but even having reviewed it to the point
of rewriting parts of it, I didn't really look into what the whole
workflow you were trying to address is.

So e.g. just to pick a random commit of your for show:
    
    $ git show c990a4c11dd | sed 's/$/Z/'
    commit c990a4c11ddZ
    Author: Eric Sunshine <sunshine@sunshineco.com>Z
    Date:   Mon Jul 6 13:30:45 2015 -0400Z
    Z
        checkout: fix bug with --to and relative HEADZ
        Z
        Given "git checkout --to <path> HEAD~1", the new worktree's HEAD shouldZ
        begin life at the current branch's HEAD~1, however, it actually ends upZ
        at HEAD~2. This happens because:Z
        Z
            1. git-checkout resolves HEAD~1Z
        Z
    [...]

Here we end up also adding the whitespace indenting to the empty lines,
whereas if we were trying to feed this to an editor we'd place those
later Z's at the start of our line.

Are notes different? Or are they just similarly indented? For commits we
don't insert that leading whitespace in the commit object, do notes get
that part wrong too?

It might be showing, but I've only used notes a few times, my main use
of them is Junio's amlog.

So even for someone experienced in git, I think some show & tell of
step-by-step showing in the commit message how we end up with X before,
and have Y with this change would help a lot.

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

* Re: [PATCH 3/3] notes: don't indent empty lines
  2021-09-11  1:53                 ` Ævar Arnfjörð Bjarmason
@ 2021-09-11  9:15                   ` Eric Sunshine
  2021-09-11 10:39                     ` Ævar Arnfjörð Bjarmason
  0 siblings, 1 reply; 25+ messages in thread
From: Eric Sunshine @ 2021-09-11  9:15 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason; +Cc: Junio C Hamano, Git List

On Fri, Sep 10, 2021 at 9:59 PM Ævar Arnfjörð Bjarmason
<avarab@gmail.com> wrote:
> >> Eric Sunshine <sunshine@sunshineco.com> writes:
> >> > Have we made a decision about whether this patch series -- which
> >> > avoids indenting blank notes lines -- is desirable? Or are we worried
> >> > about backward-compatibility?
>
> This change per-se seems nice, but even having reviewed it to the point
> of rewriting parts of it, I didn't really look into what the whole
> workflow you were trying to address is.
>
> So e.g. just to pick a random commit of your for show:
>     $ git show c990a4c11dd | sed 's/$/Z/'
> Here we end up also adding the whitespace indenting to the empty lines,
> whereas if we were trying to feed this to an editor we'd place those
> later Z's at the start of our line.

I'm not sure what you mean by "feed this to an editor". Do you mean
sending the output of `git show` to an editor? I'm guessing that's not
what you mean, and that you instead are talking about editing the
commit message in an editor (say, via the "reword" option of `git
rebase --interactive`).

> Are notes different? Or are they just similarly indented? For commits we
> don't insert that leading whitespace in the commit object, do notes get
> that part wrong too?

Notes don't store the indented blank lines; it's only at output time,
such as with `git format-patch --notes` that the blank lines get
indented along with the rest of the note text (just as is happening in
your `git show` example in which the entire commit message is being
indented, including the blank lines).

> It might be showing, but I've only used notes a few times, my main use
> of them is Junio's amlog.

I also have only used notes a few times.

> So even for someone experienced in git, I think some show & tell of
> step-by-step showing in the commit message how we end up with X before,
> and have Y with this change would help a lot.

This all came about due to two unrelated circumstances: (1) a few
months ago, I configured Emacs to highlight trailing whitespace, and
(2) I decided to use `notes` to add commentary to a commit since,
although I normally just write the commentary directly in the patch
itself after running `git format-patch`, in this case, it likely will
be weeks or months before I finish the series, and was worried that
I'd forget the intended commentary by that time, thus recorded it as a
note. Since I've almost never used notes, I ran `git format-patch
--notes` as a test and was surprised to see the trailing whitespace on
the "blank" lines when viewing the patch in the editor.

This submission started as a single patch which just "fixed" the bug
and added a test. Only after that was complete (but before I submitted
the patch), did I discover that other tests in the suite were failing
since the "fix" also changed git-log's default output format which
includes notes (indented). Since I so rarely use notes, I had either
forgotten that git-log showed notes or didn't know in the first place.
The submission grew to multiple patches due to fixing those
newly-failing tests.

Anyhow, since then, I've discovered that `git format-patch
--range-diff` also indents blank lines. And you've now shown that `git
show` does, as well, so the behavior which triggered this "fix" turns
out to be somewhat normal in this project, rather than a one-off "bug"
in need of a fix.

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

* Re: [PATCH 3/3] notes: don't indent empty lines
  2021-09-11  9:15                   ` Eric Sunshine
@ 2021-09-11 10:39                     ` Ævar Arnfjörð Bjarmason
  2021-09-12  5:53                       ` Eric Sunshine
  0 siblings, 1 reply; 25+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2021-09-11 10:39 UTC (permalink / raw)
  To: Eric Sunshine; +Cc: Junio C Hamano, Git List


On Sat, Sep 11 2021, Eric Sunshine wrote:

> On Fri, Sep 10, 2021 at 9:59 PM Ævar Arnfjörð Bjarmason
> <avarab@gmail.com> wrote:
>> >> Eric Sunshine <sunshine@sunshineco.com> writes:
>> >> > Have we made a decision about whether this patch series -- which
>> >> > avoids indenting blank notes lines -- is desirable? Or are we worried
>> >> > about backward-compatibility?
>>
>> This change per-se seems nice, but even having reviewed it to the point
>> of rewriting parts of it, I didn't really look into what the whole
>> workflow you were trying to address is.
>>
>> So e.g. just to pick a random commit of your for show:
>>     $ git show c990a4c11dd | sed 's/$/Z/'
>> Here we end up also adding the whitespace indenting to the empty lines,
>> whereas if we were trying to feed this to an editor we'd place those
>> later Z's at the start of our line.
>
> I'm not sure what you mean by "feed this to an editor". Do you mean
> sending the output of `git show` to an editor? I'm guessing that's not
> what you mean, and that you instead are talking about editing the
> commit message in an editor (say, via the "reword" option of `git
> rebase --interactive`).

Feed it to whatever, maybe I have a commit message in my terminal I
highlight and copy/paste, my shell/terminal is highlighting line-endings
etc.

I've got a default bias towards trimming this whitespace, I'm just
wondering why notes are a special-case as opposed to our more general
log/notes etc. output.

>> Are notes different? Or are they just similarly indented? For commits we
>> don't insert that leading whitespace in the commit object, do notes get
>> that part wrong too?
>
> Notes don't store the indented blank lines; it's only at output time,
> such as with `git format-patch --notes` that the blank lines get
> indented along with the rest of the note text (just as is happening in
> your `git show` example in which the entire commit message is being
> indented, including the blank lines).

Ah, so with your change we'd end up with trimmed notes, but not the
trimmed main body of the commit message?

We don't have to fix everything at once, just establishing context,
maybe it's useful for format-patch etc. in isolation...

>> It might be showing, but I've only used notes a few times, my main use
>> of them is Junio's amlog.
>
> I also have only used notes a few times.
>
>> So even for someone experienced in git, I think some show & tell of
>> step-by-step showing in the commit message how we end up with X before,
>> and have Y with this change would help a lot.
>
> This all came about due to two unrelated circumstances: (1) a few
> months ago, I configured Emacs to highlight trailing whitespace, and
> (2) I decided to use `notes` to add commentary to a commit since,
> although I normally just write the commentary directly in the patch
> itself after running `git format-patch`, in this case, it likely will
> be weeks or months before I finish the series, and was worried that
> I'd forget the intended commentary by that time, thus recorded it as a
> note. Since I've almost never used notes, I ran `git format-patch
> --notes` as a test and was surprised to see the trailing whitespace on
> the "blank" lines when viewing the patch in the editor.
>
> This submission started as a single patch which just "fixed" the bug
> and added a test. Only after that was complete (but before I submitted
> the patch), did I discover that other tests in the suite were failing
> since the "fix" also changed git-log's default output format which
> includes notes (indented). Since I so rarely use notes, I had either
> forgotten that git-log showed notes or didn't know in the first place.
> The submission grew to multiple patches due to fixing those
> newly-failing tests.
>
> Anyhow, since then, I've discovered that `git format-patch
> --range-diff` also indents blank lines. And you've now shown that `git
> show` does, as well, so the behavior which triggered this "fix" turns
> out to be somewhat normal in this project, rather than a one-off "bug"
> in need of a fix.

Per the above I wouldn't mind this just being changed for all of them,
even one at a time.

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

* Re: [PATCH 3/3] notes: don't indent empty lines
  2021-09-11 10:39                     ` Ævar Arnfjörð Bjarmason
@ 2021-09-12  5:53                       ` Eric Sunshine
  2021-09-12  8:22                         ` Junio C Hamano
  0 siblings, 1 reply; 25+ messages in thread
From: Eric Sunshine @ 2021-09-12  5:53 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason; +Cc: Junio C Hamano, Git List

On Sat, Sep 11, 2021 at 6:43 AM Ævar Arnfjörð Bjarmason
<avarab@gmail.com> wrote:
> On Sat, Sep 11 2021, Eric Sunshine wrote:
> > Notes don't store the indented blank lines; it's only at output time,
> > such as with `git format-patch --notes` that the blank lines get
> > indented along with the rest of the note text (just as is happening in
> > your `git show` example in which the entire commit message is being
> > indented, including the blank lines).
>
> Ah, so with your change we'd end up with trimmed notes, but not the
> trimmed main body of the commit message?

That's correct. This "fix" is specific to the note-printing machinery
which is invoked by (at least) git-format-patch and git-log.

(Until your demonstration of git-show indentation, I wasn't even aware
that blank lines in commit messages were getting indented there, as
well.)

> > Anyhow, since then, I've discovered that `git format-patch
> > --range-diff` also indents blank lines. And you've now shown that `git
> > show` does, as well, so the behavior which triggered this "fix" turns
> > out to be somewhat normal in this project, rather than a one-off "bug"
> > in need of a fix.
>
> Per the above I wouldn't mind this just being changed for all of them,
> even one at a time.

I'm not a fan of the trailing whitespace either, however, Junio does
have the concern that there may be some tooling somewhere which relies
upon the "indented blank lines" (even if such tooling would not be
robust).

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

* Re: [PATCH 3/3] notes: don't indent empty lines
  2021-09-12  5:53                       ` Eric Sunshine
@ 2021-09-12  8:22                         ` Junio C Hamano
  0 siblings, 0 replies; 25+ messages in thread
From: Junio C Hamano @ 2021-09-12  8:22 UTC (permalink / raw)
  To: Eric Sunshine; +Cc: Ævar Arnfjörð Bjarmason, Git List

Eric Sunshine <sunshine@sunshineco.com> writes:

> I'm not a fan of the trailing whitespace either, however, Junio does
> have the concern that there may be some tooling somewhere which relies
> upon the "indented blank lines" (even if such tooling would not be
> robust).

Note that such a "concern" is always relative.  If the upside were
so great, perhaps risking possible breakage may be warranted.  FWIW,
I am not a big fan of trailing whitespaces that human writers leave
in what they write, either.

Because the patch text will be full of lines with trailing
whitespaces anyway due to a blank lines in the patch context,
however, it does not sound so great an upside to tweak how the
paragraphs taken from the notes are inserted.

Thanks.

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

end of thread, other threads:[~2021-09-12  8:22 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-30  7:21 [PATCH 0/3] suppress trailing whitespace on empty "notes" lines Eric Sunshine
2021-08-30  7:21 ` [PATCH 1/3] t3301: tolerate minor notes-related presentation changes Eric Sunshine
2021-08-30 17:09   ` Junio C Hamano
2021-08-30 18:16     ` Eric Sunshine
2021-08-30  7:21 ` [PATCH 2/3] t3303/t9301: make `notes` tests less brittle Eric Sunshine
2021-08-30  7:21 ` [PATCH 3/3] notes: don't indent empty lines Eric Sunshine
2021-08-30 17:10   ` Junio C Hamano
2021-08-30 17:41     ` Eric Sunshine
2021-08-30 17:56       ` Junio C Hamano
2021-08-30 18:04         ` Eric Sunshine
2021-09-10  5:18           ` Eric Sunshine
2021-09-10  5:21             ` Eric Sunshine
2021-09-10 18:33             ` Junio C Hamano
2021-09-10 20:31               ` Eric Sunshine
2021-09-11  1:53                 ` Ævar Arnfjörð Bjarmason
2021-09-11  9:15                   ` Eric Sunshine
2021-09-11 10:39                     ` Ævar Arnfjörð Bjarmason
2021-09-12  5:53                       ` Eric Sunshine
2021-09-12  8:22                         ` Junio C Hamano
2021-08-30 10:47 ` [RFC PATCH v2 0/2] suppress trailing whitespace on empty "notes" lines Ævar Arnfjörð Bjarmason
2021-08-30 10:47   ` [RFC PATCH v2 1/2] t3303/t9301: make `notes` tests less brittle Ævar Arnfjörð Bjarmason
2021-08-30 10:47   ` [RFC PATCH v2 2/2] notes: don't indent empty lines Ævar Arnfjörð Bjarmason
2021-08-30 16:45   ` [RFC PATCH v2 0/2] suppress trailing whitespace on empty "notes" lines Eric Sunshine
2021-08-30 16:50     ` Eric Sunshine
2021-08-30 17:04   ` 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).