All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Lutz Lengemann via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org,  Lutz Lengemann <lutz@lengemann.net>,
	 "D. Ben Knoble" <ben.knoble@gmail.com>
Subject: Re: [PATCH v2] completion: zsh: support completion after "git -C <path>"
Date: Wed, 26 Aug 2026 15:04:43 -0700	[thread overview]
Message-ID: <xmqqld9sczd0.fsf@gitster.g> (raw)
In-Reply-To: <pull.2155.v2.git.1787144872870.gitgitgadget@gmail.com> (Lutz Lengemann via GitGitGadget's message of "Wed, 19 Aug 2026 13:07:51 +0000")

"Lutz Lengemann via GitGitGadget" <gitgitgadget@gmail.com> writes:

> From: Lutz Lengemann <lutz@lengemann.net>
>
> The zsh completion wrapper does not handle the global -C option, so
>
> 	git -C <path> <command> <TAB>
>
> offers nothing.  -C is not part of the _arguments specification, and the
> wrapper hard-codes __git_cmd_idx=1, i.e. it assumes that the command is
> the first argument, so the bash helpers look at the wrong word.  The
> latter is not specific to -C; the assumption breaks after any global
> option, e.g. "git -p checkout <TAB>" does not complete branch names.
>
> Add -C to the specification, and find the command by skipping over the
> global options and, where they take one, their arguments, as __git_main
> in git-completion.bash does.  The index is one less than zsh's, as the
> helpers count the words from zero.  Collect the paths given to -C into
> __git_C_args, or else the helpers run git in the current directory and
> fail to resolve the aliases and refs of the repository the command runs
> in.
>
> The argument of a -C is still completed without regard for the -C
> options before it, i.e. "git -C dir -C <TAB>" offers the directories in
> ".", not the ones in "dir".
>
> Signed-off-by: Lutz Lengemann <lutz@lengemann.net>
> ---

Let me mark the topic for 'next', as later parts of the thread was
about an unrelated tangent.


      parent reply	other threads:[~2026-08-26 22:04 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-17 15:30 [PATCH] completion: zsh: support completion after "git -C <path>" Lutz Lengemann via GitGitGadget
2026-06-17 17:17 ` Ben Knoble
2026-06-17 17:21 ` Junio C Hamano
2026-06-18 17:43 ` D. Ben Knoble
2026-07-14 22:34   ` D. Ben Knoble
2026-08-17 19:29     ` Lutz Lengemann
2026-08-18 12:13       ` D. Ben Knoble
2026-08-18 12:40         ` Lutz Lengemann
2026-08-18 16:35           ` D. Ben Knoble
2026-08-19 13:07 ` [PATCH v2] " Lutz Lengemann via GitGitGadget
2026-08-20 12:28   ` D. Ben Knoble
2026-08-20 21:39     ` Junio C Hamano
2026-08-21 12:31       ` D. Ben Knoble
2026-08-21 16:42         ` Junio C Hamano
2026-08-26 22:04   ` Junio C Hamano [this message]

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=xmqqld9sczd0.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=ben.knoble@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=lutz@lengemann.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.