Re: [PATCH v6] [GSOC] trailer: add new trailer.<token>.cmd config option
- From
ZheNing Hu <adlternative@gmail.com>
- Date
- Apr 4, 2021, 05:43 UTC
- Message-ID
- <CAOLTT8QvPPJ4jYXjch+RhdHDnvDT6Woh2oQoX2LcoiVX_t7jZQ@mail.gmail.com>
- In-Reply-To
- <xmqqim544dl4.fsf@gitster.g>
Hi, Junio and Christian,
Show 36 quoted lines
> > +------------ > > +$ cat ~/bin/git-one > > +#!/bin/sh > > +git show -s --pretty=reference "$1" > > +$ git config trailer.see.key "See-also: " > > +$ git config trailer.see.ifExists "replace" > > +$ git config trailer.see.ifMissing "doNothing" > > +$ git config trailer.see.cmd "~/bin/git-one" > > +$ git interpret-trailers <<EOF > > +> subject > > +> > > +> message > > +> > > +> see: HEAD~2 > > +> EOF > > +subject > > + > > +message > > + > > +See-also: fe3187e (subject of related commit, 2021-4-2) > > +------------ > > + > > +* Configure a 'who' trailer with a cmd use a global script `git-who` > > + to find the recent matching "author <mail>" pair in git log and > > + show how it works: > > ++ > > +------------ > > +$ cat ~/bin/git-who > > + #!/bin/sh > > + git log -1 --format="%an <%ae>" --author="$1" > > Unusual indentation here. But more importantly, I am not sure if > having both 'see' and 'help' examples is worth it---they are similar > enough that the second one does not teach anything new to those who > studied the first one already, aren't they? >
This may be an off-topic question: I wanted to use `shortlog -s` instead of the document example, But I found a very strange place: Here we have two shell scripts:
$ cat ~/bin/gcount #!/bin/sh if test "$1" != "" then git log -1 --author="$1" else echo "hello there" fi
cat ~/bin/gcount2 #!/bin/sh if test "$1" != "" then git shortlog -1 --author="$1" else echo "hello there" fi
If I use them in the terminal, there is no problem with them,
$ ~/bin/gcount gitster commit 142430338477d9d1bb25be66267225fb58498d92 (interpret-trailers-command-arg, abc5b) Author: Junio C Hamano <gitster@pobox.com> Date: Mon Mar 22 14:00:00 2021 -0700
The second batch
Signed-off-by: Junio C Hamano <gitster@pobox.com>
$ ~/bin/gcount2 gitster
Junio C Hamano (1):
The second batchif I use .cmd to run these scripts, the situation is totally different:
$ git config -l | grep trailer trailer.cnt.ifexists=add trailer.cnt.key=Cnt: trailer.cnt.cmd=~/bin/gcount
$ git interpret-trailers --trailer="cnt:gitster" <<EOF EOF
Cnt: hello there Cnt: commit 142430338477d9d1bb25be66267225fb58498d92 Author: Junio C Hamano <gitster@pobox.com> Date: Mon Mar 22 14:00:00 2021 -0700
The second batch
Signed-off-by: Junio C Hamano <gitster@pobox.com>
And if I turn to use gcount2: $ git config trailer.cnt.cmd "~/bin/gcount2" $ git interpret-trailers --trailer="cnt:gitster" <<EOF EOF
Cnt: hello there Cnt:
It looks like `shortlog` does not write to standard output. Note that in `short_log.c`, log will be output to `log->file`. Does it make the above behavior different? Is there a good solution?
Show 19 quoted lines
> > +$ git config trailer.help.key "Helped-by: " > > +$ git config trailer.help.ifExists "replace" > > +$ git config trailer.help.cmd "~/bin/git-who" > > +$ git interpret-trailers --trailer="help:gitster@" <<EOF > > +> subject > > +> > > +> message > > +> > > +> EOF > > +subject > > + > > +message > > + > > +Helped-by: Junio C Hamano <gitster@pobox.com> > > +------------ > > + > > * Configure a 'see' trailer with a command to show the subject of a > > commit that is related, and show how it works: > > +