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

4 messages from 2010-06-02 to 2010-06-02. Participants: Ramkumar Ramachandra.
Thread: https://gitlist.dev/t/23977

## Ramkumar Ramachandra, 2010-06-02 08:33

Subject: [PATCH v2 0/3] git am: Improve error messages
Message-ID: <1275467617-23065-1-git-send-email-artagnon@gmail.com>
URL: https://gitlist.dev/e/1275467617-23065-1-git-send-email-artagnon%40gmail.com

```
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, 2010-06-02 08:33

Subject: [PATCH v2 1/3] git am: Set cmdline globally
Message-ID: <1275467617-23065-2-git-send-email-artagnon@gmail.com>
URL: https://gitlist.dev/e/1275467617-23065-2-git-send-email-artagnon%40gmail.com
In-Reply-To: <1275467617-23065-1-git-send-email-artagnon@gmail.com>

```
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(-)

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, 2010-06-02 08:33

Subject: [PATCH v2 2/3] git am: Display some help text when patch is empty
Message-ID: <1275467617-23065-3-git-send-email-artagnon@gmail.com>
URL: https://gitlist.dev/e/1275467617-23065-3-git-send-email-artagnon%40gmail.com
In-Reply-To: <1275467617-23065-1-git-send-email-artagnon@gmail.com>

```
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(-)

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, 2010-06-02 08:33

Subject: [PATCH v2 3/3] git am: Remove stray error message from sed
Message-ID: <1275467617-23065-4-git-send-email-artagnon@gmail.com>
URL: https://gitlist.dev/e/1275467617-23065-4-git-send-email-artagnon%40gmail.com
In-Reply-To: <1275467617-23065-1-git-send-email-artagnon@gmail.com>

```
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(-)

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

```
