From: Marc Finet <m.dreadlock@gmail.com>
To: Frank Terbeck <ft@bewatermyfriend.org>
Cc: zsh-workers@zsh.org
Subject: Re: [PATCH 8/9] vcs_info git: consider patches for rebase
Date: Tue, 16 Sep 2014 22:07:59 +0200 [thread overview]
Message-ID: <20140916220759.0401052c@mlap.lactee> (raw)
In-Reply-To: <871tre7bo1.fsf@ft.bewatermyfriend.org>
On Sun, 14 Sep 2014 12:13:02 +0200
Frank Terbeck <ft@bewatermyfriend.org> wrote:
> Frank Terbeck wrote:
> > Let's apply it and see if people start to complain. :-)
>
> ...ungh. Because I didn't apply the $rrn patch yet, this doesn't apply
> cleanly. Do you mind updating the $rrn patch and then rebase this one
> on top of it and resend these two?
>
> Thanks!
Sure, here comes the v2 against patch4 (rrn) updated:
Since a rebase contains a list of patches to re-apply, re-use the
facility for stgit to have the same mechanism.
The patch list given to the gen-{un,}applied-string hooks is an array
with the sha1 and the subject of the commit. On rebase merge, the
applied patches prior to current contains only a number and "?".
---
Doc/Zsh/contrib.yo | 14 +--
Functions/VCS_Info/Backends/VCS_INFO_get_data_git | 116 ++++++++++++++--------
2 files changed, 81 insertions(+), 49 deletions(-)
diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo
index 1c1a66a..361e866 100644
--- a/Doc/Zsh/contrib.yo
+++ b/Doc/Zsh/contrib.yo
@@ -1296,10 +1296,10 @@ tt(formats) and tt(actionformats) and will be availabe in the global
tt(backend_misc) array as tt(${backend_misc[bookmarks]}).
)
item(tt(gen-applied-string))(
-Called in the tt(git) (with tt(stgit)), and tt(hg) (with tt(mq)) backends
-and in tt(quilt) support when the tt(applied-string) is generated; the
-tt(use-quilt) zstyle must be true for tt(quilt) (the tt(mq) and tt(stgit)
-backends are active by default).
+Called in the tt(git) (with tt(stgit) or during rebase), and tt(hg)
+(with tt(mq)) backends and in tt(quilt) support when the tt(applied-string)
+is generated; the tt(use-quilt) zstyle must be true for tt(quilt) (the tt(mq)
+and tt(stgit) backends are active by default).
This hook gets the names of all applied patches which tt(vcs_info) collected
so far in the opposite order, which means that the first argument is the
@@ -1312,9 +1312,9 @@ tt(backend_misc) array as tt($backend_misc[patches]}); and it will be
available as tt(%p) in the tt(patch-format) and tt(nopatch-format) styles.
)
item(tt(gen-unapplied-string))(
-Called in the tt(git) (with tt(stgit)), and tt(hg) (with tt(mq)) backend
-and in tt(quilt) support when the tt(unapplied-string) is generated; the
-tt(get-unapplied) style must be true.
+Called in the tt(git) (with tt(stgit) or during rebase), and tt(hg) (with
+tt(mq)) backend and in tt(quilt) support when the tt(unapplied-string) is
+generated; the tt(get-unapplied) style must be true.
This hook gets the names of all unapplied patches which tt(vcs_info)
collected so far in the opposite order, which mean that the first argument is
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
index 24efab2..c243bf7 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
@@ -3,9 +3,9 @@
## Distributed under the same BSD-ish license as zsh itself.
setopt localoptions extendedglob NO_shwordsplit
-local gitdir gitbase gitbranch gitaction gitunstaged gitstaged gitsha1
-local stgitpatch stgitunapplied
+local gitdir gitbase gitbranch gitaction gitunstaged gitstaged gitsha1 gitmisc
local -i querystaged queryunstaged
+local -a git_patches_applied git_patches_unapplied
local -A hook_com
VCS_INFO_git_getaction () {
@@ -113,6 +113,44 @@ VCS_INFO_git_getbranch () {
return 0
}
+VCS_INFO_git_handle_patches () {
+ local git_applied_s git_unapplied_s gitmsg git_all
+ git_patches_applied=(${(Oa)git_patches_applied})
+ git_patches_unapplied=(${(Oa)git_patches_unapplied})
+ (( git_all = ${#git_patches_applied} + ${#git_patches_unapplied} ))
+
+ if VCS_INFO_hook 'gen-applied-string' "${git_patches_applied[@]}"; then
+ if (( ${#git_patches_applied} )); then
+ git_applied_s=${git_patches_applied[1]}
+ else
+ git_applied_s=""
+ fi
+ else
+ git_applied_s=${hook_com[applied-string]}
+ fi
+ hook_com=()
+ if VCS_INFO_hook 'gen-unapplied-string' "${git_patches_unapplied[@]}"; then
+ git_patches_unapplied=${#git_patches_unapplied}
+ else
+ git_patches_unapplied=${hook_com[unapplied-string]}
+ fi
+
+ if (( ${#git_patches_applied} )); then
+ zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" patch-format gitmsg || gitmsg="%p (%n applied)"
+ else
+ zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" nopatch-format gitmsg || gitmsg="no patch applied"
+ fi
+ hook_com=( applied "${git_applied_s}" unapplied "${git_patches_unapplied}"
+ applied-n ${#git_patches_applied} unapplied-n ${#git_patches_unapplied} all-n ${git_all} )
+ if VCS_INFO_hook 'set-patch-format' "${gitmsg}"; then
+ zformat -f gitmisc "${gitmsg}" "p:${hook_com[applied]}" "u:${hook_com[unapplied]}" \
+ "n:${#git_patches_applied}" "c:${#git_patches_unapplied}" "a:${git_all}"
+ else
+ gitmisc=${hook_com[patch-replace]}
+ fi
+ hook_com=()
+}
+
gitdir=${vcs_comm[gitdir]}
VCS_INFO_git_getbranch ${gitdir}
gitbase=$( ${vcs_comm[cmd]} rev-parse --show-toplevel )
@@ -157,52 +195,46 @@ fi
VCS_INFO_adjust
VCS_INFO_git_getaction ${gitdir}
+
+VCS_INFO_get_get_rebase()
+{
+ if [[ -f "$1" ]]; then
+ echo "$(< "$1")"
+ fi
+}
+
local patchdir=${gitdir}/patches/${gitbranch}
if [[ -d $patchdir ]] && [[ -f $patchdir/applied ]] \
&& [[ -f $patchdir/unapplied ]]
then
- local -a stgit_applied stgit_unapplied stgit_all
-
- stgit_applied=(${(f)"$(< "${patchdir}/applied")"})
- stgit_applied=( ${(Oa)stgit_applied} )
- stgit_unapplied=(${(f)"$(< "${patchdir}/unapplied")"})
- stgit_unapplied=( ${(oa)stgit_unapplied} )
- stgit_all=( ${(Oa)stgit_applied} ${stgit_unapplied} )
-
- if VCS_INFO_hook 'gen-applied-string' "${stgit_applied[@]}"; then
- if (( ${#stgit_applied} )); then
- stgitpatch=${stgit_applied[1]}
- else
- stgitpatch=""
- fi
- else
- stgitpatch=${hook_com[applied-string]}
- fi
- hook_com=()
- if VCS_INFO_hook 'gen-unapplied-string' "${stgit_unapplied[@]}"; then
- stgitunapplied=${#stgit_unapplied}
- else
- stgitunapplied=${hook_com[unapplied-string]}
- fi
+ git_patches_applied=(${(f)"$(< "${patchdir}/applied")"})
+ git_patches_unapplied=(${(f)"$(< "${patchdir}/unapplied")"})
+ VCS_INFO_git_handle_patches
+elif [[ -d "${gitdir}/rebase-merge" ]]; then
+ patchdir="${gitdir}/rebase-merge"
+ local p
+ for p in ${(f)"$(< "${patchdir}/done")"}; do
+ # remove action
+ git_patches_applied+=("${${(s: :)p}[2,-1]}")
+ done
+ git_patches_unapplied=(${(f)"$(grep -v '^$' "${patchdir}/git-rebase-todo" | grep -v '^#')"})
+ VCS_INFO_git_handle_patches
+elif [[ -d "${gitdir}/rebase-apply" ]]; then
+ # Fake patch names for all but current patch
+ patchdir="${gitdir}/rebase-apply"
+ local cur=$(< "${patchdir}/next")
+ local p
+ for p in $(seq $(($cur - 1))); do
+ git_patches_applied+=("$(printf "%04d" $p) ?")
+ done
+ git_patches_applied+=("$(< "${patchdir}/original-commit") ${${(f)$(< "${patchdir}/msg-clean")}[1]}")
+ git_patches_unapplied=($(seq $cur $(< "${patchdir}/last")))
- if (( ${#stgit_applied} )); then
- zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" patch-format stgitmsg || stgitmsg="%p (%n applied)"
- else
- zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" nopatch-format stgitmsg || stgitmsg="no patch applied"
- fi
- hook_com=( applied "${stgitpatch}" unapplied "${stgitunapplied}"
- applied-n ${#stgit_applied} unapplied-n ${#stgit_unapplied} all-n ${#stgit_all} )
- if VCS_INFO_hook 'set-patch-format' "${stgitmsg}"; then
- zformat -f stgitmsg "${stgitmsg}" "p:${hook_com[applied]}" "u:${hook_com[unapplied]}" \
- "n:${#stgit_applied}" "c:${#stgit_unapplied}" "a:${#stgit_all}"
- else
- stgitmsg=${hook_com[patch-replace]}
- fi
- hook_com=()
+ VCS_INFO_git_handle_patches
else
- stgitmsg=''
+ gitmisc=''
fi
-backend_misc[patches]="${stgitmsg}"
-VCS_INFO_formats "${gitaction}" "${gitbranch}" "${gitbase}" "${gitstaged}" "${gitunstaged}" "${gitsha1}" "${stgitmsg}"
+backend_misc[patches]="${gitmisc}"
+VCS_INFO_formats "${gitaction}" "${gitbranch}" "${gitbase}" "${gitstaged}" "${gitunstaged}" "${gitsha1}" "${gitmisc}"
return 0
--
2.1.0
next prev parent reply other threads:[~2014-09-16 20:10 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-12 21:30 Misc patches for git completion and vcs_info Marc Finet
2014-09-12 21:30 ` [PATCH 1/9] vcs_info examples: fix typo Marc Finet
2014-09-14 9:33 ` Frank Terbeck
2014-09-12 21:30 ` [PATCH 2/9] completion git: support aliases when \n exist Marc Finet
2014-09-12 21:30 ` [PATCH 3/9] vcs_info git: detect revert or cherry-pick with multiple commits Marc Finet
2014-09-14 9:36 ` Frank Terbeck
2014-09-15 6:22 ` Phil Pennock
2014-09-12 21:30 ` [PATCH 4/9] vcs_info git: set rrn before using it Marc Finet
2014-09-14 9:33 ` Frank Terbeck
2014-09-16 20:07 ` Marc Finet
2014-09-16 20:41 ` Frank Terbeck
2014-09-16 20:57 ` Marc Finet
2014-09-16 21:23 ` Frank Terbeck
2014-09-12 21:30 ` [PATCH 5/9] vcs_info quilt: fix standalone detection Marc Finet
2014-09-14 9:42 ` Frank Terbeck
2014-09-16 20:19 ` Marc Finet
2014-09-12 21:30 ` [PATCH 6/9] vcs_info quilt: fix unapplied detection on sub-directory Marc Finet
2014-09-14 9:47 ` Frank Terbeck
2014-09-16 20:25 ` Marc Finet
2014-10-08 22:36 ` Marc Finet
2014-10-09 16:03 ` Frank Terbeck
2014-10-16 4:59 ` Marc Finet
2014-10-16 8:17 ` Frank Terbeck
2014-11-08 10:46 ` Marc Finet
2014-11-11 10:07 ` Marc Finet
2015-01-02 11:03 ` Frank Terbeck
2014-09-12 21:30 ` [PATCH 7/9] vcs_info git: fix applied-string name Marc Finet
2014-09-14 9:49 ` Frank Terbeck
2014-09-12 21:30 ` [PATCH 8/9] vcs_info git: consider patches for rebase Marc Finet
2014-09-14 10:08 ` Frank Terbeck
2014-09-14 10:13 ` Frank Terbeck
2014-09-16 20:07 ` Marc Finet [this message]
2014-09-12 21:30 ` [PATCH 9/9] completion git: fix send-email --confirm values Marc Finet
2014-09-14 10:11 ` Frank Terbeck
2014-09-12 23:50 ` Misc patches for git completion and vcs_info Bart Schaefer
2014-09-13 7:35 ` Marc Finet
2014-09-13 12:23 ` 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=20140916220759.0401052c@mlap.lactee \
--to=m.dreadlock@gmail.com \
--cc=ft@bewatermyfriend.org \
--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).