git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Björn Gustavsson" <bgustavsson@gmail.com>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>
Subject: [PATCH] rebase -i: print the editor name if it fails to launch
Date: Sun, 20 Dec 2009 09:32:50 +0100	[thread overview]
Message-ID: <4B2DE132.1080700@gmail.com> (raw)

The "git rebase -i" commands simply prints "Could not execute
editor" if the editor fails to launch.

Be a little bit more helpful and be consistent with the
built-in commands that use launch_editor() and also print
the name of the editor that failed to launch.

Signed-off-by: Björn Gustavsson <bgustavsson@gmail.com>
---
Here is a suggestion for how "git rebase -i" can be a
little bit more helpful if it fails to launch the editor.
This patch can be applied on top of my previous patch.

I am not sure whether "git am" also should be modified
to call git_editor_error_string. Currently it ignores
any errors from the call to git_editor. Should it abort
if there is an error or should it print a warning like this

echo "Warning: $(git_editor_error_string)"

if the editor fails to launch?

Grepping all *.sh files, I found no other references
to git_editor.

 git-rebase--interactive.sh |    3 +--
 git-sh-setup.sh            |    9 +++++++++
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index d529328..a08a813 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -778,8 +778,7 @@ EOF
 			die_abort "Nothing to do"
 
 		cp "$TODO" "$TODO".backup
-		git_editor "$TODO" ||
-			die_abort "Could not execute editor"
+		git_editor "$TODO" || die_abort "$(git_editor_error_string)"
 
 		has_action "$TODO" ||
 			die_abort "Nothing to do"
diff --git a/git-sh-setup.sh b/git-sh-setup.sh
index dfcb807..36782ec 100755
--- a/git-sh-setup.sh
+++ b/git-sh-setup.sh
@@ -107,6 +107,15 @@ git_editor() {
 	eval "$GIT_EDITOR" '"$@"'
 }
 
+git_editor_error_string() {
+	if test -z "${GIT_EDITOR:+set}"
+	then
+		GIT_EDITOR="$(git var GIT_EDITOR)" ||
+		(echo "No editor configured."; return 0)
+	fi
+	echo "There was a problem with the editor '$GIT_EDITOR'."
+}
+
 sane_grep () {
 	GREP_OPTIONS= LC_ALL=C grep "$@"
 }
-- 
1.6.6.rc3.2.ge3899

             reply	other threads:[~2009-12-20  8:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-20  8:32 Björn Gustavsson [this message]
2009-12-20  8:40 ` [PATCH] rebase -i: print the editor name if it fails to launch Björn Gustavsson
2009-12-20 18:44 ` Junio C Hamano
2009-12-21  7:54   ` Björn Gustavsson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4B2DE132.1080700@gmail.com \
    --to=bgustavsson@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 NNTP newsgroup(s).