From: Julien Langer <julien.langer@googlemail.com>
To: zsh-workers@sunsite.dk
Subject: PATCH: add support for stgit in VCS_Info
Date: Fri, 22 May 2009 17:45:43 +0200 [thread overview]
Message-ID: <c006aa4b0905220845i38beb3f3yfa158564a7178708@mail.gmail.com> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 315 bytes --]
This patch adds some support for stgit to VCS_Info. It displays the
currently active patch and the number of unapplied patches.
The additional info is configured via a new "stgitformat" style and is put
into the "misc" part of the prompt. I don't know if this is the best idea,
what do you (Frank?) think?
-Julien
[-- Attachment #1.2: Type: text/html, Size: 359 bytes --]
[-- Attachment #2: vcs_info_stgit_support.patch --]
[-- Type: text/x-patch, Size: 2081 bytes --]
add support for stgit
From: Julien Langer <julien.langer@gmail.com>
---
Functions/VCS_Info/Backends/VCS_INFO_get_data_git | 47 +++++++++++++++++++++
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 faab2b8..d30938d 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
next reply other threads:[~2009-05-22 15:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-22 15:45 Julien Langer [this message]
2009-05-22 16:17 ` Frank Terbeck
2009-05-22 17:24 ` Julien Langer
2009-05-22 17:42 ` Frank Terbeck
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=c006aa4b0905220845i38beb3f3yfa158564a7178708@mail.gmail.com \
--to=julien.langer@googlemail.com \
--cc=zsh-workers@sunsite.dk \
/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).