zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH 1/3] vcs_info git: In interactive rebases, ignore comment lines.
@ 2020-03-12 18:48 Daniel Shahaf
  2020-03-12 18:48 ` [PATCH 2/3] vcs_info git: In interactive rebases, properly support the full form of the "exec" verb Daniel Shahaf
  2020-03-12 18:48 ` [PATCH 3/3] vcs_info git: In interactive rebases, process gen-unapplied-string arguments like gen-applied-string arguments are processed Daniel Shahaf
  0 siblings, 2 replies; 3+ messages in thread
From: Daniel Shahaf @ 2020-03-12 18:48 UTC (permalink / raw)
  To: zsh-workers

---
 Functions/VCS_Info/Backends/VCS_INFO_get_data_git | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
index 5ddce72a6..a8f49e24a 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
@@ -202,6 +202,10 @@ elif [[ -d "${gitdir}/rebase-merge" ]]; then
         # exec: Add "exec ${command}" to $git_patches_applied.
         # (anything else): As 'exec'.
         case $p in
+            ([#]*)
+                # Comment line.  Skip.
+                continue
+                ;; 
             ((p|pick|e|edit|r|reword|f|fixup|s|squash)' '*)
                 # The line is of the form "pick $hash $subject".
                 # Just strip the verb and we're good to go.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/3] vcs_info git: In interactive rebases, properly support the full form of the "exec" verb.
  2020-03-12 18:48 [PATCH 1/3] vcs_info git: In interactive rebases, ignore comment lines Daniel Shahaf
@ 2020-03-12 18:48 ` Daniel Shahaf
  2020-03-12 18:48 ` [PATCH 3/3] vcs_info git: In interactive rebases, process gen-unapplied-string arguments like gen-applied-string arguments are processed Daniel Shahaf
  1 sibling, 0 replies; 3+ messages in thread
From: Daniel Shahaf @ 2020-03-12 18:48 UTC (permalink / raw)
  To: zsh-workers

The code before this commit happened to have done the right thing:
"exec" lines were handled by the catchall forward compatibility case,
which happened to have had virtually the same effect as the correct
case.  However, that was merely an accidental result.  This patch makes
the code do the right thing deliberately, rather than by accident.
---
 Functions/VCS_Info/Backends/VCS_INFO_get_data_git | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
index a8f49e24a..d8e5d1ff1 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
@@ -229,11 +229,11 @@ elif [[ -d "${gitdir}/rebase-merge" ]]; then
                         p="${p%% *} ?"
                 fi
                 ;;
-            (x *)
+            ((x|exec) *)
                 # The line is of the form 'exec foo bar baz' where 'foo bar
                 # baz' is a shell command.  There's no way to map _that_ to
                 # "$hash $subject", but I hope this counts as making an effort.
-                p=${p/x /exec }
+                p=${p/#x /exec }
                 ;;
             (*)
                 # Forward compatibility with not-yet-existing 'git rebase -i' verbs.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 3/3] vcs_info git: In interactive rebases, process gen-unapplied-string arguments like gen-applied-string arguments are processed.
  2020-03-12 18:48 [PATCH 1/3] vcs_info git: In interactive rebases, ignore comment lines Daniel Shahaf
  2020-03-12 18:48 ` [PATCH 2/3] vcs_info git: In interactive rebases, properly support the full form of the "exec" verb Daniel Shahaf
@ 2020-03-12 18:48 ` Daniel Shahaf
  1 sibling, 0 replies; 3+ messages in thread
From: Daniel Shahaf @ 2020-03-12 18:48 UTC (permalink / raw)
  To: zsh-workers

I consider this a bugfix, since it's unexpected for -applied and
-unapplied to differ about this.
---
The easy way to test this is with the script from workers/45541: edit that
script to add "-i" to the «git rebase» invocation on the last line, then run
it and observe that the word "pick" is removed from the gen-unapplied-string
hook's argv.

Cheers,

Daniel

 .../VCS_Info/Backends/VCS_INFO_get_data_git   | 23 +++++++++++++------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
index d8e5d1ff1..f7c4210e8 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
@@ -196,15 +196,16 @@ elif [[ -d "${gitdir}/rebase-merge" ]]; then
     # 'git rebase -i'
     patchdir="${gitdir}/rebase-merge"
     local p
-    [[ -f "${patchdir}/done" ]] &&
-    for p in ${(f)"$(< "${patchdir}/done")"}; do
+    VCS_INFO_git_map_rebase_line_to_hash_and_subject() {
+        local p=$1
+        unset REPLY
         # pick/edit/fixup/squash/reword: Add "$hash $subject" to $git_patches_applied.
         # exec: Add "exec ${command}" to $git_patches_applied.
         # (anything else): As 'exec'.
         case $p in
             ([#]*)
                 # Comment line.  Skip.
-                continue
+                return 0
                 ;; 
             ((p|pick|e|edit|r|reword|f|fixup|s|squash)' '*)
                 # The line is of the form "pick $hash $subject".
@@ -241,11 +242,19 @@ elif [[ -d "${gitdir}/rebase-merge" ]]; then
                     p+=" ?"
                 fi
         esac
-        git_patches_applied+=("$p")
-    done
+        REPLY=$p
+    }
+    if [[ -f "${patchdir}/done" ]] ; then
+        for p in ${(f)"$(< "${patchdir}/done")"}; do
+            VCS_INFO_git_map_rebase_line_to_hash_and_subject "$p"
+            (( $+REPLY )) && git_patches_applied+=( "$REPLY" )
+        done
+    fi
     if [[ -f "${patchdir}/git-rebase-todo" ]] ; then
-        # TODO: Process ${patchdir}/git-rebase-todo lines like ${patchdir}/done lines are
-        git_patches_unapplied=( ${${(f)${"$(<"${patchdir}/git-rebase-todo")"}}:#[#]*} )
+        for p in ${(f)"$(< "${patchdir}/git-rebase-todo")"}; do
+            VCS_INFO_git_map_rebase_line_to_hash_and_subject "$p"
+            (( $+REPLY )) && git_patches_unapplied+=( "$REPLY" )
+        done
     fi
     VCS_INFO_git_handle_patches
 elif [[ -d "${gitdir}/rebase-apply" ]]; then

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-03-12 18:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-12 18:48 [PATCH 1/3] vcs_info git: In interactive rebases, ignore comment lines Daniel Shahaf
2020-03-12 18:48 ` [PATCH 2/3] vcs_info git: In interactive rebases, properly support the full form of the "exec" verb Daniel Shahaf
2020-03-12 18:48 ` [PATCH 3/3] vcs_info git: In interactive rebases, process gen-unapplied-string arguments like gen-applied-string arguments are processed Daniel Shahaf

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).