From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: zsh-workers@zsh.org
Subject: [PATCH] vcs_info git: Fix fatal error in VCS_INFO_git_getbranch in corner case
Date: Sun, 9 Dec 2018 19:41:19 +0000 [thread overview]
Message-ID: <20181209194119.20170-1-danielsh@tarpaulin.shahaf.local2> (raw)
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.
---
Functions/VCS_Info/Backends/VCS_INFO_get_data_git | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
index 7ae2c0b27..ceb4f978a 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
@@ -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
reply other threads:[~2018-12-09 19:41 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181209194119.20170-1-danielsh@tarpaulin.shahaf.local2 \
--to=d.s@daniel.shahaf.name \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).