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

43879: vcs_info git: Fix fatal error in VCS_INFO_git_getbranch in corner case

Before this commit, the following use-case:

    git checkout foo^
    git show foo | git am

would result in a fatal error, with vcs_info_msg_N_ not set:

    VCS_INFO_git_getbranch:18: no such file or directory: .git/rebase-apply/onto

Now they are set correctly, and HEAD's commit hash is used.
This commit is contained in:
Daniel Shahaf 2018-12-09 19:41:19 +00:00
parent 90b2654b7e
commit 23154e46e6
2 changed files with 12 additions and 4 deletions

View file

@ -1,3 +1,9 @@
2018-12-13 Daniel Shahaf <d.s@daniel.shahaf.name>
* 43879: Functions/VCS_Info/Backends/VCS_INFO_get_data_git:
vcs_info git: Fix fatal error in VCS_INFO_git_getbranch in
corner case
2018-12-09 dana <dana@dana.is>
* 43871: Completion/Unix/Type/_files: Support `-F '(pat ...)'` as

View file

@ -89,7 +89,7 @@ VCS_INFO_git_getbranch () {
gitbranch="$(${(z)gitsymref} 2> /dev/null)"
[[ -z ${gitbranch} ]] && [[ -r ${actiondir}/head-name ]] \
&& gitbranch="$(< ${actiondir}/head-name)"
[[ -z ${gitbranch} || ${gitbranch} == 'detached HEAD' ]] \
[[ -z ${gitbranch} || ${gitbranch} == 'detached HEAD' ]] && [[ -r ${actiondir}/onto ]] \
&& gitbranch="$(< ${actiondir}/onto)"
elif [[ -f "${gitdir}/MERGE_HEAD" ]] ; then
@ -112,9 +112,11 @@ VCS_INFO_git_getbranch () {
## Commented out because we don't know of a case in which 'describe --contains' fails and 'name-rev --tags' succeeds.
#elif gitbranch="$(${vcs_comm[cmd]} name-rev --name-only --no-undefined --tags HEAD 2>/dev/null)" ; then
elif gitbranch="$(${vcs_comm[cmd]} name-rev --name-only --no-undefined --always HEAD 2>/dev/null)" ; then
elif gitbranch="${${"$(< $gitdir/HEAD)"}[1,7]}..." ; then
else
# Can't happen
fi
if [[ -z ${gitbranch} ]]
then
gitbranch="${${"$(< $gitdir/HEAD)"}[1,7]}..."
fi
return 0