zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: vcs_info: fix git backend backwards compatibility
@ 2010-02-07 16:40 Frank Terbeck
  0 siblings, 0 replies; only message in thread
From: Frank Terbeck @ 2010-02-07 16:40 UTC (permalink / raw)
  To: zsh-workers

The old code was way too naive. This should work better.
Not entirely sure if this doesn't break something. Keeping backwards
compatibility with older gits sucks. :-/

Regards, Frank
---
 Functions/VCS_Info/Backends/VCS_INFO_get_data_git |   30 +++++++++++++-------
 1 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
index 7b961a4..bf7c479 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
@@ -54,23 +54,31 @@ VCS_INFO_git_getaction () {
 }
 
 VCS_INFO_git_getbranch () {
-    local gitbranch gitdir=$1
+    local gitbranch gitdir=$1 tmp actiondir
     local gitsymref="${vcs_comm[cmd]} symbolic-ref HEAD"
 
-    if    [[ -d "${gitdir}/rebase-apply" ]] \
-       || [[ -d "${gitdir}/rebase" ]]       \
-       || [[ -d "${gitdir}/../.dotest" ]]   \
-       || [[ -f "${gitdir}/MERGE_HEAD" ]] ; then
+    actiondir=''
+    for tmp in "${gitdir}/rebase-apply" \
+               "${gitdir}/rebase"       \
+               "${gitdir}/../.dotest"; do
+        if [[ -d ${tmp} ]]; then
+            actiondir=${tmp}
+            break
+        fi
+    done
+    if [[ -n ${actiondir} ]]; then
+        gitbranch="$(${(z)gitsymref} 2> /dev/null)"
+        [[ -z ${gitbranch} ]] && [[ -r ${actiondir}/head-name ]] \
+            && gitbranch="$(< ${actiondir}/head-name)"
+
+    elif [[ -f "${gitdir}/MERGE_HEAD" ]] ; then
         gitbranch="$(${(z)gitsymref} 2> /dev/null)"
-        [[ -z ${gitbranch} ]] && [[ -r ${gitdir}/rebase-apply/head-name ]] \
-            && gitbranch="$(< ${gitdir}/rebase-apply/head-name)"
+        [[ -z ${gitbranch} ]] && gitbranch="$(< ${gitdir}/MERGE_HEAD)"
 
-    elif   [[ -f "${gitdir}/rebase-merge/interactive" ]] \
-        || [[ -d "${gitdir}/rebase-merge" ]] ; then
+    elif [[ -d "${gitdir}/rebase-merge" ]] ; then
         gitbranch="$(< ${gitdir}/rebase-merge/head-name)"
 
-    elif   [[ -f "${gitdir}/.dotest-merge/interactive" ]] \
-        || [[ -d "${gitdir}/.dotest-merge" ]] ; then
+    elif [[ -d "${gitdir}/.dotest-merge" ]] ; then
         gitbranch="$(< ${gitdir}/.dotest-merge/head-name)"
 
     else
-- 
1.7.0.rc1.10.gb8bb


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2010-02-07 16:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-07 16:40 PATCH: vcs_info: fix git backend backwards compatibility Frank Terbeck

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).