From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16193 invoked by alias); 16 Sep 2014 20:10:49 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 33184 Received: (qmail 25211 invoked from network); 16 Sep 2014 20:10:38 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=QC8QmzuAZRlyYpX/+4KIbV5aDvL9fgizQ3zDz3Z8VhU=; b=ZM39rvzLK+4Z6rqM4rmSrI1gGTo1BdHjfSQBa3uDRj/RIV4naYlpXBC498NEJPS9ES +kzliPmWQdhml5cSY3UWXKj3+aOowkbrtGdb5xuvKoFTJ+zF90hA9w6wwUtgj7bWnm59 q5U+XehyYQOBGAN658BOvlV3j0A+eugV7a2RqczuWeHFXfHHXateKtabQXuGYO1Jue2B HaThwY34HJ0XOwBjprv7zBA6cu+EW/W3bm/1HOOLQsVnLi1LlQxWoHzjZ+nL6zSNZtRk +MQy5ufcPdSVstswA2xuCuMXon0lVllzy3TIMi5MWBncBrh9eEBOMJN19i4MQVSwghg0 tymg== X-Received: by 10.195.12.103 with SMTP id ep7mr16045946wjd.121.1410898232025; Tue, 16 Sep 2014 13:10:32 -0700 (PDT) Date: Tue, 16 Sep 2014 22:07:59 +0200 From: Marc Finet To: Frank Terbeck Cc: zsh-workers@zsh.org Subject: Re: [PATCH 8/9] vcs_info git: consider patches for rebase Message-ID: <20140916220759.0401052c@mlap.lactee> In-Reply-To: <871tre7bo1.fsf@ft.bewatermyfriend.org> References: <1410557443-24178-1-git-send-email-m.dreadlock@gmail.com> <1410557443-24178-9-git-send-email-m.dreadlock@gmail.com> <877g167bus.fsf@ft.bewatermyfriend.org> <871tre7bo1.fsf@ft.bewatermyfriend.org> X-Mailer: Claws Mail 3.10.1 (GTK+ 2.24.24; i586-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Sun, 14 Sep 2014 12:13:02 +0200 Frank Terbeck 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