Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] vcs_info git: Fix fatal error in VCS_INFO_git_getbranch in corner case
- X-seq: zsh-workers 43879
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- 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
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=from:to:subject:date:message-id; s=fm2; bh=7amCjWOCaNYx1tXApESbU08H+XhllqJYZ8XmtF1fki8=; b=GvlmTP069KHn Ri/EfJ6i3X3wsavN8UFxTvuHpUcwMdrVvq/lZ43ojm+gaamcUIdISukSR68X5A/A q9TbdPuFByE2TRz+8dE+bwrPrmcEJ9VDT2SNWSJqg9WItY+boJH2nIBqEFkOb+zL Z8+/2NaLKWjb23Dg+AU2T0m+06yHgjpV5W4/waz7CL7FQo6MTGImFU/Y+q1Jla2m Ga+ocBkVY+eCq1qkpLlp6qqNImtjA+FAtqEMbTELpQW0zWF3P0Zp/Q5mQv/y0TNA YkNX8TDilFq5nzxoI3kRBmlLBphEeY02CEelhyrVBgBv7IpEdmoO+2/m+4yLW4RU d2IyfBmhFw==
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=date:from:message-id:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=7amCjWOCaNYx1tXApESbU08H+XhllqJYZ8XmtF1fki8=; b=qVJw26sM q9CPH5Eq3yJyqTmOsM84uAg4xKEg/AAprIUUJJNPAr0zkNxqX1z+lvRF4Vm5wQCm 46avKBnvNmsqMJonhdtg5xQFWaBNqxqI/J/nJrjeP+ZtJyzQKjILjTDw0UplLfm3 R9MJP9AtfKEPO67P5R0hZI7obMSYKg0dnMTnrICmgPgKHN/NRqQ1eFIxV1IV5vDx j7I7kYsfI+8yD9iiCyliRVZO6sdEpFRUf5Q+0gMDuFOH2b9DBAgzpOItlANtAc+W m2btp52WLNvTd3j5sZWPuBoS9HA0NO2cGLeYI7eHQKV2eF6YA++Ej9iE2P0KRQhS OEvR8KNPMhKjEA==
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author