about summary refs log tree commit diff
path: root/Functions
diff options
context:
space:
mode:
authorDaniel Shahaf <danielsh@apache.org>2020-03-12 18:06:22 +0000
committerDaniel Shahaf <danielsh@apache.org>2020-03-15 00:18:30 +0000
commit4ce4483daf856aa7e9adfecea8e5ee7f87f0b22c (patch)
tree060ac6da895f8cee7400cfd3def25b22914750b3 /Functions
parente1946bacf82653b4795793abe5ae095e3e65fea7 (diff)
downloadzsh-4ce4483daf856aa7e9adfecea8e5ee7f87f0b22c.tar.gz
zsh-4ce4483daf856aa7e9adfecea8e5ee7f87f0b22c.tar.xz
zsh-4ce4483daf856aa7e9adfecea8e5ee7f87f0b22c.zip
45539: vcs_info git: In non-interactive rebases, obtain applied patches' names.
Diffstat (limited to 'Functions')
-rw-r--r--Functions/VCS_Info/Backends/VCS_INFO_get_data_git22
1 files changed, 17 insertions, 5 deletions
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
index 97a04b6ce..2b1e9afca 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
@@ -266,11 +266,23 @@ elif [[ -d "${gitdir}/rebase-apply" ]]; then
         local cur=$(< $next)
         local p subject
         # Fake patch names for patches "before" the current patch
-        #
-        # Note: With git 2.24, (( cur == 1 )), so the loop body never runs.
-        for ((p = 1; p < cur; p++)); do
-            printf -v "git_patches_applied[$p]"  "%04d ?" "$p"
-        done
+        if [[ -r ${patchdir}/rewritten ]]; then
+            if zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" use-simple; then
+                git_patches_applied=( ${${(f)"$(<${patchdir}/rewritten)"}// */' ?'} )
+            else
+                git_patches_applied=(
+                    ${(f)"$(${vcs_comm[cmd]} log --no-walk=unsorted --pretty='%h %s' ${${(f)"$(<${patchdir}/rewritten)"}%% *} --)"}
+                )
+            fi
+        else
+            # Compatibility with old git.  In 2.11 and 2.24, at least,
+            # (( cur == 1 )), so the loop body would never run.  However, both
+            # of these versions have original-commit and orig-head and would
+            # take the 'if' branch, rather than this 'else' branch.
+            for ((p = 1; p < cur; p++)); do
+                printf -v "git_patches_applied[$p]"  "%04d ?" "$p"
+            done
+        fi
         # Set $subject to the info for the current patch
         if [[ -f "${patchdir}/msg-clean" ]]; then
             subject="${$(< "${patchdir}/msg-clean")[(f)1]}"