Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[BUG] git checkout completion shows duplicated branch names



Steps to reproduce:

git init repo
cd repo
git commit --allow-empty -m 'Initial commit'
git checkout -b topic/foo
git checkout master

Now, when trying to complete to a branch name, here's what I see:

~/repo% git checkout <TAB>
e287376  -- [HEAD]    Initial commit (12 seconds ago)
topic/foo  master  -- Initial commit
HEAD                                                master
                                 topic/foo

Notice that branches appear twice. This only happens on versions newer
than 5.3.1, excluding this one.
A `git bisect` pointed me to commit e869952, which changed to using
the __git_recent_branches function,
which uses extracts branch names from the git reflog.

Furthermore, on versions prior to commit 4dddf3aa (< zsh-5.6), the
completion is even worse since a branch
is not fully completed even if there isn't any other branch with the
same prefix.

So typing this:

~/repo% git checkout topic/<TAB>
topic/foo  -- Initial commit
topic/foo

gets completed to `git checkout topic` instead of the full branch name.

So after version 5.6 and newer the bug is not that annoying because
the full branch name is indeed completed,
but there're still duplicated entries and I'd expect there to be
unique branch names.

If I knew enough about the completion system I would try to fix it,
but sometimes you have to let the hard stuff
to the pros.

Thanks,
Marc


Messages sorted by: Reverse Date, Date, Thread, Author