]> git.ipfire.org Git - thirdparty/git.git/commit - contrib/completion/git-completion.bash
completion: don't disambiguate tags and branches
authorSZEDER Gábor <szeder.dev@gmail.com>
Thu, 23 Mar 2017 15:29:16 +0000 (16:29 +0100)
committerJunio C Hamano <gitster@pobox.com>
Thu, 23 Mar 2017 18:18:22 +0000 (11:18 -0700)
commit3ad8ea7ccc236cbe916e26c4ddf531ee2e24a772
treeaff2c2e1928e53d32d5d8f861c381dde9094d0ec
parentaed3881359027921afffae2c6da853034a42c64d
completion: don't disambiguate tags and branches

When the completion script has to list only tags or only branches, it
uses the 'git for-each-ref' format 'refname:short', which makes sure
that all listed tags and branches are unambiguous.  However,
disambiguating tags and branches in these cases is wrong, because:

  - __git_tags(), the helper function listing possible tagname
    arguments for 'git tag', lists an ambiguous tag
    'refs/tags/ambiguous' as 'tags/ambiguous'.  Its only consumer,
    'git tag' expects its tagname argument to be under 'refs/tags/',
    thus it interprets that abgiguous tag as
    'refs/tags/tags/ambiguous'.  Clearly wrong.

  - __git_heads() lists possible branchname arguments for 'git branch'
    and possible 'branch.<branchname>' configuration subsections.
    Both of these expect branchnames to be under 'refs/heads/' and
    misinterpret a disambiguated branchname like 'heads/ambiguous'.

Furthermore, disambiguation involves several stat() syscalls for each
tag or branch, thus comes at a steep cost especially on Windows and/or
when there are a lot of tags or branches to be listed.

Use the 'git for-each-ref' format 'refname:strip=2' instead of
'refname:short' to avoid harmful disambiguation of tags and branches
in __git_tags() and __git_heads().

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/completion/git-completion.bash