git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] completion: exclude previous file arguments in Zsh

From
SZEDER Gábor <szeder.dev@gmail.com>
Date
Oct 4, 2026, 08:07 UTC
Message-ID
<asIJO3CZ/P/2L4qi@szeder.dev>
In-Reply-To
<pull.2216.git.git.1791026527023.gitgitgadget@gmail.com>
On Sat, Oct 03, 2026 at 11:22:06AM +0000, Fionn via GitGitGadget wrote:
> We can get this with minor changes, however. Here we introduce an array
> __git_file_exclude which we populate with existing arguments and then
"existing arguments" of what?
> tell compadd to exclude them, which closely matches the Zsh _git
> completion behaviour (as well as common programs such as rm).
Show 5 quoted lines
> @@ -284,6 +284,8 @@ __git_zsh_main ()
>  
>  		(( $+opt_args[--help] )) && command='help'
>  
> +		__git_file_exclude=(${words[2,-1]:#${words[CURRENT]}})
I don't do Zsh, but that 2 as index looks suspicious.
What will be excluded in the following command line:
  git -C dir -C subdir -c foo.bar=baz add file1 file2 <TAB>

I think we should exclude only those arguments that come after the git command, in this case after "add", i.e. "file1" and "file2", but I suspect that everything starting with "dir" will get excluded.

> +
>  		words=( ${orig_words[@]} )
>  
>  		__git_zsh_bash_func $command
Previous: Fionn via GitGitGadgetNext: Fionn
Message 2 of 5 in “completion: exclude previous file arguments in Zsh”
  1. completion: exclude previous file arguments in ZshFionn via GitGitGadget, Oct 3, 2026
  2. SZEDER GáborOct 4, 2026
  3. FionnOct 4, 2026
  4. Junio C HamanoOct 4, 2026
  5. FionnOct 5, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.