Skip to content

Commit c7153fa

Browse files
phil-blaingitster
authored andcommitted
completion: commit: complete configured trailer tokens
Since 2daae3d (commit: add --trailer option, 2021-03-23), 'git commit' can add trailers to commit messages. To make that feature more pleasant to use at the command line, update the Bash completion code to offer configured trailer tokens. 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. Signed-off-by: Philippe Blain <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1fc548b commit c7153fa

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

contrib/completion/git-completion.bash

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1677,6 +1677,11 @@ _git_clone ()
16771677

16781678
__git_untracked_file_modes="all no normal"
16791679

1680+
__git_trailer_tokens ()
1681+
{
1682+
git config --name-only --get-regexp trailer.\*.key | awk -F. '{print $2}'
1683+
}
1684+
16801685
_git_commit ()
16811686
{
16821687
case "$prev" in
@@ -1701,6 +1706,10 @@ _git_commit ()
17011706
__gitcomp "$__git_untracked_file_modes" "" "${cur##--untracked-files=}"
17021707
return
17031708
;;
1709+
--trailer=*)
1710+
__gitcomp_nl "$(__git_trailer_tokens)" "" "${cur##--trailer=}" ":"
1711+
return
1712+
;;
17041713
--*)
17051714
__gitcomp_builtin commit
17061715
return

0 commit comments

Comments
 (0)