about summary refs log tree commit diff
path: root/Functions
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2009-05-22 17:38:05 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2009-05-22 17:38:05 +0000
commitf359213eec1dcd2a60b31e6a377328cbc6b3cbd8 (patch)
tree8cebb9eab7062a5056496e32d569648e91af27e6 /Functions
parent8edf8a06581667ca33477a864d7f93b2d6e9eccf (diff)
downloadzsh-f359213eec1dcd2a60b31e6a377328cbc6b3cbd8.tar.gz
zsh-f359213eec1dcd2a60b31e6a377328cbc6b3cbd8.tar.xz
zsh-f359213eec1dcd2a60b31e6a377328cbc6b3cbd8.zip
26982: Julien Langer: support stgit in VCS_Info
Diffstat (limited to 'Functions')
-rw-r--r--Functions/VCS_Info/Backends/VCS_INFO_get_data_git47
1 files changed, 46 insertions, 1 deletions
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
index faab2b88a..a536165e1 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
@@ -89,6 +89,36 @@ VCS_INFO_git_getbranch () {
     return 0
 }
 
+VCS_INFO_git_get_stgit_top_patch () {
+    local patchdir=$1
+
+    if [[ -d "$patchdir" ]]; then
+        local -a patches
+        patches=(${(f)"$(< "${patchdir}/applied")"})
+        printf '%s' $patches[-1]
+        return 0
+    fi
+
+    return 1
+}
+
+VCS_INFO_git_get_stgit_unapplied() {
+    local patchdir=$1
+
+    if [[ -d "$patchdir" ]]; then
+        local -a patches
+        patches=(${(f)"$(< "${patchdir}/unapplied")"})
+        if [[ -z $patches[@] ]]; then
+            printf 0
+        else
+            printf '%d' $#patches
+        fi
+        return 0
+    fi
+
+    return 1
+}
+
 gitdir=${vcs_comm[gitdir]}
 gitbranch="$(VCS_INFO_git_getbranch ${gitdir})"
 if zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" get-revision && \
@@ -117,5 +147,20 @@ VCS_INFO_adjust
 gitaction="$(VCS_INFO_git_getaction ${gitdir})"
 gitbase=${PWD%/${$( ${vcs_comm[cmd]} rev-parse --show-prefix )%/##}}
 rrn=${gitbase:t}
-VCS_INFO_formats "${gitaction}" "${gitbranch}" "${gitbase}" "${gitstaged}" "${gitunstaged}" "${gitsha1}" ''
+
+local patchdir=${gitdir}/patches/${gitbranch}
+if [[ -d $patchdir ]] ; then
+    stgitpatch=$(VCS_INFO_git_get_stgit_top_patch "${patchdir}")
+    stgitunapplied=$(VCS_INFO_git_get_stgit_unapplied "${patchdir}")
+
+    stgitpatch=${stgitpatch:-"no patch applied"}
+
+    zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" stgitformat stgitmsg || stgitmsg=" %p (%c)"
+    zformat -f stgitmsg "${stgitmsg}" "p:${stgitpatch}" "c:${stgitunapplied}"
+    gitmisc=${stgitmsg}
+else
+    gitmisc=''
+fi
+
+VCS_INFO_formats "${gitaction}" "${gitbranch}" "${gitbase}" "${gitstaged}" "${gitunstaged}" "${gitsha1}" "${gitmisc}"
 return 0