zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH 1/3] vcs_info git: Reformat to minimise next diff.  No functional change.
@ 2018-10-02 15:20 Daniel Shahaf
  2018-10-02 15:20 ` [PATCH 2/3] vcs_info git: Make sure applied-patches is of the form "$hash $subject" --- that is, has a space and a non-empty second argument --- even with future 'git rebase -i' verbs Daniel Shahaf
  2018-10-02 15:20 ` [PATCH 3/3] vcs_info git: In 'git rebase -i', when computing subjects of applied-patches, handle an edge case where the subject is not available Daniel Shahaf
  0 siblings, 2 replies; 3+ messages in thread
From: Daniel Shahaf @ 2018-10-02 15:20 UTC (permalink / raw)
  To: zsh-workers

---
 Functions/VCS_Info/Backends/VCS_INFO_get_data_git | 15 +++++++++++++--
 1 file changed, 13 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 c3e62db3a..af7466be5 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
@@ -190,8 +190,19 @@ elif [[ -d "${gitdir}/rebase-merge" ]]; then
         # pick/edit/fixup/squash/reword: Add "$hash $subject" to $git_patches_applied.
         # exec: Add "exec ${command}" to $git_patches_applied.
         # (anything else): As 'exec'.
-        p=${p/(#s)(p|pick|e|edit|r|reword|f|fixup|s|squash) /}
-        p=${p/(#s)x /exec }
+        case $p in
+            ((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.
+                p=${p#* }
+                ;;
+            (x *)
+                # 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 }
+                ;;
+        esac
         git_patches_applied+=("$p")
     done
     if [[ -f "${patchdir}/git-rebase-todo" ]] ; then

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

* [PATCH 2/3] vcs_info git: Make sure applied-patches is of the form "$hash $subject" --- that is, has a space and a non-empty second argument --- even with future 'git rebase -i' verbs.
  2018-10-02 15:20 [PATCH 1/3] vcs_info git: Reformat to minimise next diff. No functional change Daniel Shahaf
@ 2018-10-02 15:20 ` Daniel Shahaf
  2018-10-02 15:20 ` [PATCH 3/3] vcs_info git: In 'git rebase -i', when computing subjects of applied-patches, handle an edge case where the subject is not available Daniel Shahaf
  1 sibling, 0 replies; 3+ messages in thread
From: Daniel Shahaf @ 2018-10-02 15:20 UTC (permalink / raw)
  To: zsh-workers

Use of '?' is consistent with these precedents:

Backends/VCS_INFO_get_data_git:220:            printf -v "git_patches_applied[$p]"  "%04d ?" "$p"
Backends/VCS_INFO_get_data_git:242:                git_patches_applied+=("? $subject")
Backends/VCS_INFO_get_data_git:244:                git_patches_applied+=("?")
VCS_INFO_quilt:160:            applied[$i]+=" ?"
VCS_INFO_quilt:168:            unapplied[$i]+=" ?"
---
 Functions/VCS_Info/Backends/VCS_INFO_get_data_git | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
index af7466be5..f38a0d370 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
@@ -202,6 +202,11 @@ elif [[ -d "${gitdir}/rebase-merge" ]]; then
                 # "$hash $subject", but I hope this counts as making an effort.
                 p=${p/x /exec }
                 ;;
+            (*)
+                # Forward compatibility with not-yet-existing 'git rebase -i' verbs.
+                if [[ $p != *\ * ]]; then
+                    p+=" ?"
+                fi
         esac
         git_patches_applied+=("$p")
     done

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

* [PATCH 3/3] vcs_info git: In 'git rebase -i', when computing subjects of applied-patches, handle an edge case where the subject is not available.
  2018-10-02 15:20 [PATCH 1/3] vcs_info git: Reformat to minimise next diff. No functional change Daniel Shahaf
  2018-10-02 15:20 ` [PATCH 2/3] vcs_info git: Make sure applied-patches is of the form "$hash $subject" --- that is, has a space and a non-empty second argument --- even with future 'git rebase -i' verbs Daniel Shahaf
@ 2018-10-02 15:20 ` Daniel Shahaf
  1 sibling, 0 replies; 3+ messages in thread
From: Daniel Shahaf @ 2018-10-02 15:20 UTC (permalink / raw)
  To: zsh-workers

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

diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
index f38a0d370..d9cf1a19e 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
@@ -195,6 +195,24 @@ elif [[ -d "${gitdir}/rebase-merge" ]]; then
                 # The line is of the form "pick $hash $subject".
                 # Just strip the verb and we're good to go.
                 p=${p#* }
+                # Special case: in an interactive rebase, if the user wrote "p $shorthash\n"
+                # in the editor (without a description after the hash), then the .../done
+                # file will contain "p $longhash $shorthash\n" (git 2.11.0) or "pick $longhash\n"
+                # (git 2.19.0).
+                if [[ $p != *\ * ]]; then
+                        # The line is of the form "pick $longhash\n"
+                        #
+                        # Mark the log message subject as unknown.
+                        # TODO: Can we performantly obtain the subject?
+                        p+=" ?"
+                elif (( ${#${p//[^ ]}} == 1 )) && [[ ${p%% *} == ${p#* }* ]]; then
+                        # The line is of the form "p $longhash $shorthash\n"
+                        #
+                        # The shorthash is superfluous, so discard it, and mark
+                        # the log message subject as unknown.
+                        # TODO: Can we performantly obtain the subject?
+                        p="${p%% *} ?"
+                fi
                 ;;
             (x *)
                 # The line is of the form 'exec foo bar baz' where 'foo bar
@@ -211,6 +229,7 @@ elif [[ -d "${gitdir}/rebase-merge" ]]; then
         git_patches_applied+=("$p")
     done
     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")"}}:#[#]*} )
     fi
     VCS_INFO_git_handle_patches

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

end of thread, other threads:[~2018-10-02 15:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-02 15:20 [PATCH 1/3] vcs_info git: Reformat to minimise next diff. No functional change Daniel Shahaf
2018-10-02 15:20 ` [PATCH 2/3] vcs_info git: Make sure applied-patches is of the form "$hash $subject" --- that is, has a space and a non-empty second argument --- even with future 'git rebase -i' verbs Daniel Shahaf
2018-10-02 15:20 ` [PATCH 3/3] vcs_info git: In 'git rebase -i', when computing subjects of applied-patches, handle an edge case where the subject is not available 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).