[PATCH v2 2/2] completion: commit: complete trailers tokens more robustly
- From
Philippe Blain via GitGitGadget <gitgitgadget@gmail.com>
- Date
- Sep 12, 2023, 17:30 UTC
- Message-ID
- <9cb33c20294e096f5345fb1ea9d80a23e899ae6f.1694539827.git.gitgitgadget@gmail.com>
- In-Reply-To
- <pull.1583.v2.git.1694539827.gitgitgadget@gmail.com>
From: Philippe Blain <levraiphilippeblain@gmail.com>
In the previous commit, we added support for completing configured trailer tokens in 'git commit --trailer'.
Make the implementation more robust by:
- using '__git' instead of plain 'git', as the rest of the completion script does - using a stricter pattern for --get-regexp to avoid false hits - using 'cut' and 'rev' instead of 'awk' to account for tokens including dots.
Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com> --- contrib/completion/git-completion.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index b5eb75aadc5..c23465886e0 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -1679,7 +1679,7 @@ __git_untracked_file_modes="all no normal" __git_trailer_tokens () { - git config --name-only --get-regexp trailer.\*.key | awk -F. '{print $2}' + __git config --name-only --get-regexp '^trailer\..*\.key$' | cut -d. -f 2- | rev | cut -d. -f2- | rev } _git_commit ()
-- gitgitgadget