git am: Improve error messages
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(-)
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
@@ -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
PATCH v2 2/3 git am: Display some help text when patch is empty
In reply to Ramkumar RamachandraWhen 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
@@ -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
PATCH v2 3/3 git am: Remove stray error message from sed
In reply to Ramkumar RamachandraWhen --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
@@ -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