git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Questions about trailer configuration semantics

From
Anders Waldenborg <anders@0x63.nu>
Date
Jul 28, 2020, 00:01 UTC
Message-ID
<871rkwqzi3.fsf@0x63.nu>
In-Reply-To
<xmqq5za8ftih.fsf@gitster.c.googlers.com>
Junio C Hamano writes:
Show 19 quoted lines
> Anders Waldenborg <anders@0x63.nu> writes:
>
>> From what I can understand it tries to match *both* on the second level
>> AND the value of .key (trailers.c:token_matches_item)
>
> Yuck, I do not know what were we thinking to design the behaviour
> like *that*.  Or it may be simply buggy.
>
>> $ printf '\na: 1\nb: 2\nc: 3\n' | \
>>   git -c 'trailer.A.key=B' interpret-trailers
>> B: 1
>> B: 2
>> c: 3
>
> I can understand the first one (i.e. "trailer.$name.$var" try to
> match $name as case insensitively) but not the second one.  There is
> not an single rule for "b" trailer, and we should be getting the
> same behaviour as the third line, i.e. the key not involved in
> rewriting is passed as-is.

I'm not so sure about that. Matching sometimes needs to happen on .key too. If this configuration is supposed to be useful (and as "shortcuts" has been mentioned before and is what tests does, I think it should be):

trailer.rb.key=Reviewed-By trailer.rb.ifexists=addifdifferent

then matching must look at key, not name. As the value of .key is what would have been written previously into the message.

E.g:
$ printf "\nReviewed-By: hi\n" | \
  git -c "trailer.rb.key=Reviewed-By" \
      -c "trailer.rb.ifexists=addifdifferent" \
      interpret-trailers --trailer "rb=hi"
Reviewed-By: hi

The opposite case, matching on name in input message I'm not sure where it is useful.

 $ printf "\nrb: hi\n" | \
   git -c "trailer.rb.key=Reviewed-By" \
       -c "trailer.rb.ifexists=addifdifferent" \
       interpret-trailers --trailer "rb=hi"
Reviewed-By: hi

The way I have understood it ".key" can be used for some different things:

 * Freeing up name to be used as a shortcut alias.
 * Defining the canonical capitalization when passing through trailers
 * Allowing specifying non default separator for that key.
I wonder if those uses could be split up.
So instead of this configuration:
 [trailer "rb"]
     key="Reviewed-By> "
that does all three of those. The configuration would be:
 [trailer "Reviewed-By"]
     separator="> "
     canonicalize=true
     alias=rb

that way the "name" part of the config always is the correct spelling and capitalization. "alias" could easily be a list of multiple alias if that is wanted. "alias" could be split into "inputalias" (matched against when reading trailers from stdin or a commit/tag message) and "optalias" (matched against when reading --trailer cmdline option, and %(trailers:key))

Previous: Junio C HamanoNext: Anders Waldenborg
Message 10 of 16 in “Questions about trailer configuration semantics”
  1. Anders WaldenborgJul 27, 2020
  2. Junio C HamanoJul 27, 2020
  3. Christian CouderJul 27, 2020
  4. Jeff KingJul 27, 2020
  5. Anders WaldenborgJul 27, 2020
  6. Jeff KingJul 27, 2020
  7. Junio C HamanoJul 27, 2020
  8. Anders WaldenborgJul 27, 2020
  9. Junio C HamanoJul 27, 2020
  10. Anders WaldenborgJul 28, 2020
  11. Anders WaldenborgJul 27, 2020
  12. Junio C HamanoJul 27, 2020
  13. Anders WaldenborgJul 27, 2020
  14. Christian CouderJul 28, 2020
  15. Jeff KingJul 28, 2020
  16. Junio C HamanoJul 28, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.