Hi Martin, Le 2023-09-11 à 06:20, Martin Ågren a écrit : > 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.