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

Re: [PATCH] completion: commit: complete configured trailer tokens

From
Philippe Blain <levraiphilippeblain@gmail.com>
Date
Sep 12, 2023, 12:02 UTC
Message-ID
<50d4fa5c-8648-a51a-43a0-416d7f2e3df6@gmail.com>
In-Reply-To
<20230911102017.1927468-1-martin.agren@gmail.com>
Hi Martin,
Le 2023-09-11 à 06:20, Martin Ågren a écrit :
Show 50 quoted lines
> Hi Philippe,
> 
>> Add a __git_trailer_tokens function to list the configured trailers
>> tokens, and use it in _git_commit to suggest the configured tokens,
>> suffixing the completion words with ':' so that the user only has to add
>> the trailer value.
> 
> Makes sense.
> 
> I've never dabbled in the completion scripts, so take the following with
> some salt.
> 
>> +__git_trailer_tokens ()
>> +{
>> +	git config --name-only --get-regexp trailer.\*.key | awk -F. '{print $2}'
>> +}
> 
> The rest of this script uses `__git config` rather than `git config`.
> The purpose of `__git` seems to be to respect options given on the
> command line, so I think we would want to use it here.
> 
> These "." in "trailer." and ".key" will match any character. We also
> don't anchor this at beginning and end. Maybe tighten this a bit and use
> '^trailer\..*\.key$' to behave better in the face of config such as
> this:
> 
> 	[strailer]
> 		skeying = "s"
> 	[trailerx]
> 		keyx = "x"
> 
> Another thing. Consider such a config:
> 
> 	[trailer "q.p"]
> 		key = "Q-p-by"
> 
> The "trailer.q.p.key" config above ends up completing as just "q"
> because of how you use `print $2`. I see that `git commit --trailer=`
> itself is fairly relaxed here, so `--trailer=q` effectively ends up
> picking up "q.p" in the end. Tightening that is obviously out of scope
> here and I have no opinion if the current behavior there is intended.
> But maybe we should be a bit less relaxed here and complete to "q.p"? At
> any rate, it gets weird when you also have "trailer.q.x.key" in your
> config but we still just suggest the one "q".
> 
> I see your patch is in next, but maybe some of this tightening might be
> worthwhile doing on top of it?
> 
> Martin
> 

These are all good suggestions. I'll send a new version with these fixes on top.

Thanks,
Philippe.
Previous: Martin ÅgrenNext: Philippe Blain via GitGitGadget
Message 4 of 9 in “completion: commit: complete configured trailer tokens”
  1. completion: commit: complete configured trailer tokensPhilippe Blain via GitGitGadget, Sep 7, 2023
  2. Junio C HamanoSep 7, 2023
  3. Martin ÅgrenSep 11, 2023
  4. Philippe BlainSep 12, 2023
  5. 0/2 completion: commit: complete configured trailer tokensPhilippe Blain via GitGitGadget, Sep 12, 2023
  6. 1/2 completion: commit: complete configured trailer tokensPhilippe Blain via GitGitGadget, Sep 12, 2023
  7. 2/2 completion: commit: complete trailers tokens more robustlyPhilippe Blain via GitGitGadget, Sep 12, 2023
  8. Junio C HamanoSep 13, 2023
  9. ZheNing HuSep 16, 2023

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.