6

Whenever I press tab after entering git stash drop, I get the following error message (outputted thrice in a row):

_arguments:comparguments:325: invalid argument: _git-notes
_git-stash:88: command not found: (-q --quiet)-q[suppress all output]

The actual stash deletion still does work, but it's a hassle to have to list my stashes first before choosing.

I've tried uninstalling and reinstalling git, but to no avail.

If it helps, I upgraded recently to Ubuntu 20.04 from 19.10 and I don't recall this bug ever appearing in the previous OS version.

psdi
  • 61
  • 5
  • Looks like a mismatch between the autocomplete script for your Git, your Git itself, and/or your version of bash. Installing a new Git doesn't always update the autocompletion scripts. [This](https://stackoverflow.com/q/14970728/1256452) is for OSX, not Ubuntu, but is worth seeing. – torek May 14 '20 at 22:29
  • Have you found a solution to this? I'm facing the same issue. – SergioLeone May 21 '20 at 13:13
  • @SergioLeone I googled git autocompletion and came upon [this tutorial](https://medium.com/@oliverspryn/adding-git-completion-to-zsh-60f3b0e7ffbc) for adding autocompletion to zsh, the shell I use. While it does fix the error, whenever I press tab after `git stash drop stash@{`, it only adds another curly brace, which results to `git stash drop stash@{{`. – psdi May 22 '20 at 16:52
  • Doesn't look like a solution to me. The rest of the autocomplete functions work fine, only `git stash drop` is the problematic one (And actaully I've also started experiencing this on Ubuntu 20.04) I've opened an issue with omzsh for this, let's see what they say. – SergioLeone May 23 '20 at 14:14
  • Any updates on this issue? – Paul Jul 20 '20 at 00:56
  • 1
    Yes, the [issue](https://github.com/ohmyzsh/ohmyzsh/issues/8956) was closed because it is not a problem of ohmyzsh. – minterior Jul 28 '20 at 16:32
  • 1
    It seems that has been fixed by zsh-5.8-44-g754658aff (according to https://www.zsh.org/mla/workers/2020/msg00915.html) – minterior Jul 28 '20 at 16:58

1 Answers1

3

I found a temporary solution (until Ubuntu gets a later version of zsh with the fix) here:

https://github.com/ohmyzsh/ohmyzsh/issues/9264

This github issue references the zsh commit which fixes it: https://github.com/zsh-users/zsh/commit/754658aff38e1bdf487c58bec6174cbecd019d11

So - taken from those places you can do this to fix it:

  1. Run this to find the file you need to edit: ls -l ${^fpath}/_git(N)
  2. Edit the file, for me it was: vim /usr/share/zsh/functions/Completion/Unix/_git
    • On line 1812
      • Change from _arguments -S $endopt \_git-notes to _arguments -S $endopt \
  3. Close and reopen your zsh terminal.

The gstd command should now work fine without receiving errors. I did this a few months ago and it's been fine ever since. Had to do it on another machine which is why I ended up looking for this solution again. Thought I'd post here to help myself (and everyone else) for the future!

BT643
  • 3,495
  • 5
  • 34
  • 55
  • 2
    On macOS you have to copy `/usr/share/zsh/5.8/functions/_git` to `/usr/local/share/zsh/site-functions` before changing it as /usr/share is protected. – Marco Pelegrini Jan 14 '22 at 20:26