Subject: Re: [PATCH v6] [GSOC] trailer: add new trailer.<token>.cmd config option

From: Junio C Hamano <[email-masked]>
Date: Fri, 02 Apr 2021 16:44:37 -0700

"ZheNing Hu via GitGitGadget" <[email-masked]> writes:

> From: ZheNing Hu <[email-masked]>
>
> The `trailer.<token>.command` configuration variable
> specifies a command (run via the shell, so it does not have
> to be a single name of or path to the command, but can be a
> shell script), and the first occurrence of substring $ARG is
> replaced with the value given to the `interpret-trailer`
> command for the token.  This has two downsides:
> ...
>
>  Documentation/git-interpret-trailers.txt | 82 +++++++++++++++++---
>  t/t7513-interpret-trailers.sh            | 95 +++++++++++++++++++++++-
>  trailer.c                                | 38 +++++++---
>  3 files changed, 193 insertions(+), 22 deletions(-)

Merging this to anything that has zh/commit-trailer (which extends
the tests in t7502) seems to break t7502.  Running the test with the
"-i -v" option ends like so.

expecting success of 7502.24 'commit --trailer with -c and command': 
	trailer_commit_base &&
	cat >expected <<-\EOF &&
	hello

	Signed-off-by: C O Mitter <[email-masked]>
	Signed-off-by: C1 E1
	Helped-by: C2 E2
	Mentored-by: C4 E4
	Reported-by: A U Thor <[email-masked]>
	EOF
	git -c trailer.report.key="Reported-by: " \
		-c trailer.report.ifexists="replace" \
		-c trailer.report.command="NAME=\"\$ARG\"; test -n \"\$NAME\" && \
		git log --author=\"\$NAME\" -1 --format=\"format:%aN <%aE>\" || true" \
		commit --trailer "report = author" --amend &&
	git cat-file commit HEAD >commit.msg &&
	sed -e "1,/^\$/d" commit.msg >actual &&
	test_cmp expected actual

[main 6b1e5e9] hello
 Author: A U Thor <[email-masked]>
 1 file changed, 1 insertion(+)
[main 97c7a39] hello
 Author: A U Thor <[email-masked]>
 Date: Thu Apr 7 15:22:13 2005 -0700
 1 file changed, 1 insertion(+)
--- expected	2021-04-02 23:43:10.649082950 +0000
+++ actual	2021-04-02 23:43:10.673085111 +0000
@@ -4,4 +4,4 @@
 Signed-off-by: C1 E1
 Helped-by: C2 E2
 Mentored-by: C4 E4
-Reported-by: A U Thor <[email-masked]>
+Reported-by:
not ok 24 - commit --trailer with -c and command
#	
#		trailer_commit_base &&
#		cat >expected <<-\EOF &&
#		hello
#	
#		Signed-off-by: C O Mitter <[email-masked]>
#		Signed-off-by: C1 E1
#		Helped-by: C2 E2
#		Mentored-by: C4 E4
#		Reported-by: A U Thor <[email-masked]>
#		EOF
#		git -c trailer.report.key="Reported-by: " \
#			-c trailer.report.ifexists="replace" \
#			-c trailer.report.command="NAME=\"\$ARG\"; test -n \"\$NAME\" && \
#			git log --author=\"\$NAME\" -1 --format=\"format:%aN <%aE>\" || true" \
#			commit --trailer "report = author" --amend &&
#		git cat-file commit HEAD >commit.msg &&
#		sed -e "1,/^\$/d" commit.msg >actual &&
#		test_cmp expected actual
#