ZSH git add completion problems

Bug #1862338 reported by Gonzalo Peci
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
zsh (Ubuntu)
New
Undecided
Unassigned

Bug Description

There seem to be a problem when trying to autocomplete some git commands due to a bad prefix detection for "git ls-files".

If you check the new version of this package in the Arch repos, along with other updates you can find this file update:

> /usr/share/zsh/functions/Completion/Unix/_git
------
diff --git i/git.zsh w/git.zsh
index cf95bcd..745a57c 100644
--- i/git.zsh
+++ w/git.zsh
@@ -6625,7 +6625,7 @@ __git_files () {
   local pref=$gitcdup$gitprefix$PREFIX

   # First allow ls-files to pattern-match in case of remote repository
- files=(${(0)"$(_call_program files git ls-files -z --exclude-standard ${(q)opts} -- ${(q)${pref:+$pref\\\*}} 2>/dev/null)"})
+ files=(${(0)"$(_call_program files git ls-files -z --exclude-standard ${(q)opts} -- ${(q)${pref:+$pref\*}:-.} 2>/dev/null)"})
   __git_command_successful $pipestatus || return

   # If ls-files succeeded but returned nothing, try again with no pattern
------

If this is not applied, the command basically becomes:
> git ls-files -z --exclude-standard --others -- \'\'
when on the root of the git repository and fails with:
> fatal: empty string is not a valid pathspec. please use . instead if you meant to match all paths

This affects the "git add<tab>" command autocompletion and potentially others.

PS: This seems to be in "zsh-commons" but the report form did not allow me to select it

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.