zsh-workers
 help / color / mirror / code / Atom feed
From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: zsh-workers@zsh.org
Subject: [PATCH] vcs_info git: Add a cherry-pick patch-format
Date: Fri, 30 Oct 2015 15:08:53 +0000	[thread overview]
Message-ID: <20151030150853.GC1462@tarsus.local2> (raw)

---
Connect a 'git cherry-pick' that conflicted to patch-format.

Git doesn't make available as much information as we'd like, but I still
think this is useful.

diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
index fcee47c..704c189 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
@@ -267,6 +267,28 @@ elif [[ -f "${gitdir}/MERGE_HEAD" ]]; then
     # Not touching git_patches_unapplied
 
     VCS_INFO_git_handle_patches
+elif [[ -f "${gitdir}/CHERRY_PICK_HEAD" ]]; then
+    # 'git cherry-pick' without -n, that conflicted.  (With -n, git doesn't
+    # record the CHERRY_PICK_HEAD information anywhere, as of git 2.6.2.)
+    #
+    # ### 'git cherry-pick foo bar baz' only records the "remaining" part of
+    # ### the queue in the .git dir: if 'bar' has a conflict, the .git dir 
+    # ### has a record of 'baz' being queued, but no record of 'foo' having been
+    # ### part of the queue as well.  Therefore, the %n/%c applied/unapplied
+    # ### expandos will be memoryless: the "applied" counter will always
+    # ### be "1".  The %u/%c tuple will assume the values [(1,2), (1,1), (1,0)],
+    # ### whereas the correct sequence would be [(1,2), (2,1), (3,0)].
+    local subject
+    IFS='' read -r subject < "${gitdir}/MERGE_MSG"
+    git_patches_applied=( "$(<${gitdir}/CHERRY_PICK_HEAD) ${subject}" )
+    if [[ -f "${gitdir}/sequencer/todo" ]]; then
+        # Get the next patches, and remove the one that's in CHERRY_PICK_HEAD.
+        git_patches_unapplied=( ${${(M)${(f)"$(<"${gitdir}/sequencer/todo")"}:#pick *}#pick } )
+        git_patches_unapplied[1]=()
+    else
+        git_patches_unapplied=()
+    fi
+    VCS_INFO_git_handle_patches
 else
     gitmisc=''
 fi


                 reply	other threads:[~2015-10-30 15:08 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20151030150853.GC1462@tarsus.local2 \
    --to=d.s@daniel.shahaf.name \
    --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).