about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDaniel Shahaf <d.s@daniel.shahaf.name>2015-09-03 09:24:16 +0000
committerDaniel Shahaf <d.s@daniel.shahaf.name>2015-09-05 10:47:44 +0000
commit880579dc1e368bd6111b6f2d4c4449f4d42cd1b3 (patch)
tree606173b467acb04ee75e0b2809671976d38e1cdd
parent5445d5f0cc26f03eda26f8c74723a8fb65466586 (diff)
downloadzsh-880579dc1e368bd6111b6f2d4c4449f4d42cd1b3.tar.gz
zsh-880579dc1e368bd6111b6f2d4c4449f4d42cd1b3.tar.xz
zsh-880579dc1e368bd6111b6f2d4c4449f4d42cd1b3.zip
36410: vcs_info git: Present merge heads as patches
This shows, during 'git merge', the revision hashes of the "remote" head
(the one that will become second parent of the commit) in the %m expando.

Review-by: Frank Terbeck
-rw-r--r--ChangeLog6
-rw-r--r--Doc/Zsh/contrib.yo2
-rw-r--r--Functions/VCS_Info/Backends/VCS_INFO_get_data_git17
3 files changed, 24 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index bb2d507c2..05d6999ce 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2015-09-05  Daniel Shahaf  <d.s@daniel.shahaf.name>
+
+	* 36410: Doc/Zsh/contrib.yo
+	Functions/VCS_Info/Backends/VCS_INFO_get_data_git: vcs_info git:
+	Present merge heads as patches
+
 2015-09-04  Peter Stephenson  <p.stephenson@samsung.com>
 
 	* 36421: Src/pattern.c: can't-get-the-staff fix for idiocy in
diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo
index db0940d94..741d4ad07 100644
--- a/Doc/Zsh/contrib.yo
+++ b/Doc/Zsh/contrib.yo
@@ -1339,7 +1339,7 @@ tt(formats) and tt(actionformats) and will be available 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) or during rebase), and tt(hg)
+Called in the tt(git) (with tt(stgit) or during rebase or merge), 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).
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
index 3fc861eeb..638ea4572 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
@@ -231,6 +231,23 @@ elif [[ -d "${gitdir}/rebase-apply" ]]; then
     git_patches_unapplied=($(seq $cur $(< "${patchdir}/last")))
 
     VCS_INFO_git_handle_patches
+elif [[ -f "${gitdir}/MERGE_HEAD" ]]; then
+    # This is 'git merge --no-commit'
+    local -a heads=( ${(@f)"$(<"${gitdir}/MERGE_HEAD")"} )
+    local subject;
+    IFS='' read -r subject < "${gitdir}/MERGE_MSG"
+    # $subject is the subject line of the would-be commit
+    # Maybe we can get the subject lines of MERGE_HEAD's commits cheaply?
+
+    local p
+    for p in $heads[@]; do
+      git_patches_applied+=("$p $subject")
+    done
+    unset p
+
+    # Not touching git_patches_unapplied
+
+    VCS_INFO_git_handle_patches
 else
     gitmisc=''
 fi