Re: [PATCH v10 11/12] Documentation: add documentation for 'git interpret-trailers'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Apr 29, 2014 at 1:05 PM, Jeremy Morton <admin@xxxxxxxxxxxxxx> wrote:
> On 28/04/2014 17:37, Junio C Hamano wrote:
>>
>> Christian Couder<chriscool@xxxxxxxxxxxxx>  writes:
>>
>>> From: Junio C Hamano<gitster@xxxxxxxxx>
>>>>
>>>>
>>>> Christian Couder<chriscool@xxxxxxxxxxxxx>  writes:
>>>> ...
>>>
>>>
>>>>> +       trailer. After some alphanumeric characters, it can contain
>>>>> +       some non alphanumeric characters like ':', '=' or '#' that will
>>>>> +       be used instead of ':' to separate the token from the value in
>>>>> +       the trailer, though the default ':' is more standard.
>>>>
>>>>
>>>> I assume that this is for things like
>>>>
>>>>         bug #538
>>>>
>>>> and the configuration would say something like:
>>>>
>>>>         [trailer "bug"]
>>>>                 key = "bug #"
>>>>
>>>> For completeness (of this example), the bog-standard s-o-b would
>>>> look like
>>>>
>>>>         Signed-off-by: Christian Couder<chriscool@xxxxxxxxxxxxx>
>>>>
>>>> and the configuration for it that spell the redundant "key" would
>>>> be:
>>>>
>>>>         [trailer "Signed-off-by"]
>>>>                 key = "Signed-off-by: "
>>>
>>>
>>> Yeah, but you can use the following instead:
>>>
>>>         [trailer "s-o-b"]
>>>                 key = "Signed-off-by: "
>
>
> One thing I'm not quite understanding is where the "Christian
> Couder<chriscool@xxxxxxxxxxxxx>" bit comes from.  So you've defined the
> trailer token and key, but interpret-trailers then needs to get the value it
> will give for the key from somewhere.  Does it have to just be hardcoded in?
> We probably want some way to get various variables like current branch name,
> current git version, etc.  So in the case of always adding a trailer for the
> branch that the commit was checked in to at the time (Developed-on,
> Made-on-branch, Author-branch, etc. [I think my favourite is
> Made-on-branch]), you'd want something like:
>
>         [trailer "m-o-b"]
>                 key = "Made-on-branch: "
>                 value = "$currentBranch"
>
> ... resulting in the trailer (for example):
>         Made-on-branch: pacman-minigame

In the documentation patch, there is:

trailer.<token>.command::
       This option can be used to specify a shell command that will
       be used to automatically add or modify a trailer with the
       specified 'token'.

       When this option is specified, it is like if a special 'token=value'
       argument is added at the end of the command line, where 'value' will
       be given by the standard output of the specified command.

       If the command contains the `$ARG` string, this string will be
       replaced with the 'value' part of an existing trailer with the same
       token, if any, before the command is launched.

That's why Something like the following should work if "git commit"
automitically runs "git interpret-trailers":

         [trailer "m-o-b"]
                 key = "Made-on-branch: "
                 command = "git name-rev --name-only HEAD"


> Also, if there were no current branch name because you're committing in a
> detached head state, it would be nice if you could have some logic to
> determine that, and instead write the trailer as:
>         Made-on-branch: (detached HEAD: AB12CD34)

You may need to write a small script for that.
Then you just need the "trailer.m-o-b.command" config value to point
to your script.

> ... or whatever.  And also how about some logic to be able to say that if
> you're committing to the "master" branch, the trailer doesn't get inserted
> at all?

You can script that too.

Best,
Christian.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]