Message ID | ea06be8f5ac77e5be64ab674f5a4fbe0b7e56c0e.1680548650.git.code@khaugsbakk.name (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [v2,1/3] doc: interpret-trailers: don’t use heredoc in examples | expand |
Kristoffer Haugsbakk <code@khaugsbakk.name> writes: > [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.” This may be a question more for Zhening than for you, but is the above a typo for "git commit -s", not "command"? > +$ 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?
On Mon, Apr 3, 2023, at 23:18, Junio C Hamano wrote: > 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. :)
"Kristoffer Haugsbakk" <code@khaugsbakk.name> writes: > On Mon, Apr 3, 2023, at 23:18, Junio C Hamano wrote: >> 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”. 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.
Kristoffer Haugsbakk <code@khaugsbakk.name> 于2023年4月4日周二 03:24写道: > > `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=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.” > 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. > Cc: ZheNing Hu <adlternative@gmail.com> > Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name> > --- > Documentation/git-interpret-trailers.txt | 9 ++++++--- > 1 file changed, 6 insertions(+), 3 deletions(-) > > diff --git a/Documentation/git-interpret-trailers.txt b/Documentation/git-interpret-trailers.txt > index dbbb6815c3..c76efae76a 100644 > --- a/Documentation/git-interpret-trailers.txt > +++ b/Documentation/git-interpret-trailers.txt > @@ -325,7 +325,7 @@ $ git interpret-trailers --trailer 'Cc: Alice <alice@example.com>' --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 <bob@example.com> > @@ -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 > -- > 2.40.0 > Thanks. -- ZheNing Hu
Junio C Hamano <gitster@pobox.com> 于2023年4月4日周二 05:18写道: > > Kristoffer Haugsbakk <code@khaugsbakk.name> writes: > > > [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.” > > 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. > > +$ 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?
On Wed, Apr 5, 2023, at 09:45, ZheNing Hu wrote: > 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. :)
diff --git a/Documentation/git-interpret-trailers.txt b/Documentation/git-interpret-trailers.txt index dbbb6815c3..c76efae76a 100644 --- a/Documentation/git-interpret-trailers.txt +++ b/Documentation/git-interpret-trailers.txt @@ -325,7 +325,7 @@ $ git interpret-trailers --trailer 'Cc: Alice <alice@example.com>' --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 <bob@example.com> @@ -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
`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=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.” Cc: ZheNing Hu <adlternative@gmail.com> Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name> --- Documentation/git-interpret-trailers.txt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)