1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-01-01 05:16:05 +01:00

39921: __git_recent_branches: Remove erroneous parsing of partial ref names as tags.

In the reflog, partial ref names in the "from" field always represent names of
heads.  (That is not true for the "to" field.)  The parsing of tag names was
added in commit 39102 (317c96b64f) for equivalence
with the then-previous implementation which used `git log $partial_ref_name`.
The equivalence was correct, however, the then-previous implementation was not,
since it would consider $partial_ref_name as a refs/tags/ name if a refs/heads/
name did not exist.
This commit is contained in:
Daniel Shahaf 2016-11-12 01:01:29 +00:00
parent d7b57cc957
commit 297471cf77
2 changed files with 6 additions and 3 deletions

View file

@ -1,5 +1,8 @@
2016-11-17 Daniel Shahaf <d.s@daniel.shahaf.name>
* 39921: Completion/Unix/Command/_git: __git_recent_branches:
Remove erroneous parsing of partial ref names as tags.
* 39922: Completion/Unix/Command/_git: __git_recent_branches:
Fix an 'assertion' failure when two branches (refs) point to
the same commit.

View file

@ -6079,7 +6079,7 @@ __git_recent_branches() {
local -a branches
local -A descriptions
local -a reply
local -aU valid_ref_names_munged=( ${"${(f)"$(_call_program valid-ref-names 'git for-each-ref --format="%(refname)" refs/heads/ refs/tags/')"}"#refs/(heads|tags)/} )
local -aU valid_ref_names_munged=( ${"${(f)"$(_call_program valid-ref-names 'git for-each-ref --format="%(refname)" refs/heads/')"}"#refs/heads/} )
# 1. Obtain names of recently-checked-out branches from the reflog.
# 2. Remove ref names that that no longer exist from the list.
@ -6096,13 +6096,13 @@ __git_recent_branches() {
# 4. Obtain log messages for all of them in one shot.
# TODO: we'd really like --sort=none here... but git doesn't support such a thing.
# The \n removal is because for-each-ref prints a \n after each entry.
descriptions=( ${(0)"$(_call_program all-descriptions "git --no-pager for-each-ref --format='%(refname)%00%(subject)%00'" refs/heads/${(q)^branches} refs/tags/${(q)^branches} "--")"//$'\n'} )
descriptions=( ${(0)"$(_call_program all-descriptions "git --no-pager for-each-ref --format='%(refname)%00%(subject)%00'" refs/heads/${(q)^branches} "--")"//$'\n'} )
# 5. Synthesize the data structure _describe wants.
local -a branches_colon_descriptions
local branch
for branch in ${branches} ; do
branches_colon_descriptions+="${branch//:/\:}:${(v)descriptions[(I)(refs/heads/|refs/tags/)${(b)branch}]}"
branches_colon_descriptions+="${branch//:/\:}:${descriptions[refs/heads/${(b)branch}]}"
done
_describe -V -t recent-branches "recent branches" branches_colon_descriptions