Re: Fix issue with formatting multiple trailer keys

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

 



On Fri, Sep 06, 2024 at 01:55:46PM -0600, Brooke Kuhlmann wrote:

> ``` 
> git tag --list \
>         --format="%(refname:short) %(taggerdate:short) %(taggername) %(subject) %(trailers:key=Files) %(trailers:key=Duration)"
> ```
> 
> ...I get this output:
> 
> 0.0.0 2024-09-06 Brooke Kuhlmann Version 0.0.0 Files: 1
> Duration: 1
>  Files: 1
> Duration: 1
> 
> 0.0.1 2024-09-06 Brooke Kuhlmann Version 0.0.1 Files: 1
> Duration: 1
>  Files: 1
> Duration: 1
> 
> Notice, when logging trailer information for commits and tags, I get
> unexpected new line characters showing up in the output. I expect to
> see all information printed on the same line without any new lines
> showing up.
> 
> Also, I want to point out that when listing tag trailers, I get the
> "Duration" key showing up twice. I'm not sure if that's related or not
> but seems like very weird behavior.

There are two things going on here:

  1. Some of the trailer options are stored in a global, rather than a
     per-placeholder basis. This includes the list of keys to show. So
     you basically end up with a filter list that includes _both_ keys,
     and that list is used for both %(trailers) items.

     IMHO this is a bug, and I have a patch (which I'll send along with
     the one I mentioned in the other thread) to fix it.

     In the meantime you can work around it by specifying both keys in
     a single invocation, like:

       %(trailers:key=Files,key=Duration)

     Obviously that doesn't work if you don't want them adjacent in the
     final output.

  2. By default, each trailer is terminated with a newline. But you can
     specify your own separator, like so:

       %(trailers:key=Files,key=Duration,separator= )

     See the documentation for the trailers placeholder in "git help
     log". Depending on your trailers, "valueonly" might also be useful
     for this kind of formatting.

-Peff




[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]

  Powered by Linux