git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH 0/3] Improve git-am error messages
@ 2010-06-01  9:20 Ramkumar Ramachandra
  2010-06-01  9:20 ` [PATCH 1/3] Set cmdline globally, not in stop_here_user_resolve Ramkumar Ramachandra
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Ramkumar Ramachandra @ 2010-06-01  9:20 UTC (permalink / raw
  To: Git Mailing List; +Cc: Sverre Rabbelier, Junio C Hamano

Hi,

This patch series aims to improve some of the error messages in git-am
that I came across.

-- Ram

Ramkumar Ramachandra (3):
  Initialize cmdline globally, not in stop_here_user_resolve
  Display some help text when patch is empty
  Remove stray error message from sed when continuing without changes

 git-am.sh |   23 +++++++++++++----------
 1 files changed, 13 insertions(+), 10 deletions(-)

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/3] Set cmdline globally, not in stop_here_user_resolve
  2010-06-01  9:20 [PATCH 0/3] Improve git-am error messages Ramkumar Ramachandra
@ 2010-06-01  9:20 ` Ramkumar Ramachandra
  2010-06-01  9:27   ` Johannes Sixt
  2010-06-01  9:20 ` [PATCH 2/3] Display some help text when patch is empty Ramkumar Ramachandra
  2010-06-01  9:20 ` [PATCH 3/3] Remove stray error message from sed Ramkumar Ramachandra
  2 siblings, 1 reply; 7+ messages in thread
From: Ramkumar Ramachandra @ 2010-06-01  9:20 UTC (permalink / raw
  To: Git Mailing List; +Cc: Sverre Rabbelier, Junio C Hamano

Set the $cmdline variable globally, so it can be used in other code
fragments as well. Also, instead of hardcoding the string "git am",
use the command line argument "$0".

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..b779277 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -52,6 +52,16 @@ else
 	HAS_HEAD=
 fi
 
+cmdline="$0"
+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

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/3] Display some help text when patch is empty
  2010-06-01  9:20 [PATCH 0/3] Improve git-am error messages Ramkumar Ramachandra
  2010-06-01  9:20 ` [PATCH 1/3] Set cmdline globally, not in stop_here_user_resolve Ramkumar Ramachandra
@ 2010-06-01  9:20 ` Ramkumar Ramachandra
  2010-06-01  9:20 ` [PATCH 3/3] Remove stray error message from sed Ramkumar Ramachandra
  2 siblings, 0 replies; 7+ messages in thread
From: Ramkumar Ramachandra @ 2010-06-01  9:20 UTC (permalink / raw
  To: Git Mailing List; +Cc: Sverre Rabbelier, Junio C Hamano

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 b779277..04f02a8 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

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/3] Remove stray error message from sed
  2010-06-01  9:20 [PATCH 0/3] Improve git-am error messages Ramkumar Ramachandra
  2010-06-01  9:20 ` [PATCH 1/3] Set cmdline globally, not in stop_here_user_resolve Ramkumar Ramachandra
  2010-06-01  9:20 ` [PATCH 2/3] Display some help text when patch is empty Ramkumar Ramachandra
@ 2010-06-01  9:20 ` Ramkumar Ramachandra
  2010-06-01 17:44   ` Junio C Hamano
  2 siblings, 1 reply; 7+ messages in thread
From: Ramkumar Ramachandra @ 2010-06-01  9:20 UTC (permalink / raw
  To: Git Mailing List; +Cc: Sverre Rabbelier, Junio C Hamano

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 |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/git-am.sh b/git-am.sh
index 04f02a8..e61f47a 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -693,7 +693,7 @@ do
 	else
 	    action=yes
 	fi
-	FIRSTLINE=$(sed 1q "$dotest/final-commit")
+	test -e "$dotest/final-commit" && FIRSTLINE=$(sed 1q "$dotest/final-commit")
 
 	if test $action = skip
 	then
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/3] Set cmdline globally, not in stop_here_user_resolve
  2010-06-01  9:20 ` [PATCH 1/3] Set cmdline globally, not in stop_here_user_resolve Ramkumar Ramachandra
@ 2010-06-01  9:27   ` Johannes Sixt
  2010-06-01  9:36     ` Ramkumar Ramachandra
  0 siblings, 1 reply; 7+ messages in thread
From: Johannes Sixt @ 2010-06-01  9:27 UTC (permalink / raw
  To: Ramkumar Ramachandra; +Cc: Git Mailing List, Sverre Rabbelier, Junio C Hamano

Am 6/1/2010 11:20, schrieb Ramkumar Ramachandra:
> Set the $cmdline variable globally, so it can be used in other code
> fragments as well. Also, instead of hardcoding the string "git am",
> use the command line argument "$0".

Did you test this? "$0" prints the full path to git-am. This does not
count as user-friendly in my book!

-- Hannes

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/3] Set cmdline globally, not in stop_here_user_resolve
  2010-06-01  9:27   ` Johannes Sixt
@ 2010-06-01  9:36     ` Ramkumar Ramachandra
  0 siblings, 0 replies; 7+ messages in thread
From: Ramkumar Ramachandra @ 2010-06-01  9:36 UTC (permalink / raw
  To: Johannes Sixt; +Cc: Git Mailing List, Sverre Rabbelier, Junio C Hamano

Hi,

> Did you test this? "$0" prints the full path to git-am. This does not
> count as user-friendly in my book!

Doesn't it print out exactly the way you invoke the application ie.
either "./git-am.sh" or "git am"? Then again, when git-am is invoked
internally by git, it possibly uses the full path instead of relying
on $PATH, and this is quite ugly. I noticed that all the other other
shell scripts in git.git also hardcode the string, and there must be a
good reason for this. Therefore I think this particular change should
be dropped.

Thanks for pointing this out.

-- Ram

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 3/3] Remove stray error message from sed
  2010-06-01  9:20 ` [PATCH 3/3] Remove stray error message from sed Ramkumar Ramachandra
@ 2010-06-01 17:44   ` Junio C Hamano
  0 siblings, 0 replies; 7+ messages in thread
From: Junio C Hamano @ 2010-06-01 17:44 UTC (permalink / raw
  To: Ramkumar Ramachandra; +Cc: Git Mailing List, Sverre Rabbelier

Ramkumar Ramachandra <artagnon@gmail.com> writes:

> 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 |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/git-am.sh b/git-am.sh
> index 04f02a8..e61f47a 100755
> --- a/git-am.sh
> +++ b/git-am.sh
> @@ -693,7 +693,7 @@ do
>  	else
>  	    action=yes
>  	fi
> -	FIRSTLINE=$(sed 1q "$dotest/final-commit")
> +	test -e "$dotest/final-commit" && FIRSTLINE=$(sed 1q "$dotest/final-commit")

This will let the command follow the same codepath as before but the
change in behaviour is that it does not reset FIRSTLINE to an empty
string.  Does this difference affect what the user sees after this part of
the code?

I would generally prefer to use "test -f" not "-e" (simply because it came
later and I am an old-timer), but if you want to use something newer than
"test -f", it might be worth using "test -r" instead, as readability (not
existence) is what you are after anyway.

>  
>  	if test $action = skip
>  	then
> -- 
> 1.7.1

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-06-01 17:44 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-01  9:20 [PATCH 0/3] Improve git-am error messages Ramkumar Ramachandra
2010-06-01  9:20 ` [PATCH 1/3] Set cmdline globally, not in stop_here_user_resolve Ramkumar Ramachandra
2010-06-01  9:27   ` Johannes Sixt
2010-06-01  9:36     ` Ramkumar Ramachandra
2010-06-01  9:20 ` [PATCH 2/3] Display some help text when patch is empty Ramkumar Ramachandra
2010-06-01  9:20 ` [PATCH 3/3] Remove stray error message from sed Ramkumar Ramachandra
2010-06-01 17:44   ` Junio C Hamano

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).