threads / patch / 23977

v2, 3 partsgit am: Improve error messages

Subject: [PATCH v2 0/3] git am: Improve error messages

## tl;dr

4 messages between Jun 2, 2010 and Jun 2, 2010. Diffs are folded; open one to read it.

replies: 3people: 1as markdown or json

Ramkumar Ramachandra· Jun 2, 2010, 08:33 UTC · lore
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(-)
Ramkumar Ramachandra· Jun 2, 2010, 08:33 UTC · re: Ramkumar Ramachandra · lore

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

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 git-am.sh |   19 ++++++++++---------
 1 files changed, 10 insertions(+), 9 deletions(-)
Show changes to git-am.sh +10 −9
diff --git a/git-am.sh b/git-am.sh
index 87ffae2..b75358b 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -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\"."
-- 
1.7.1
Ramkumar Ramachandra· Jun 2, 2010, 08:33 UTC · re: Ramkumar Ramachandra · lore

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

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

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 git-am.sh |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
Show changes to git-am.sh +2 −0
diff --git a/git-am.sh b/git-am.sh
index b75358b..a52c2b4 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -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"
-- 
1.7.1
Ramkumar Ramachandra· Jun 2, 2010, 08:33 UTC · re: Ramkumar Ramachandra · lore

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

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.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 git-am.sh |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
Show changes to git-am.sh +7 −1
diff --git a/git-am.sh b/git-am.sh
index a52c2b4..062b5a7 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -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
-- 
1.7.1

← back to recent threads