Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[PATCH] vcs_info: handle missing .git/rebase-apply/{next,msg-clean}



From: Daniel Hahler <git@xxxxxxxxxx>

When pressing Ctrl-C after `git am`, only `last` exists in
`.git/rebase-apply/`, which is empty.

This patch fixes it to fall back to "no patch applied" then.
---
 Functions/VCS_Info/Backends/VCS_INFO_get_data_git | 25 +++++++++++++----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
index 638ea45..8ecc7c7 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
@@ -217,18 +217,21 @@ elif [[ -d "${gitdir}/rebase-merge" ]]; then
 elif [[ -d "${gitdir}/rebase-apply" ]]; then
     # Fake patch names for all but current patch
     patchdir="${gitdir}/rebase-apply"
-    local cur=$(< "${patchdir}/next")
-    local p subject
-    for p in $(seq $(($cur - 1))); do
-        git_patches_applied+=("$(printf "%04d" $p) ?")
-    done
-    subject="${$(< "${patchdir}/msg-clean")[(f)1]}"
-    if [[ -f "${patchdir}/original-commit" ]]; then
-        git_patches_applied+=("$(< ${patchdir}/original-commit) $subject")
-    else
-        git_patches_applied+=("? $subject")
+    local next="${patchdir}/next"
+    if [[ -f $next ]]; then
+	local cur=$(< $next)
+	local p subject
+	for p in $(seq $(($cur - 1))); do
+	    git_patches_applied+=("$(printf "%04d" $p) ?")
+	done
+	subject="${$(< "${patchdir}/msg-clean")[(f)1]}"
+	if [[ -f "${patchdir}/original-commit" ]]; then
+	    git_patches_applied+=("$(< ${patchdir}/original-commit) $subject")
+	else
+	    git_patches_applied+=("? $subject")
+	fi
+	git_patches_unapplied=($(seq $cur $(< "${patchdir}/last")))
     fi
-    git_patches_unapplied=($(seq $cur $(< "${patchdir}/last")))
 
     VCS_INFO_git_handle_patches
 elif [[ -f "${gitdir}/MERGE_HEAD" ]]; then
-- 
2.5.3.dirty



Messages sorted by: Reverse Date, Date, Thread, Author