public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox•com>
To: "Philippe Blain via GitGitGadget" <gitgitgadget@gmail•com>
Cc: git@vger•kernel.org, ZheNing Hu <adlternative@gmail•com>,
	Philippe Blain <levraiphilippeblain@gmail•com>
Subject: Re: [PATCH] completion: commit: complete configured trailer tokens
Date: Thu, 07 Sep 2023 13:20:28 -0700	[thread overview]
Message-ID: <xmqqpm2tka5v.fsf@gitster.g> (raw)
In-Reply-To: <pull.1583.git.1694108551683.gitgitgadget@gmail.com> (Philippe Blain via GitGitGadget's message of "Thu, 07 Sep 2023 17:42:31 +0000")

"Philippe Blain via GitGitGadget" <gitgitgadget@gmail•com> writes:

> From: Philippe Blain <levraiphilippeblain@gmail•com>
>
> Since 2daae3d1d1 (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.

Nice attention to the details.

I do not use custom trailers myself, but I can see how this will be
useful.  The choice of the source of the information (i.e. the
configuration variables trailer.*.key) sounds sensible, too.

Will queue.  Thanks.

> Signed-off-by: Philippe Blain <levraiphilippeblain@gmail•com>
> ---
>     completion: commit: complete configured trailer tokens
>     
>     Since 2daae3d1d1 (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.
>
> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1583%2Fphil-blain%2Fcompletion-commit-trailers-v1
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1583/phil-blain/completion-commit-trailers-v1
> Pull-Request: https://github.com/gitgitgadget/git/pull/1583
>
>  contrib/completion/git-completion.bash | 9 +++++++++
>  1 file changed, 9 insertions(+)
>
> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> index 133ec92bfae..b5eb75aadc5 100644
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -1677,6 +1677,11 @@ _git_clone ()
>  
>  __git_untracked_file_modes="all no normal"
>  
> +__git_trailer_tokens ()
> +{
> +	git config --name-only --get-regexp trailer.\*.key | awk -F. '{print $2}'
> +}
> +
>  _git_commit ()
>  {
>  	case "$prev" in
> @@ -1701,6 +1706,10 @@ _git_commit ()
>  		__gitcomp "$__git_untracked_file_modes" "" "${cur##--untracked-files=}"
>  		return
>  		;;
> +	--trailer=*)
> +		__gitcomp_nl "$(__git_trailer_tokens)" "" "${cur##--trailer=}" ":"
> +		return
> +		;;
>  	--*)
>  		__gitcomp_builtin commit
>  		return
>
> base-commit: 1fc548b2d6a3596f3e1c1f8b1930d8dbd1e30bf3

  reply	other threads:[~2023-09-07 20:20 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-07 17:42 [PATCH] completion: commit: complete configured trailer tokens Philippe Blain via GitGitGadget
2023-09-07 20:20 ` Junio C Hamano [this message]
2023-09-11 10:20 ` Martin Ågren
2023-09-12 12:02   ` Philippe Blain
2023-09-12 17:30 ` [PATCH v2 0/2] " Philippe Blain via GitGitGadget
2023-09-12 17:30   ` [PATCH v2 1/2] " Philippe Blain via GitGitGadget
2023-09-12 17:30   ` [PATCH v2 2/2] completion: commit: complete trailers tokens more robustly Philippe Blain via GitGitGadget
2023-09-13  0:34     ` Junio C Hamano
2023-09-16 13:30 ` [PATCH] completion: commit: complete configured trailer tokens ZheNing Hu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqpm2tka5v.fsf@gitster.g \
    --to=gitster@pobox$(echo .)com \
    --cc=adlternative@gmail$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    --cc=gitgitgadget@gmail$(echo .)com \
    --cc=levraiphilippeblain@gmail$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox