From: Ben Knoble <ben.knoble@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org,
"Philippe Blain" <levraiphilippeblain@gmail.com>,
"Leo Kerin Britton" <britton.kerin@gmail.com>,
"Elijah Newren" <newren@gmail.com>,
"Rubén Justo" <rjusto@gmail.com>,
"Patrick Steinhardt" <ps@pks.im>,
"Gábor SZEDER" <szeder.dev@gmail.com>
Subject: Re: [PATCH 2/2] completion: complete tracked paths for "git checkout"
Date: Tue, 11 Aug 2026 12:32:05 -0400 [thread overview]
Message-ID: <834FE315-FB34-47B7-9ACF-FC8194FBE8D5@gmail.com> (raw)
In-Reply-To: <xmqqmrut4a1l.fsf@gitster.g>
>
> Le 10 août 2026 à 23:21, Junio C Hamano <gitster@pobox.com> a écrit :
>
> When completing arguments for "git checkout", _git_checkout()
> delegates to __git_complete_refs(), which only completes revision
> references. This is good, as mixing revisions and paths in a single
> list from which the user can choose is confusing. However, if no
> reference matches, or if "--" is given, _git_checkout() leaves
> COMPREPLY empty. Bash then falls back to the default filename
> completion in $PWD.
>
> This fails when "git -C <path>" is used, as $PWD is not the target
> repository.
>
> Update _git_checkout() to use __git_complete_index_file() when "--"
> is present, or when revision reference completion yields no matching
> candidates, so that tracked paths are offered as candidates.
>
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
> contrib/completion/git-completion.bash | 4 ++++
> t/t9902-completion.sh | 27 ++++++++++++++++++++++++++
> 2 files changed, 31 insertions(+)
>
> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> index 38dec1cabe..bd4b6e9247 100644
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -1780,6 +1780,10 @@ _git_checkout ()
> ;;
> esac
> fi
> +
> + if [ ${#COMPREPLY[@]} -eq 0 ]; then
> + __git_complete_index_file
> + fi
> }
Assuming the prior step was purely mechanical, which I did not validate, this looks reasonable to me.
next prev parent reply other threads:[~2026-08-11 16:32 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-11 3:19 [PATCH 0/2] completion of 'git [-C <dir>] checkout' Junio C Hamano
2026-08-11 3:21 ` [PATCH 1/2] completion: no-op refactoring of checkout completion Junio C Hamano
2026-08-11 3:21 ` [PATCH 2/2] completion: complete tracked paths for "git checkout" Junio C Hamano
2026-08-11 16:32 ` Ben Knoble [this message]
2026-08-11 17:25 ` Junio C Hamano
2026-08-11 4:04 ` [PATCH 0/2] completion of 'git [-C <dir>] checkout' Junio C Hamano
2026-08-11 16:33 ` Ben Knoble
2026-08-12 1:45 ` Junio C Hamano
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=834FE315-FB34-47B7-9ACF-FC8194FBE8D5@gmail.com \
--to=ben.knoble@gmail.com \
--cc=britton.kerin@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=levraiphilippeblain@gmail.com \
--cc=newren@gmail.com \
--cc=ps@pks.im \
--cc=rjusto@gmail.com \
--cc=szeder.dev@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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