"ZheNing Hu via GitGitGadget" <gitgitgadget@xxxxxxxxx> writes: > trailer.<token>.command:: > + This option can be used to specify a shell command that will be called: > + once to automatically add a trailer with the specified <token>, and then > + each time a '--trailer <token>=<value>' argument to modify the <value> of > + the trailer that this option would produce. > + > -When this option is specified, the behavior is as if a special > +When the specified command is first called to add a trailer > +with the specified <token>, the behavior is as if a special > +'--trailer <token>=<value>' argument was added at the beginning > +of the "git interpret-trailers" command, where <value> > +is taken to be the standard output of the command with any > +leading and trailing whitespace trimmed off. So, with [trailer "foo"] command = "echo $ARG" in your .git/config $ git interpret-trailers </dev/null gives 'foo:'. > +If some '--trailer <token>=<value>' arguments are also passed > +on the command line, the command is called again once for each > +of these arguments with the same <token>. And the <value> part > +of these arguments, if any, will be used to replace the first > +occurrence of substring `$ARG` in the command. This way the > +command can produce a <value> computed from the <value> passed > +in the '--trailer <token>=<value>' argument. > + > +For consistency, the first occurrence of substring `$ARG` is > +also replaced, this time with the empty string, in the command > +when the command is first called to add a trailer with the > +specified <token>. And then $ git interpret-trailers --trailer=foo:F </dev/null would give you foo: foo: F The above is quite an easy to read explanation of the behaviour. I somehow wonder if this "run with empty even without anything on the command line" a misfeature, and I'd prefer to iron it out before we add .cmd, because we may not want to inherit it to the new .cmd, just like we avoided '$ARG' that does not properly quote and replaces only once from getting inherited by .cmd mechanism. The reason why I suspect this may be a misfeature is because I do not see any way to avoid 'foo' trailer once trailer.foo.command is set. Which means I cannot use this mechanism to emulate "commit -s", which would hopefully be something like [trailer "signoff"] command = "git var GIT_COMMITTER_IDENT | sed -e 's/>.*/>/" ifexists = addIfDifferentNeighbor And trailer.signoff.ifmissing=donothing would not help in this case, either, I am afraid, as that would not just suppress the automatic empty one, which is fairly useless, but also suppresses the one that is made in response to the option from the command line. Christian? What's your thought on this? I can understand that it sometimes may be useful to unconditionally be able to add a trailer without doing anything from the command line, but it feels fairly useless that an empty one is automatically added, that the only way to hide that empty one from the end result is to use ifexists=replace, and that there is no apparent way to remove the empty one. The --trim-empty option is a bit too crude a band-aid to use, as the existing log message may have an unrelated trailer for which it is perfectly valid not to have any value. The fix we'd do when introducing .cmd should also get rid of this initial "run with an empty even when not asked"? Or if the execution without any input from the command line were truly useful sometimes, a configuration variable that disables this behaviour, i.e. [trailer "signoff"] command = "git who" ifexists = addIfDifferentNeighbor implicitExecution = false so that git commit --trailer=signoff:Couder --trailer=signoff:gitster@ would give us two sign-offs without the empty one, perhaps? In any case, the documentation update in this step looks reasonably well written. Thanks.