doc: interpret-trailers: remove trailing spaces
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH v2 1/3 doc: interpret-trailers: remove trailing spaces
--- Documentation/git-interpret-trailers.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
Documentation/git-interpret-trailers.txt +4 -4
@@ -408,9 +408,9 @@ $ git config trailer.see.ifMissing "doNothing" $ git config trailer.see.command "git log -1 --oneline --format=\"%h (%s)\" --abbrev-commit --abbrev=14 \$ARG" $ git interpret-trailers <<EOF > subject -> +> > message -> +> > see: HEAD~2 > EOF subject
@@ -429,9 +429,9 @@ See-also: fe3187489d69c4 (subject of related commit) ------------ $ sed -e 's/ Z$/ /' >commit_template.txt <<EOF > ***subject*** -> +> > ***message*** -> +> > Fixes: Z > Cc: Z > Reviewed-by: Z
Signature · 1 line
2.40.0
Quoted 1 line · Kristoffer Haugsbakk
Signed-off-by Kristoffer Haugsbakk <[email protected]>
It seems that my cover letter got denied since it contained non-ascii in the subject.
I’ll re-roll later.
Signature · 1 line
Kristoffer Haugsbakk
Quoted 1 line · Kristoffer Haugsbakk
I’ll re-roll later.
Interestingly though it worked for the third patch which had the same subject since it got encoded properly. But I pasted in the same subject manually in the cover letter.
Signature · 1 line
Kristoffer Haugsbakk
Quoted 10 lines · Kristoffer Haugsbakk
$ git interpret-trailers <<EOFQuoted 1 line
subject
->
+>Quoted 1 line
message
->
+>Quoted 2 lines
see: HEAD~2
EOFsubject
This example pretends as if the above was an interactive session the writer of the documentation did with a shell in a terminal, and these lines are trying to show that each line is prefixed with $PS2 (the secondary prompt string given by the shell for continued lines).
Taking that fact into account, it is arguably more correct to keep these spaces rather than removing them like this patch does, but of course it does not make a practical difference, because these spaces are invisible unless the reader reads the source documentation pages without passing them through AsciiDoc machinery.
The only folks that would be helped by this patch are those of us who edit one of these four lines of the source file (perhaps by replacing '>' with '|', such a patch tries to show use of a different $PS2) and are annoyed to see trailing whitespaces their patch inherited from the original trigger "git diff --check"; I wonder if that is a good enough justification.
I, however, do wonder if we should make our example more friendly to cutting and pasting. And I would not mind it if we got rid of these 4 trailing whitespaces as a side effect of such an effort.
One way to do so, while still pretending to show an actual session with an interactive shell, may be to give the example with an empty string set to $PS2, i.e.
$ git interpret-trailers <<\EOF
subject message
see: HEAD~2
EOF
subject
...but then it makes it a bit harder to see what is input and what is output. Showing with a separate intermediate file, i.e.
$ cat sample-message.txt
subject message
see: HEAD~2
$ git interpret-trailers <sample-message.txt
subject
...might make the result slightly easier to follow. I dunno.
The same comment applies to the other hunk.
Thanks.
Junio C Hamano <[email protected]> writes:
[jc: I forgot to cc the area expert, so here is a forward]
Quoted 68 lines
Quoted 10 lines · Kristoffer Haugsbakk
$ git interpret-trailers <<EOFQuoted 1 line
subject
->
+>Quoted 1 line
message
->
+>Quoted 2 lines
see: HEAD~2
EOFsubject
This example pretends as if the above was an interactive session the writer of the documentation did with a shell in a terminal, and these lines are trying to show that each line is prefixed with $PS2 (the secondary prompt string given by the shell for continued lines).
Taking that fact into account, it is arguably more correct to keep these spaces rather than removing them like this patch does, but of course it does not make a practical difference, because these spaces are invisible unless the reader reads the source documentation pages without passing them through AsciiDoc machinery.
The only folks that would be helped by this patch are those of us who edit one of these four lines of the source file (perhaps by replacing '>' with '|', such a patch tries to show use of a different $PS2) and are annoyed to see trailing whitespaces their patch inherited from the original trigger "git diff --check"; I wonder if that is a good enough justification.
I, however, do wonder if we should make our example more friendly to cutting and pasting. And I would not mind it if we got rid of these 4 trailing whitespaces as a side effect of such an effort.
One way to do so, while still pretending to show an actual session with an interactive shell, may be to give the example with an empty string set to $PS2, i.e.
$ git interpret-trailers <<\EOF subjectmessage see: HEAD~2 EOF subject ...but then it makes it a bit harder to see what is input and what is output. Showing with a separate intermediate file, i.e.
$ cat sample-message.txt subjectmessage see: HEAD~2 $ git interpret-trailers <sample-message.txt subject ...might make the result slightly easier to follow. I dunno.
The same comment applies to the other hunk.
Thanks.
v2 cover doc: interpret-trailers: don't use deprecated config
In reply to Kristoffer HaugsbakkReplace deprecated command with cmd (patch 2). While visiting this file also rewrite heredoc examples to use files which are shown with cat(1) (patch 1) and fix two examples that didn’t work properly (patch 3).
§ Changes in v2
First of all I had to send a second version since I messed up sending my v1 cover letter (unencoded Unicode in the subject). But I ended up doing quite a few changes:
1. Patch 1: Junio had some alternative suggestions. Remove trailing spaces by using files which are shown with cat(1) and thereby make it easier to copy-paste from the docs.
2. Patch 2: Fix discrepancy (see/sign) in commit message (thanks to Andrei Rybak)
3. Patch 2: minor commit message correction
4. Patch 3: Fix another example and build on top of it by using the typical “subject/message” format instead of an empty file and an s-o-b file (a file with just an s-o-b trailer)
Kristoffer Haugsbakk (3):
doc: interpret-trailers: don’t use heredoc in examples
doc: interpret-trailers: don’t use deprecated config
doc: interpret-trailers: fix examples
Documentation/git-interpret-trailers.txt | 93 +++++++++++++----------- 1 file changed, 52 insertions(+), 41 deletions(-)
Range-diff against v1:
1: b57fac21e4 < -: ---------- doc: interpret-trailers: remove trailing spaces 2: d85e955ff2 < -: ---------- doc: interpret-trailers: don’t use deprecated config 3: bd6b78a707 < -: ---------- doc: interpret-trailers: fix example -: ---------- > 1: 38f9a4bdf8 doc: interpret-trailers: don’t use heredoc in examples -: ---------- > 2: ea06be8f5a doc: interpret-trailers: don’t use deprecated config -: ---------- > 3: 14555cf87f doc: interpret-trailers: fix examples
--
2.40.0
v3 cover doc: interpret-trailers: don't use deprecated config
Replace deprecated command with cmd (patch 3). While visiting this file also:
• rewrite heredoc examples to use files which are shown with cat(1) (patch 1);
• use input redirection instead of using cat(1) piped into git interpret-trailers (patch 2); and
• fix an example that didn’t work properly (patch 4).
§ Changes in v3
• All patches: drop “Cc” trailers
• Patch 1: Use input redirection instead of cat msg.txt | git […]
• Patch 2: New
• Patch 3: Add “acked” trailer
• Patch 4: Tweak commit message
Kristoffer Haugsbakk (4):
doc: interpret-trailers: don’t use heredoc in examples
doc: interpret-trailers: use input redirection
doc: interpret-trailers: don’t use deprecated config
doc: interpret-trailers: fix example
Documentation/git-interpret-trailers.txt | 97 ++++++++++++++---------- 1 file changed, 55 insertions(+), 42 deletions(-)
Range-diff against v2:
1: 38f9a4bdf8 ! 1: fd515ad8b4 doc: interpret-trailers: don’t use heredoc in examples
@@ Commit message
interpret-trailers', 2014-10-13)
- Cc: Christian Couder <[email protected]>
-
- ## Notes (series) ##
- This was one of the suggestions by Junio[1]
-
- > Showing with a separate intermediate file, i.e.
- > [snip]
- > might make the result slightly easier to follow. I dunno.
-
- [1]: https://lore.kernel.org/git/[email protected]/
-
## Documentation/git-interpret-trailers.txt ##
@@ Documentation/git-interpret-trailers.txt: $ git config trailer.sign.key "Signed-off-by: "
$ git config trailer.sign.ifmissing add
@@ Documentation/git-interpret-trailers.txt: $ git config trailer.sign.key "Signed-
$ git config trailer.sign.command 'echo "$(git config user.name) <$(git config user.email)>"'
-$ git interpret-trailers <<EOF
-> EOF
-+$ cat empty-msg.txt | git interpret-trailers
++$ git interpret-trailers <empty-msg.txt
-$ git interpret-trailers <<EOF
@@ Documentation/git-interpret-trailers.txt: $ git config trailer.sign.key "Signed-
-> EOF
+$ cat msg.txt
+Signed-off-by: Alice <[email protected]>
-+$ cat msg.txt | git interpret-trailers
++$ git interpret-trailers <msg.txt
------------
@@ Documentation/git-interpret-trailers.txt: Fix #42
-> message
->
-> EOF
-+$ cat msg.txt | git interpret-trailers --trailer="help:Junio" --trailer="help:Couder" ++$ git interpret-trailers --trailer="help:Junio" --trailer="help:Couder" <msg.txt
subject
message
@@ Documentation/git-interpret-trailers.txt: Helped-by: Christian Couder <christian
-> message
->
-> EOF
-+$ cat msg.txt | git interpret-trailers --trailer="ref:Add copyright notices." ++$ git interpret-trailers --trailer="ref:Add copyright notices." <msg.txt
subject
message
@@ Documentation/git-interpret-trailers.txt: Reference-to: 8bc9a0c769 (Add copyrigh
+subject
+
+message
++
++see: HEAD~2
$ git config trailer.see.key "See-also: "
$ git config trailer.see.ifExists "replace"
$ git config trailer.see.ifMissing "doNothing"
@@ Documentation/git-interpret-trailers.txt: Reference-to: 8bc9a0c769 (Add copyrigh
->
-> see: HEAD~2
-> EOF
-+$ cat msg.txt | git interpret-trailers
++$ git interpret-trailers <msg.txt
subject
message
@@ Documentation/git-interpret-trailers.txt: See-also: fe3187489d69c4 (subject of r
-> Reviewed-by: Z
-> Signed-off-by: Z
-> EOF
-+$ cat commit_template.txt
++$ cat temp.txt
+***subject***
+
+***message***
@@ Documentation/git-interpret-trailers.txt: See-also: fe3187489d69c4 (subject of r
+Cc: Z
+Reviewed-by: Z
+Signed-off-by: Z
-+$ sed --in-place -e 's/ Z$/ /' commit_template.txt
++$ sed -e 's/ Z$/ /' temp.txt > commit_template.txt
$ git config commit.template commit_template.txt
-$ cat >.git/hooks/commit-msg <<EOF
-> #!/bin/sh
-: ---------- > 2: 12f7b10462 doc: interpret-trailers: use input redirection 2: ea06be8f5a ! 3: dc1982f0d0 doc: interpret-trailers: don’t use deprecated config
@@ Commit message
better simulate the behavior of git command -s, 'trailer.<token>.cmd' will not automatically execute.”
- Cc: ZheNing Hu <[email protected]>
+ Acked-by: ZheNing Hu <[email protected]>
## Documentation/git-interpret-trailers.txt ##
@@ Documentation/git-interpret-trailers.txt: $ git interpret-trailers --trailer 'Cc
$ git config trailer.sign.ifexists doNothing
-$ git config trailer.sign.command 'echo "$(git config user.name) <$(git config user.email)>"' +$ git config trailer.sign.cmd 'echo "$(git config user.name) <$(git config user.email)>"'
- $ cat empty-msg.txt | git interpret-trailers
+ $ git interpret-trailers <empty-msg.txt
-@@ Documentation/git-interpret-trailers.txt: $ cat msg.txt
- subject
-
+@@ Documentation/git-interpret-trailers.txt: subject
message
+
+ see: HEAD~2
+$ cat ~/bin/glog-ref
+#!/bin/sh
+git log -1 --oneline --format="%h (%s)" --abbrev-commit --abbrev=14
@@ Documentation/git-interpret-trailers.txt: $ cat msg.txt
$ git config trailer.see.ifExists "replace"
$ git config trailer.see.ifMissing "doNothing"
-$ git config trailer.see.command "git log -1 --oneline --format=\"%h (%s)\" --abbrev-commit --abbrev=14 \$ARG"
--$ cat msg.txt | git interpret-trailers
+-$ git interpret-trailers <msg.txt
+$ git config trailer.see.cmd "glog-ref"
-+$ cat msg.txt | git interpret-trailers --trailer=see
++$ git interpret-trailers --trailer=see <msg.txt
subject
message
3: 14555cf87f ! 4: f6e5605107 doc: interpret-trailers: fix examples
@@ Metadata
Author: Kristoffer Haugsbakk <[email protected]>
## Commit message ##
- doc: interpret-trailers: fix examples
+ doc: interpret-trailers: fix example
We need to provide --trailer sign since the command won’t output anything if you don’t give it an input and/or a
- --trailer. Furthermore, the example where msg.txt already contains
- an s-o-b is wrong:
+ --trailer. Furthermore, the message which already contains an s-o-b is
+ wrong:
- $ cat msg.txt | git interpret-trailers --trailer sign
+ $ git interpret-trailers --trailer sign <msg.txt
- A file which only consists of one trailer line is not interpreted as the
- original example must have expected. So change the examples to use the
- typical “subject/message” file.
-
- Cc: Christian Couder <[email protected]>
- Signed-off-by: Kristoffer Haugsbakk <[email protected]>
+ This can’t be what was originally intended.
+ So change the messages in this example to use the typical
+ “subject/message” file.
- ## Notes (series) ##
- This isn’t just a quirk of this series but also happens on master:
-
- $ git config trailer.sign.ifmissing add
- $ git config trailer.sign.ifexists doNothing
- $ git config trailer.sign.command 'echo "$(git config user.name) <$(git config user.email)>"'
- $ git interpret-trailers <<EOF
- > EOF
- $ git interpret-trailers <<EOF
- Signed-off-by: Alice <[email protected]>
- > EOF
- Signed-off-by: Alice <[email protected]>
-
- Signed-off-by: Kristoffer Haugsbakk <[email protected]>
+ Signed-off-by: Kristoffer Haugsbakk <[email protected]>
## Documentation/git-interpret-trailers.txt ##
@@ Documentation/git-interpret-trailers.txt: $ git interpret-trailers --trailer 'Cc: Alice <[email protected]>' --trailer 'Re
@@ Documentation/git-interpret-trailers.txt: $ git interpret-trailers --trailer 'Cc
$ git config trailer.sign.ifmissing add
$ git config trailer.sign.ifexists doNothing
$ git config trailer.sign.cmd 'echo "$(git config user.name) <$(git config user.email)>"'
--$ cat empty-msg.txt | git interpret-trailers
-+$ cat msg1.txt | git interpret-trailers --trailer sign
+-$ git interpret-trailers <empty-msg.txt
++$ git interpret-trailers --trailer sign <msg1.txt
+subject
+
+message
@@ Documentation/git-interpret-trailers.txt: $ git interpret-trailers --trailer 'Cc
+message
+
--$ cat msg.txt | git interpret-trailers
-+$ cat msg2.txt | git interpret-trailers --trailer sign +-$ git interpret-trailers <msg.txt
++$ git interpret-trailers --trailer sign <msg2.txt
+subject
+
+message
--
2.40.0
PATCH v3 1/4 doc: interpret-trailers: don’t use heredoc in examples
This file contains four instances of trailing spaces from its inception in commit [1]. These spaces might be intentional, since a user would be prompted with > in an interactive session. On the one hand, this is a whitespace error according to git diff --check; on the other hand, the raw documentation—it makes no difference in the rendered output—is just staying faithful to the simulation of the interactive prompt.
Let’s get rid of these whitespace errors and also make the examples more friendly to cut-and-paste by replacing the heredocs with files which are shown with cat(1).
[1]: dfd66ddf5a (Documentation: add documentation for 'git
interpret-trailers', 2014-10-13)
--- Documentation/git-interpret-trailers.txt | 74 +++++++++++------------- 1 file changed, 35 insertions(+), 39 deletions(-)
Documentation/git-interpret-trailers.txt +35 -39
@@ -326,13 +326,12 @@ $ git config trailer.sign.key "Signed-off-by: " $ git config trailer.sign.ifmissing add $ git config trailer.sign.ifexists doNothing $ git config trailer.sign.command 'echo "$(git config user.name) <$(git config user.email)>"' -$ git interpret-trailers <<EOF -> EOF +$ git interpret-trailers <empty-msg.txt Signed-off-by: Bob <[email protected]> -$ git interpret-trailers <<EOF -> Signed-off-by: Alice <[email protected]> -> EOF +$ cat msg.txt +Signed-off-by: Alice <[email protected]> +$ git interpret-trailers <msg.txt Signed-off-by: Alice <[email protected]> ------------
@@ -357,15 +356,14 @@ Fix #42 $ cat ~/bin/glog-find-author #!/bin/sh test -n "$1" && git log --author="$1" --pretty="%an <%ae>" -1 || true +$ cat msg.txt +subject + +message $ git config trailer.help.key "Helped-by: " $ git config trailer.help.ifExists "addIfDifferentNeighbor" $ git config trailer.help.cmd "~/bin/glog-find-author" -$ git interpret-trailers --trailer="help:Junio" --trailer="help:Couder" <<EOF -> subject -> -> message -> -> EOF +$ git interpret-trailers --trailer="help:Junio" --trailer="help:Couder" <msg.txt subject message
@@ -382,15 +380,14 @@ Helped-by: Christian Couder <[email protected]> $ cat ~/bin/glog-grep #!/bin/sh test -n "$1" && git log --grep "$1" --pretty=reference -1 || true +$ cat msg.txt +subject + +message $ git config trailer.ref.key "Reference-to: " $ git config trailer.ref.ifExists "replace" $ git config trailer.ref.cmd "~/bin/glog-grep" -$ git interpret-trailers --trailer="ref:Add copyright notices." <<EOF -> subject -> -> message -> -> EOF +$ git interpret-trailers --trailer="ref:Add copyright notices." <msg.txt subject message
@@ -402,17 +399,17 @@ Reference-to: 8bc9a0c769 (Add copyright notices., 2005-04-07) commit that is related, and show how it works: + ------------ +$ cat msg.txt +subject + +message + +see: HEAD~2 $ git config trailer.see.key "See-also: " $ git config trailer.see.ifExists "replace" $ git config trailer.see.ifMissing "doNothing" $ git config trailer.see.command "git log -1 --oneline --format=\"%h (%s)\" --abbrev-commit --abbrev=14 \$ARG" -$ git interpret-trailers <<EOF -> subject -> -> message -> -> see: HEAD~2 -> EOF +$ git interpret-trailers <msg.txt subject message
@@ -427,22 +424,21 @@ See-also: fe3187489d69c4 (subject of related commit) to add a 'git-version' trailer: + ------------ -$ sed -e 's/ Z$/ /' >commit_template.txt <<EOF -> ***subject*** -> -> ***message*** -> -> Fixes: Z -> Cc: Z -> Reviewed-by: Z -> Signed-off-by: Z -> EOF +$ cat temp.txt +***subject*** + +***message*** + +Fixes: Z +Cc: Z +Reviewed-by: Z +Signed-off-by: Z +$ sed -e 's/ Z$/ /' temp.txt > commit_template.txt $ git config commit.template commit_template.txt -$ cat >.git/hooks/commit-msg <<EOF -> #!/bin/sh -> git interpret-trailers --trim-empty --trailer "git-version: \$(git describe)" "\$1" > "\$1.new" -> mv "\$1.new" "\$1" -> EOF +$ cat .git/hooks/commit-msg +#!/bin/sh +git interpret-trailers --trim-empty --trailer "git-version: \$(git describe)" "\$1" > "\$1.new" +mv "\$1.new" "\$1" $ chmod +x .git/hooks/commit-msg ------------
Signature · 1 line
2.40.0
Re: [PATCH v3 1/4] doc: interpret-trailers: don’t use heredoc in examples
Quoted 8 lines · Kristoffer Haugsbakk
Let’s get rid of these whitespace errors and also make the examples more friendly to cut-and-paste by replacing the heredocs with files which are shown with cat(1).
-$ git interpret-trailers <<EOF
-> EOF
+$ git interpret-trailers <empty-msg.txtSigned-off-by Bob <[email protected]>
Nobody created empty-msg.txt and readers need to guess that it is a file with 0-byte contents. Using "</dev/null" would have avoided the need for guessing.
But it seems that this goes away at the end of the series, so let's not worry too much about it ;-)
PATCH v3 2/4 doc: interpret-trailers: use input redirection
In reply to Kristoffer Haugsbakk---
Notes (series):
Documentation/git-interpret-trailers.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/git-interpret-trailers.txt +1 -1
@@ -280,7 +280,7 @@ $ cat msg.txt subject message -$ cat msg.txt | git interpret-trailers --trailer 'sign: Alice <[email protected]>' --trailer 'sign: Bob <[email protected]>' +$ git interpret-trailers --trailer 'sign: Alice <[email protected]>' --trailer 'sign: Bob <[email protected]>' <msg.txt subject message
Signature · 1 line
2.40.0
Re: [PATCH v3 2/4] doc: interpret-trailers: use input redirection
Quoted 3 lines · Kristoffer Haugsbakk
Suggested-by Junio C Hamano <[email protected]>Signed-off-by Kristoffer Haugsbakk <[email protected]>---
Perhaps explain why it is a good idea in the body of the message?
Instead of "cat"ting a single file into a pipe, redirect from the file to the standard input of the command on the downstream side of the pipe. This is more straight-forward, saves one extra process, and often makes the line shorter.
or something like that.
PATCH v3 3/4 doc: interpret-trailers: don’t use deprecated config
In reply to Kristoffer Haugsbakkcommand has been deprecated since commit c364b7ef51 (trailer: add new .cmd config option, 2021-05-03).
Use the commit message of c364b7ef51 as a guide to replace the use of $ARG and to use a script instead of an inline command.[1] Also, explicitly trigger the command by passing in --trailer=see, since this config is not automatically used.[2]
[1]: “Instead of "$ARG", users can refer to the value as positional
argument, $1, in their scripts.”
[2]: “At the same time, in order to allow git interpret-trailers to
better simulate the behavior of git command -s, 'trailer.<token>.cmd' will not automatically execute.”
--- Documentation/git-interpret-trailers.txt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
Documentation/git-interpret-trailers.txt +6 -3
@@ -325,7 +325,7 @@ $ git interpret-trailers --trailer 'Cc: Alice <[email protected]>' --trailer 'Re $ git config trailer.sign.key "Signed-off-by: " $ git config trailer.sign.ifmissing add $ git config trailer.sign.ifexists doNothing -$ git config trailer.sign.command 'echo "$(git config user.name) <$(git config user.email)>"' +$ git config trailer.sign.cmd 'echo "$(git config user.name) <$(git config user.email)>"' $ git interpret-trailers <empty-msg.txt Signed-off-by: Bob <[email protected]>
@@ -405,11 +405,14 @@ subject message see: HEAD~2 +$ cat ~/bin/glog-ref +#!/bin/sh +git log -1 --oneline --format="%h (%s)" --abbrev-commit --abbrev=14 $ git config trailer.see.key "See-also: " $ git config trailer.see.ifExists "replace" $ git config trailer.see.ifMissing "doNothing" -$ git config trailer.see.command "git log -1 --oneline --format=\"%h (%s)\" --abbrev-commit --abbrev=14 \$ARG" -$ git interpret-trailers <msg.txt +$ git config trailer.see.cmd "glog-ref" +$ git interpret-trailers --trailer=see <msg.txt subject message
Signature · 1 line
2.40.0
PATCH v3 4/4 doc: interpret-trailers: fix example
In reply to Kristoffer HaugsbakkWe need to provide --trailer sign since the command won’t output anything if you don’t give it an input and/or a--trailer. Furthermore, the message which already contains an s-o-b is wrong:
$ git interpret-trailers --trailer sign <msg.txt
Signed-off-by: Alice <[email protected]>This can’t be what was originally intended.
So change the messages in this example to use the typical “subject/message” file.
--- Documentation/git-interpret-trailers.txt | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)
Documentation/git-interpret-trailers.txt +17 -3
@@ -322,16 +322,30 @@ $ git interpret-trailers --trailer 'Cc: Alice <[email protected]>' --trailer 'Re 'Signed-off-by: ' already, and show how it works: + ------------ +$ cat msg1.txt +subject + +message $ git config trailer.sign.key "Signed-off-by: " $ git config trailer.sign.ifmissing add $ git config trailer.sign.ifexists doNothing $ git config trailer.sign.cmd 'echo "$(git config user.name) <$(git config user.email)>"' -$ git interpret-trailers <empty-msg.txt +$ git interpret-trailers --trailer sign <msg1.txt +subject + +message Signed-off-by: Bob <[email protected]> -$ cat msg.txt +$ cat msg2.txt +subject + +message + Signed-off-by: Alice <[email protected]> -$ git interpret-trailers <msg.txt +$ git interpret-trailers --trailer sign <msg2.txt +subject + +message Signed-off-by: Alice <[email protected]> ------------
Signature · 1 line
2.40.0
Re: [PATCH v3 0/4] doc: interpret-trailers: don't use deprecated config
In reply to Kristoffer HaugsbakkQuoted 8 lines · Kristoffer Haugsbakk
Replace deprecated
commandwithcmd(patch 3). While visiting this file also:• rewrite heredoc examples to use files which are shown with cat(1) (patch 1);
• use input redirection instead of using cat(1) piped intogit interpret-trailers(patch 2); and
• fix an example that didn’t work properly (patch 4).
This was a pleasant read. I had small nits here and there but overall the series is very well crafted.
Will queue. Thanks.
v4 cover doc: interpret-trailers: don't use deprecated config
In reply to Kristoffer HaugsbakkReplace deprecated command with cmd (patch 3). While visiting this file also:
• rewrite heredoc examples to use files which are shown with cat(1) (patch 1);
• use input redirection instead of using cat(1) piped into git interpret-trailers (patch 2); and
• fix an example that didn’t work properly (patch 4).
§ Changes in v4
• Patch 1: Use /dev/null instead of empty-msg.txt
• Patch 2: Expand commit message
Kristoffer Haugsbakk (4):
doc: interpret-trailers: don’t use heredoc in examples
doc: interpret-trailers: use input redirection
doc: interpret-trailers: don’t use deprecated config
doc: interpret-trailers: fix example
Documentation/git-interpret-trailers.txt | 97 ++++++++++++++---------- 1 file changed, 55 insertions(+), 42 deletions(-)
Range-diff against v3:
1: fd515ad8b4 ! 1: 149dcf964c doc: interpret-trailers: don’t use heredoc in examples
@@ Documentation/git-interpret-trailers.txt: $ git config trailer.sign.key "Signed-
$ git config trailer.sign.command 'echo "$(git config user.name) <$(git config user.email)>"'
-$ git interpret-trailers <<EOF
-> EOF
-+$ git interpret-trailers <empty-msg.txt
++$ git interpret-trailers </dev/null
-$ git interpret-trailers <<EOF
2: 12f7b10462 ! 2: 32483aa635 doc: interpret-trailers: use input redirection
@@ Metadata
## Commit message ##
doc: interpret-trailers: use input redirection
+ Use input redirection instead of invoking cat(1) on a single file. This
+ is more straightforward, saves a process, and often makes the line
+ shorter.
+
## Notes (series) ##
- Link: https://lore.kernel.org/git/[email protected]/
+ Junio suggested expanding the commit message:
+ https://lore.kernel.org/git/[email protected]/
## Documentation/git-interpret-trailers.txt ##
@@ Documentation/git-interpret-trailers.txt: $ cat msg.txt
3: dc1982f0d0 ! 3: 9ea4c4f916 doc: interpret-trailers: don’t use deprecated config
@@ Documentation/git-interpret-trailers.txt: $ git interpret-trailers --trailer 'Cc
$ git config trailer.sign.ifexists doNothing
-$ git config trailer.sign.command 'echo "$(git config user.name) <$(git config user.email)>"' +$ git config trailer.sign.cmd 'echo "$(git config user.name) <$(git config user.email)>"'
- $ git interpret-trailers <empty-msg.txt
+ $ git interpret-trailers </dev/null
@@ Documentation/git-interpret-trailers.txt: subject
4: f6e5605107 ! 4: 95760aafe8 doc: interpret-trailers: fix example
@@ Documentation/git-interpret-trailers.txt: $ git interpret-trailers --trailer 'Cc
$ git config trailer.sign.ifmissing add
$ git config trailer.sign.ifexists doNothing
$ git config trailer.sign.cmd 'echo "$(git config user.name) <$(git config user.email)>"'
--$ git interpret-trailers <empty-msg.txt
+-$ git interpret-trailers </dev/null
+$ git interpret-trailers --trailer sign <msg1.txt
+subject
+
--
2.40.1
PATCH v4 1/4 doc: interpret-trailers: don’t use heredoc in examples
This file contains four instances of trailing spaces from its inception in commit [1]. These spaces might be intentional, since a user would be prompted with > in an interactive session. On the one hand, this is a whitespace error according to git diff --check; on the other hand, the raw documentation—it makes no difference in the rendered output—is just staying faithful to the simulation of the interactive prompt.
Let’s get rid of these whitespace errors and also make the examples more friendly to cut-and-paste by replacing the heredocs with files which are shown with cat(1).
[1]: dfd66ddf5a (Documentation: add documentation for 'git
interpret-trailers', 2014-10-13)
--- Documentation/git-interpret-trailers.txt | 74 +++++++++++------------- 1 file changed, 35 insertions(+), 39 deletions(-)
Documentation/git-interpret-trailers.txt +35 -39
@@ -326,13 +326,12 @@ $ git config trailer.sign.key "Signed-off-by: " $ git config trailer.sign.ifmissing add $ git config trailer.sign.ifexists doNothing $ git config trailer.sign.command 'echo "$(git config user.name) <$(git config user.email)>"' -$ git interpret-trailers <<EOF -> EOF +$ git interpret-trailers </dev/null Signed-off-by: Bob <[email protected]> -$ git interpret-trailers <<EOF -> Signed-off-by: Alice <[email protected]> -> EOF +$ cat msg.txt +Signed-off-by: Alice <[email protected]> +$ git interpret-trailers <msg.txt Signed-off-by: Alice <[email protected]> ------------
@@ -357,15 +356,14 @@ Fix #42 $ cat ~/bin/glog-find-author #!/bin/sh test -n "$1" && git log --author="$1" --pretty="%an <%ae>" -1 || true +$ cat msg.txt +subject + +message $ git config trailer.help.key "Helped-by: " $ git config trailer.help.ifExists "addIfDifferentNeighbor" $ git config trailer.help.cmd "~/bin/glog-find-author" -$ git interpret-trailers --trailer="help:Junio" --trailer="help:Couder" <<EOF -> subject -> -> message -> -> EOF +$ git interpret-trailers --trailer="help:Junio" --trailer="help:Couder" <msg.txt subject message
@@ -382,15 +380,14 @@ Helped-by: Christian Couder <[email protected]> $ cat ~/bin/glog-grep #!/bin/sh test -n "$1" && git log --grep "$1" --pretty=reference -1 || true +$ cat msg.txt +subject + +message $ git config trailer.ref.key "Reference-to: " $ git config trailer.ref.ifExists "replace" $ git config trailer.ref.cmd "~/bin/glog-grep" -$ git interpret-trailers --trailer="ref:Add copyright notices." <<EOF -> subject -> -> message -> -> EOF +$ git interpret-trailers --trailer="ref:Add copyright notices." <msg.txt subject message
@@ -402,17 +399,17 @@ Reference-to: 8bc9a0c769 (Add copyright notices., 2005-04-07) commit that is related, and show how it works: + ------------ +$ cat msg.txt +subject + +message + +see: HEAD~2 $ git config trailer.see.key "See-also: " $ git config trailer.see.ifExists "replace" $ git config trailer.see.ifMissing "doNothing" $ git config trailer.see.command "git log -1 --oneline --format=\"%h (%s)\" --abbrev-commit --abbrev=14 \$ARG" -$ git interpret-trailers <<EOF -> subject -> -> message -> -> see: HEAD~2 -> EOF +$ git interpret-trailers <msg.txt subject message
@@ -427,22 +424,21 @@ See-also: fe3187489d69c4 (subject of related commit) to add a 'git-version' trailer: + ------------ -$ sed -e 's/ Z$/ /' >commit_template.txt <<EOF -> ***subject*** -> -> ***message*** -> -> Fixes: Z -> Cc: Z -> Reviewed-by: Z -> Signed-off-by: Z -> EOF +$ cat temp.txt +***subject*** + +***message*** + +Fixes: Z +Cc: Z +Reviewed-by: Z +Signed-off-by: Z +$ sed -e 's/ Z$/ /' temp.txt > commit_template.txt $ git config commit.template commit_template.txt -$ cat >.git/hooks/commit-msg <<EOF -> #!/bin/sh -> git interpret-trailers --trim-empty --trailer "git-version: \$(git describe)" "\$1" > "\$1.new" -> mv "\$1.new" "\$1" -> EOF +$ cat .git/hooks/commit-msg +#!/bin/sh +git interpret-trailers --trim-empty --trailer "git-version: \$(git describe)" "\$1" > "\$1.new" +mv "\$1.new" "\$1" $ chmod +x .git/hooks/commit-msg ------------
Signature · 1 line
2.40.1
PATCH v4 2/4 doc: interpret-trailers: use input redirection
In reply to Kristoffer HaugsbakkUse input redirection instead of invoking cat(1) on a single file. This is more straightforward, saves a process, and often makes the line shorter.
---
Notes (series):
Junio suggested expanding the commit message:
https://lore.kernel.org/git/[email protected]/
Documentation/git-interpret-trailers.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/git-interpret-trailers.txt +1 -1
@@ -280,7 +280,7 @@ $ cat msg.txt subject message -$ cat msg.txt | git interpret-trailers --trailer 'sign: Alice <[email protected]>' --trailer 'sign: Bob <[email protected]>' +$ git interpret-trailers --trailer 'sign: Alice <[email protected]>' --trailer 'sign: Bob <[email protected]>' <msg.txt subject message
Signature · 1 line
2.40.1
PATCH v4 3/4 doc: interpret-trailers: don’t use deprecated config
In reply to Kristoffer Haugsbakkcommand has been deprecated since commit c364b7ef51 (trailer: add new .cmd config option, 2021-05-03).
Use the commit message of c364b7ef51 as a guide to replace the use of $ARG and to use a script instead of an inline command.[1] Also, explicitly trigger the command by passing in --trailer=see, since this config is not automatically used.[2]
[1]: “Instead of "$ARG", users can refer to the value as positional
argument, $1, in their scripts.”
[2]: “At the same time, in order to allow git interpret-trailers to
better simulate the behavior of git command -s, 'trailer.<token>.cmd' will not automatically execute.”
--- Documentation/git-interpret-trailers.txt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
Documentation/git-interpret-trailers.txt +6 -3
@@ -325,7 +325,7 @@ $ git interpret-trailers --trailer 'Cc: Alice <[email protected]>' --trailer 'Re $ git config trailer.sign.key "Signed-off-by: " $ git config trailer.sign.ifmissing add $ git config trailer.sign.ifexists doNothing -$ git config trailer.sign.command 'echo "$(git config user.name) <$(git config user.email)>"' +$ git config trailer.sign.cmd 'echo "$(git config user.name) <$(git config user.email)>"' $ git interpret-trailers </dev/null Signed-off-by: Bob <[email protected]>
@@ -405,11 +405,14 @@ subject message see: HEAD~2 +$ cat ~/bin/glog-ref +#!/bin/sh +git log -1 --oneline --format="%h (%s)" --abbrev-commit --abbrev=14 $ git config trailer.see.key "See-also: " $ git config trailer.see.ifExists "replace" $ git config trailer.see.ifMissing "doNothing" -$ git config trailer.see.command "git log -1 --oneline --format=\"%h (%s)\" --abbrev-commit --abbrev=14 \$ARG" -$ git interpret-trailers <msg.txt +$ git config trailer.see.cmd "glog-ref" +$ git interpret-trailers --trailer=see <msg.txt subject message
Signature · 1 line
2.40.1
PATCH v4 4/4 doc: interpret-trailers: fix example
In reply to Kristoffer HaugsbakkWe need to provide --trailer sign since the command won’t output anything if you don’t give it an input and/or a--trailer. Furthermore, the message which already contains an s-o-b is wrong:
$ git interpret-trailers --trailer sign <msg.txt
Signed-off-by: Alice <[email protected]>This can’t be what was originally intended.
So change the messages in this example to use the typical “subject/message” file.
--- Documentation/git-interpret-trailers.txt | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)
Documentation/git-interpret-trailers.txt +17 -3
@@ -322,16 +322,30 @@ $ git interpret-trailers --trailer 'Cc: Alice <[email protected]>' --trailer 'Re 'Signed-off-by: ' already, and show how it works: + ------------ +$ cat msg1.txt +subject + +message $ git config trailer.sign.key "Signed-off-by: " $ git config trailer.sign.ifmissing add $ git config trailer.sign.ifexists doNothing $ git config trailer.sign.cmd 'echo "$(git config user.name) <$(git config user.email)>"' -$ git interpret-trailers </dev/null +$ git interpret-trailers --trailer sign <msg1.txt +subject + +message Signed-off-by: Bob <[email protected]> -$ cat msg.txt +$ cat msg2.txt +subject + +message + Signed-off-by: Alice <[email protected]> -$ git interpret-trailers <msg.txt +$ git interpret-trailers --trailer sign <msg2.txt +subject + +message Signed-off-by: Alice <[email protected]> ------------
Signature · 1 line
2.40.1
Re: [PATCH v4 0/4] doc: interpret-trailers: don't use deprecated config
In reply to Kristoffer HaugsbakkQuoted 9 lines · Kristoffer Haugsbakk
Replace deprecated
commandwithcmd(patch 3). While visiting this file also:• rewrite heredoc examples to use files which are shown with cat(1) (patch 1);
• use input redirection instead of using cat(1) piped intogit interpret-trailers(patch 2); and
• fix an example that didn’t work properly (patch 4).
Quoted 4 lines
§ Changes in v4
• Patch 1: Use
/dev/nullinstead ofempty-msg.txt
• Patch 2: Expand commit message
Looking good. Will replace. I'll ping Christian as the area expert just in case there is something obvious we missed, but let's aim to merge this down to 'next' soonish.
Thanks.
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH v2 1/3 doc: interpret-trailers: don’t use heredoc in examples
This file contains four instances of trailing spaces from its inception in commit [1]. These spaces might be intentional, since a user would be prompted with > in an interactive session. On the one hand, this is a whitespace error according to git diff --check; on the other hand, the raw documentation—it makes no difference in the rendered output—is just staying faithful to the simulation of the interactive prompt.
Let’s get rid of these whitespace errors and also make the examples more friendly to cut-and-paste by replacing the heredocs with files which are shown with cat(1).
[1]: dfd66ddf5a (Documentation: add documentation for 'git
interpret-trailers', 2014-10-13)
---
Notes (series):
This was one of the suggestions by Junio[1]
> Showing with a separate intermediate file, i.e. > [snip]
> might make the result slightly easier to follow. I dunno.
[1]: https://lore.kernel.org/git/[email protected]/
Documentation/git-interpret-trailers.txt | 72 +++++++++++------------- 1 file changed, 33 insertions(+), 39 deletions(-)
Documentation/git-interpret-trailers.txt +33 -39
@@ -326,13 +326,12 @@ $ git config trailer.sign.key "Signed-off-by: " $ git config trailer.sign.ifmissing add $ git config trailer.sign.ifexists doNothing $ git config trailer.sign.command 'echo "$(git config user.name) <$(git config user.email)>"' -$ git interpret-trailers <<EOF -> EOF +$ cat empty-msg.txt | git interpret-trailers Signed-off-by: Bob <[email protected]> -$ git interpret-trailers <<EOF -> Signed-off-by: Alice <[email protected]> -> EOF +$ cat msg.txt +Signed-off-by: Alice <[email protected]> +$ cat msg.txt | git interpret-trailers Signed-off-by: Alice <[email protected]> ------------
@@ -357,15 +356,14 @@ Fix #42 $ cat ~/bin/glog-find-author #!/bin/sh test -n "$1" && git log --author="$1" --pretty="%an <%ae>" -1 || true +$ cat msg.txt +subject + +message $ git config trailer.help.key "Helped-by: " $ git config trailer.help.ifExists "addIfDifferentNeighbor" $ git config trailer.help.cmd "~/bin/glog-find-author" -$ git interpret-trailers --trailer="help:Junio" --trailer="help:Couder" <<EOF -> subject -> -> message -> -> EOF +$ cat msg.txt | git interpret-trailers --trailer="help:Junio" --trailer="help:Couder" subject message
@@ -382,15 +380,14 @@ Helped-by: Christian Couder <[email protected]> $ cat ~/bin/glog-grep #!/bin/sh test -n "$1" && git log --grep "$1" --pretty=reference -1 || true +$ cat msg.txt +subject + +message $ git config trailer.ref.key "Reference-to: " $ git config trailer.ref.ifExists "replace" $ git config trailer.ref.cmd "~/bin/glog-grep" -$ git interpret-trailers --trailer="ref:Add copyright notices." <<EOF -> subject -> -> message -> -> EOF +$ cat msg.txt | git interpret-trailers --trailer="ref:Add copyright notices." subject message
@@ -402,17 +399,15 @@ Reference-to: 8bc9a0c769 (Add copyright notices., 2005-04-07) commit that is related, and show how it works: + ------------ +$ cat msg.txt +subject + +message $ git config trailer.see.key "See-also: " $ git config trailer.see.ifExists "replace" $ git config trailer.see.ifMissing "doNothing" $ git config trailer.see.command "git log -1 --oneline --format=\"%h (%s)\" --abbrev-commit --abbrev=14 \$ARG" -$ git interpret-trailers <<EOF -> subject -> -> message -> -> see: HEAD~2 -> EOF +$ cat msg.txt | git interpret-trailers subject message
@@ -427,22 +422,21 @@ See-also: fe3187489d69c4 (subject of related commit) to add a 'git-version' trailer: + ------------ -$ sed -e 's/ Z$/ /' >commit_template.txt <<EOF -> ***subject*** -> -> ***message*** -> -> Fixes: Z -> Cc: Z -> Reviewed-by: Z -> Signed-off-by: Z -> EOF +$ cat commit_template.txt +***subject*** + +***message*** + +Fixes: Z +Cc: Z +Reviewed-by: Z +Signed-off-by: Z +$ sed --in-place -e 's/ Z$/ /' commit_template.txt $ git config commit.template commit_template.txt -$ cat >.git/hooks/commit-msg <<EOF -> #!/bin/sh -> git interpret-trailers --trim-empty --trailer "git-version: \$(git describe)" "\$1" > "\$1.new" -> mv "\$1.new" "\$1" -> EOF +$ cat .git/hooks/commit-msg +#!/bin/sh +git interpret-trailers --trim-empty --trailer "git-version: \$(git describe)" "\$1" > "\$1.new" +mv "\$1.new" "\$1" $ chmod +x .git/hooks/commit-msg ------------
Signature · 1 line
2.40.0
Re: [PATCH v2 1/3] doc: interpret-trailers: don’t use heredoc in examples
Documentation/git-interpret-trailers.txt Fix #42 · line 362
Quoted 8 lines
Documentation/git-interpret-trailers.txt +4
-0@@ -357,15 +356,14 @@ Fix #42 $ cat ~/bin/glog-find-author #!/bin/sh test -n "$1" && git log --author="$1" --pretty="%an <%ae>" -1 || true +$ cat msg.txt +subject + +message
When I suggested to use "cat" to show contents, instead of pretending an interactive session, I didn't check if we already had examples, but it looks like we did, which is great.
Documentation/git-interpret-trailers.txt Fix #42 · line 366
Quoted 1 line
Documentation/git-interpret-trailers.txt +1
-0+$ cat msg.txt | git interpret-trailers --trailer="help:Junio" --trailer="help:Couder"
Do not "cat" a single file and pipe into another command. It will always be equivalent to redirecting that file into the command on the downstream, i.e.
$ git interpret-trailers --options <mst.txt
Documentation/git-interpret-trailers.txt See-also: fe3187489d69c4 (subject of related commit) · line 434
Quoted 1 line
Documentation/git-interpret-trailers.txt +1
-0+$ sed --in-place -e 's/ Z$/ /' commit_template.txt
Avoid "--in-place"; not everybody's "sed" has it.
Other than that, I didn't spot anything glaringly wrong.
Thanks for working on this series.
PATCH v2 2/3 doc: interpret-trailers: don’t use deprecated config
In reply to a message not in the archivecommand has been deprecated since commit c364b7ef51 (trailer: add new .cmd config option, 2021-05-03).
Use the commit message of c364b7ef51 as a guide to replace the use of $ARG and to use a script instead of an inline command.[1] Also, explicitly trigger the command by passing in --trailer=see, since this config is not automatically used.[2]
[1]: “Instead of "$ARG", users can refer to the value as positional
argument, $1, in their scripts.”
[2]: “At the same time, in order to allow git interpret-trailers to
better simulate the behavior of git command -s, 'trailer.<token>.cmd' will not automatically execute.”
--- Documentation/git-interpret-trailers.txt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
Documentation/git-interpret-trailers.txt +6 -3
@@ -325,7 +325,7 @@ $ git interpret-trailers --trailer 'Cc: Alice <[email protected]>' --trailer 'Re $ git config trailer.sign.key "Signed-off-by: " $ git config trailer.sign.ifmissing add $ git config trailer.sign.ifexists doNothing -$ git config trailer.sign.command 'echo "$(git config user.name) <$(git config user.email)>"' +$ git config trailer.sign.cmd 'echo "$(git config user.name) <$(git config user.email)>"' $ cat empty-msg.txt | git interpret-trailers Signed-off-by: Bob <[email protected]>
@@ -403,11 +403,14 @@ $ cat msg.txt subject message +$ cat ~/bin/glog-ref +#!/bin/sh +git log -1 --oneline --format="%h (%s)" --abbrev-commit --abbrev=14 $ git config trailer.see.key "See-also: " $ git config trailer.see.ifExists "replace" $ git config trailer.see.ifMissing "doNothing" -$ git config trailer.see.command "git log -1 --oneline --format=\"%h (%s)\" --abbrev-commit --abbrev=14 \$ARG" -$ cat msg.txt | git interpret-trailers +$ git config trailer.see.cmd "glog-ref" +$ cat msg.txt | git interpret-trailers --trailer=see subject message
Signature · 1 line
2.40.0
Re: [PATCH v2 2/3] doc: interpret-trailers: don’t use deprecated config
Quoted 3 lines · Kristoffer Haugsbakk
[2]: “At the same time, in order to allow
git interpret-trailersto
better simulate the behavior ofgit command -s, 'trailer.<token>.cmd' will not automatically execute.”
This may be a question more for Zhening than for you, but is the above a typo for "git commit -s", not "command"?
Quoted 2 lines
+$ git config trailer.see.cmd "glog-ref"
+$ cat msg.txt | git interpret-trailers --trailer=see
This is inherited from the original, but it is a poor practice to run "cat" on a single file and pipe the result to another command. Just redirect from the file into the downstream command instead, i.e.
$ git interpret-trailers <empty-msg.txt
Perhaps we should do that as a preliminary clean-up before these updates?
Re: [PATCH v2 2/3] doc: interpret-trailers: don’t use deprecated config
Quoted 2 lines · Junio C Hamano
Perhaps we should do that as a preliminary clean-up before these updates?
I think updating to use <msg.txt for existing (on master) examples would fit in as patch number 2, since I rewrite heredocs to use files in patch 1. The commit message for patch 2 would then say, “and let’s make things consistent for the other examples as well”.
Thanks for spotting that. :)
Signature · 1 line
Kristoffer Haugsbakk
Re: [PATCH v2 2/3] doc: interpret-trailers: don’t use deprecated config
Quoted 8 lines · Kristoffer Haugsbakk
Quoted 2 lines · Junio C Hamano
Perhaps we should do that as a preliminary clean-up before these updates?
I think updating to use
<msg.txtfor existing (onmaster) examples would fit in as patch number 2, since I rewrite heredocs to use files in patch 1. The commit message for patch 2 would then say, “and let’s make things consistent for the other examples as well”.
The suggestion to do so in a separate preliminary step was made because I had an impression that existing examples were full of these "cat file | command" patterns, and you were adjusting only some of them. If there were (I didn't count or re-check the file) say 10 such bad examples and you are only changing only two for the primary purpose of the patch (i.e. use interpret-trailers command correctly), updating the other 8 bad examples "while at it" would make the patch with unnecessarily noisy, and fixing the "cat file |" in a separate step may help us let each step of the series focus on one thing and do it well.
But I see there is only one or two existing "cat file | command", so I agree with you that it is more reasonable to do it there.
Thanks.
Re: [PATCH v2 2/3] doc: interpret-trailers: don’t use deprecated config
In reply to Junio C HamanoQuoted 10 lines · Junio C Hamano <[email protected]> 于2023年4月4日周二 05:18写道:
Quoted 3 lines · Kristoffer Haugsbakk
[2]: “At the same time, in order to allow
git interpret-trailersto
better simulate the behavior ofgit command -s, 'trailer.<token>.cmd' will not automatically execute.”This may be a question more for Zhening than for you, but is the above a typo for "git commit -s", not "command"?
Ah, indeed it was a typo.
Quoted 12 lines
Quoted 2 lines
+$ git config trailer.see.cmd "glog-ref"
+$ cat msg.txt | git interpret-trailers --trailer=seeThis is inherited from the original, but it is a poor practice to run "cat" on a single file and pipe the result to another command. Just redirect from the file into the downstream command instead, i.e.
$ git interpret-trailers <empty-msg.txtPerhaps we should do that as a preliminary clean-up before these updates?
Re: [PATCH v2 2/3] doc: interpret-trailers: don’t use deprecated config
In reply to Kristoffer HaugsbakkQuoted 9 lines · Kristoffer Haugsbakk <[email protected]> 于2023年4月4日周二 03:24写道:
commandhas been deprecated since commitc364b7ef51(trailer: add new .cmd config option, 2021-05-03).Use the commit message of
c364b7ef51as a guide to replace the use of$ARGand to use a script instead of an inline command.[1] Also, explicitly trigger the command by passing in--trailer=see, since this config is not automatically used.[2]
Quoted 6 lines
[1]: “Instead of "$ARG", users can refer to the value as positional
argument, $1, in their scripts.”
[2]: “At the same time, in order to allowgit interpret-trailersto
better simulate the behavior ofgit command -s, 'trailer.<token>.cmd' will not automatically execute.”
Changing these examples from command -> cmd makes sense. So users will tend to use 'cmd' instead of 'command' as much as possible when referring to examples.
Quoted 37 lines
Cc ZheNing Hu <[email protected]>Signed-off-by Kristoffer Haugsbakk <[email protected]>--- Documentation/git-interpret-trailers.txt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)Documentation/git-interpret-trailers.txt +6
-4@@ -325,7 +325,7 @@ $ git interpret-trailers --trailer 'Cc: Alice <[email protected]>' --trailer 'Re $ git config trailer.sign.key "Signed-off-by: " $ git config trailer.sign.ifmissing add $ git config trailer.sign.ifexists doNothing -$ git config trailer.sign.command 'echo "$(git config user.name) <$(git config user.email)>"' +$ git config trailer.sign.cmd 'echo "$(git config user.name) <$(git config user.email)>"' $ cat empty-msg.txt | git interpret-trailers Signed-off-by: Bob <[email protected]>@@ -403,11 +403,14 @@ $ cat msg.txt subject message +$ cat ~/bin/glog-ref +#!/bin/sh +git log -1 --oneline --format="%h (%s)" --abbrev-commit --abbrev=14 $ git config trailer.see.key "See-also: " $ git config trailer.see.ifExists "replace" $ git config trailer.see.ifMissing "doNothing" -$ git config trailer.see.command "git log -1 --oneline --format=\"%h (%s)\" --abbrev-commit --abbrev=14 \$ARG" -$ cat msg.txt | git interpret-trailers +$ git config trailer.see.cmd "glog-ref" +$ cat msg.txt | git interpret-trailers --trailer=see subject message --
Quoted 2 lines
2.40.0
Thanks.
--
ZheNing Hu
Re: [PATCH v2 2/3] doc: interpret-trailers: don’t use deprecated config
Quoted 3 lines · ZheNing Hu
Changing these examples from command -> cmd makes sense. So users will tend to use 'cmd' instead of 'command' as much as possible when referring to examples.
Thanks ZheNing. I’ll add an “ack” trailer to this patch. :)
Signature · 1 line
Kristoffer Haugsbakk
PATCH v2 3/3 doc: interpret-trailers: fix examples
In reply to a message not in the archiveWe need to provide --trailer sign since the command won’t output anything if you don’t give it an input and/or a --trailer. Furthermore, the example where msg.txt already contains an s-o-b is wrong:
$ cat msg.txt | git interpret-trailers --trailer sign
Signed-off-by: Alice <[email protected]>A file which only consists of one trailer line is not interpreted as the original example must have expected. So change the examples to use the typical “subject/message” file.
---
Notes (series):
This isn’t just a quirk of this series but also happens on master:
$ git config trailer.sign.ifmissing add
$ git config trailer.sign.ifexists doNothing
$ git config trailer.sign.command 'echo "$(git config user.name) <$(git config user.email)>"' $ git interpret-trailers <<EOF
> EOF
$ git interpret-trailers <<EOF
> EOF
Documentation/git-interpret-trailers.txt | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)
Documentation/git-interpret-trailers.txt +17 -3
@@ -322,16 +322,30 @@ $ git interpret-trailers --trailer 'Cc: Alice <[email protected]>' --trailer 'Re 'Signed-off-by: ' already, and show how it works: + ------------ +$ cat msg1.txt +subject + +message $ git config trailer.sign.key "Signed-off-by: " $ git config trailer.sign.ifmissing add $ git config trailer.sign.ifexists doNothing $ git config trailer.sign.cmd 'echo "$(git config user.name) <$(git config user.email)>"' -$ cat empty-msg.txt | git interpret-trailers +$ cat msg1.txt | git interpret-trailers --trailer sign +subject + +message Signed-off-by: Bob <[email protected]> -$ cat msg.txt +$ cat msg2.txt +subject + +message + Signed-off-by: Alice <[email protected]> -$ cat msg.txt | git interpret-trailers +$ cat msg2.txt | git interpret-trailers --trailer sign +subject + +message Signed-off-by: Alice <[email protected]> ------------
Signature · 1 line
2.40.0
PATCH v2 2/3 doc: interpret-trailers: don’t use deprecated config
In reply to a message not in the archivetrailer.sign.command has been deprecated since commit c364b7ef51 (trailer: add new .cmd config option, 2021-05-03).
Use the commit message of c364b7ef51 as a guide to replace the use of $ARG and to use a script instead of an inline command.[1] Also, explicitly trigger the command by passing in --trailer=sign, since this config is not automatically used.[2]
[1]: “Instead of "$ARG", users can refer to the value as positional
argument, $1, in their scripts.”
[2]: “At the same time, in order to allow git interpret-trailers to
better simulate the behavior of git command -s, 'trailer.<token>.cmd' will not automatically execute.”
--- Documentation/git-interpret-trailers.txt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
Documentation/git-interpret-trailers.txt +6 -3
@@ -325,7 +325,7 @@ $ git interpret-trailers --trailer 'Cc: Alice <[email protected]>' --trailer 'Re $ git config trailer.sign.key "Signed-off-by: " $ git config trailer.sign.ifmissing add $ git config trailer.sign.ifexists doNothing -$ git config trailer.sign.command 'echo "$(git config user.name) <$(git config user.email)>"' +$ git config trailer.sign.cmd 'echo "$(git config user.name) <$(git config user.email)>"' $ git interpret-trailers <<EOF > EOF
@@ -402,11 +402,14 @@ Reference-to: 8bc9a0c769 (Add copyright notices., 2005-04-07) commit that is related, and show how it works: + ------------ +$ cat ~/bin/glog-ref +#!/bin/sh +git log -1 --oneline --format="%h (%s)" --abbrev-commit --abbrev=14 $ git config trailer.see.key "See-also: " $ git config trailer.see.ifExists "replace" $ git config trailer.see.ifMissing "doNothing" -$ git config trailer.see.command "git log -1 --oneline --format=\"%h (%s)\" --abbrev-commit --abbrev=14 \$ARG" -$ git interpret-trailers <<EOF +$ git config trailer.see.cmd "glog-ref" +$ git interpret-trailers --trailer=see <<EOF > subject > > message
Signature · 1 line
2.40.0
Re: [PATCH 2/3] doc: interpret-trailers: don’t use deprecated config
I've noticed a discrepancy in this patch
Quoted 1 line · Kristoffer Haugsbakk
explicitly trigger the command by passing in
--trailer=sign, since
Commit message mentions "sign" as the value for "--trailer=" ...
Quoted 4 lines
-$ git config trailer.see.command "git log -1 --oneline --format=\"%h (%s)\" --abbrev-commit --abbrev=14 \$ARG" -$ git interpret-trailers <<EOF
+$ git config trailer.see.cmd "glog-ref"
+$ git interpret-trailers --trailer=see <<EOF
... but the new sample code uses "see" as the value.
Quoted 3 lines
Quoted 3 lines
subject
message
PATCH v2 3/3 doc: interpret-trailers: fix example
In reply to a message not in the archiveThis command won’t output anything if you don’t give it an input and/or a --trailer.
--- Documentation/git-interpret-trailers.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/git-interpret-trailers.txt +1 -1
@@ -326,7 +326,7 @@ $ git config trailer.sign.key "Signed-off-by: " $ git config trailer.sign.ifmissing add $ git config trailer.sign.ifexists doNothing $ git config trailer.sign.cmd 'echo "$(git config user.name) <$(git config user.email)>"' -$ git interpret-trailers <<EOF +$ git interpret-trailers --trailer sign <<EOF > EOF Signed-off-by: Bob <[email protected]>
Signature · 1 line
2.40.0