Skip to contentSkip to conversation

git am: Improve error messages

PATCH New Ramkumar Ramachandra 1 participant 4 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

v2 cover git am: Improve error messages

What changed since v1:
0. Use TAB to indent
1. Revert to hardcoding "git am" instead of "$0" (Johannes Sixt)
2. Use "test -f", not "test -e" (Junio)
3. Set $FIRSTLINE to an empty string if the test fails (Junio)

Ramkumar Ramachandra (3):
git am: Set cmdline globally
git am: Display some help text when patch is empty git am: Remove stray error message from sed

 git-am.sh |   29 +++++++++++++++++++----------
 1 files changed, 19 insertions(+), 10 deletions(-)
#1 lore raw

PATCH v2 1/3 git am: Set cmdline globally

Set the $cmdline variable globally, and not in stop_here_user_resolve so it can be used in other code fragments as well.

---
 git-am.sh |   19 ++++++++++---------
 1 files changed, 10 insertions(+), 9 deletions(-)
git-am.sh +10 -9
index 87ffae2..b75358b 100755
@@ -52,6 +52,16 @@ else
 	HAS_HEAD=
 fi
 
+cmdline="git am"
+if test '' != "$interactive"
+then
+	cmdline="$cmdline -i"
+fi
+if test '' != "$threeway"
+then
+	cmdline="$cmdline -3"
+fi
+
 sq () {
 	git rev-parse --sq-quote "$@"
 }
@@ -66,15 +76,6 @@ stop_here_user_resolve () {
 	    printf '%s\n' "$resolvemsg"
 	    stop_here $1
     fi
-    cmdline="git am"
-    if test '' != "$interactive"
-    then
-        cmdline="$cmdline -i"
-    fi
-    if test '' != "$threeway"
-    then
-        cmdline="$cmdline -3"
-    fi
     echo "When you have resolved this problem run \"$cmdline --resolved\"."
     echo "If you would prefer to skip this patch, instead run \"$cmdline --skip\"."
     echo "To restore the original branch and stop patching run \"$cmdline --abort\"."
Signature · 1 line
1.7.1
#2 lore raw

PATCH v2 2/3 git am: Display some help text when patch is empty

In reply to Ramkumar Ramachandra

When a patch is found to be empty, prompt the user to use either --skip or --abort.

---
 git-am.sh |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
git-am.sh +2 -0
index b75358b..a52c2b4 100755
@@ -592,6 +592,8 @@ do
 
 		test -s "$dotest/patch" || {
 			echo "Patch is empty.  Was it split wrong?"
+			echo "If you would prefer to skip this patch, instead run \"$cmdline --skip\"."
+			echo "To restore the original branch and stop patching run \"$cmdline --abort\"."
 			stop_here $this
 		}
 		rm -f "$dotest/original-commit"
Signature · 1 line
1.7.1
#3 lore raw

PATCH v2 3/3 git am: Remove stray error message from sed

In reply to Ramkumar Ramachandra

When --continue is invoked without any changes, the following stray error message appears- sed: can't read $dotest/final-commit: No such file or directory. Remove this by making sure that the file actually exists.

---
 git-am.sh |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
git-am.sh +7 -1
index a52c2b4..062b5a7 100755
@@ -693,8 +693,13 @@ do
 	else
 	    action=yes
 	fi
-	FIRSTLINE=$(sed 1q "$dotest/final-commit")
+
+	if test -f "$dotest/final-commit"
+	then
+		FIRSTLINE=$(sed 1q "$dotest/final-commit")
+	else
+		FIRSTLINE=""
+	fi
 
 	if test $action = skip
 	then
Signature · 1 line
1.7.1