From 4ce4483daf856aa7e9adfecea8e5ee7f87f0b22c Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Thu, 12 Mar 2020 18:06:22 +0000 Subject: 45539: vcs_info git: In non-interactive rebases, obtain applied patches' names. --- Functions/VCS_Info/Backends/VCS_INFO_get_data_git | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'Functions/VCS_Info') 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]}" -- cgit 1.4.1