From: Adam Roben <aroben@apple.com>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>, Adam Roben <aroben@apple.com>
Subject: [PATCH] Add core.editor configuration variable
Date: Thu, 19 Jul 2007 17:28:23 -0700 [thread overview]
Message-ID: <11848913032579-git-send-email-aroben@apple.com> (raw)
In-Reply-To: <7vfy3k2an7.fsf@assigned-by-dhcp.cox.net>
This variable lets you specify an editor that will be launched in preference to
the EDITOR and VISUAL environment variables.
Signed-off-by: Adam Roben <aroben@apple.com>
Acked-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
---
On Jul 19, 2007, at 5:15 PM, Junio C Hamano wrote:
> Could you please re-diff to make this into a single patch
> without intermediate "Oh, doing it this way is cleaner", and
> also with Dscho's Ack? I do not think we would need to have 3
> commits for this topic --- it is not like wide userbase tested
> each iteration.
Documentation/git-commit.txt | 9 +++++----
Documentation/git-send-email.txt | 4 ++--
git-am.sh | 3 ++-
git-commit.sh | 12 ++----------
git-rebase--interactive.sh | 3 ++-
git-send-email.perl | 3 +--
git-sh-setup.sh | 16 ++++++++++++++++
git-tag.sh | 3 ++-
8 files changed, 32 insertions(+), 21 deletions(-)
diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt
index f96142f..5caad56 100644
--- a/Documentation/git-commit.txt
+++ b/Documentation/git-commit.txt
@@ -244,10 +244,11 @@ on the Subject: line and the rest of the commit in the body.
include::i18n.txt[]
-ENVIRONMENT VARIABLES
----------------------
-The command specified by either the VISUAL or EDITOR environment
-variables is used to edit the commit log message.
+ENVIRONMENT AND CONFIGURATION VARIABLES
+---------------------------------------
+The editor used to edit the commit log message will be chosen from the
+core.editor configuration variable, the VISUAL environment variable, or the
+EDITOR environment variable (in that order).
HOOKS
-----
diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt
index 293686c..e7723c9 100644
--- a/Documentation/git-send-email.txt
+++ b/Documentation/git-send-email.txt
@@ -44,8 +44,8 @@ The --cc option must be repeated for each user you want on the cc list.
value; if that is unspecified, default to --chain-reply-to.
--compose::
- Use $EDITOR to edit an introductory message for the
- patch series.
+ Use core.editor, $VISUAL, or $EDITOR to edit an introductory message
+ for the patch series.
--from::
Specify the sender of the emails. This will default to
diff --git a/git-am.sh b/git-am.sh
index e5e6f2c..dd517f4 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -364,7 +364,8 @@ do
[yY]*) action=yes ;;
[aA]*) action=yes interactive= ;;
[nN]*) action=skip ;;
- [eE]*) "${VISUAL:-${EDITOR:-vi}}" "$dotest/final-commit"
+ [eE]*) set_editor
+ "$GIT_EDITOR" "$dotest/final-commit"
action=again ;;
[vV]*) action=again
LESS=-S ${PAGER:-less} "$dotest/patch" ;;
diff --git a/git-commit.sh b/git-commit.sh
index 3f3de17..4d5d898 100755
--- a/git-commit.sh
+++ b/git-commit.sh
@@ -544,18 +544,10 @@ fi
case "$no_edit" in
'')
- case "${VISUAL:-$EDITOR},$TERM" in
- ,dumb)
- echo >&2 "Terminal is dumb but no VISUAL nor EDITOR defined."
- echo >&2 "Please supply the commit log message using either"
- echo >&2 "-m or -F option. A boilerplate log message has"
- echo >&2 "been prepared in $GIT_DIR/COMMIT_EDITMSG"
- exit 1
- ;;
- esac
+ set_editor
git-var GIT_AUTHOR_IDENT > /dev/null || die
git-var GIT_COMMITTER_IDENT > /dev/null || die
- ${VISUAL:-${EDITOR:-vi}} "$GIT_DIR/COMMIT_EDITMSG"
+ $GIT_EDITOR "$GIT_DIR/COMMIT_EDITMSG"
;;
esac
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index f395076..27f8639 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -414,7 +414,8 @@ EOF
die_abort "Nothing to do"
cp "$TODO" "$TODO".backup
- ${VISUAL:-${EDITOR:-vi}} "$TODO" ||
+ set_editor
+ $GIT_EDITOR "$TODO" ||
die "Could not execute editor"
test -z "$(grep -ve '^$' -e '^#' < $TODO)" &&
diff --git a/git-send-email.perl b/git-send-email.perl
index 7552cac..ad17b4e 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -341,8 +341,7 @@ GIT: for the patch you are writing.
EOT
close(C);
- my $editor = $ENV{EDITOR};
- $editor = 'vi' unless defined $editor;
+ my $editor = $repo->config("core.editor") || $ENV{VISUAL} || $ENV{EDITOR} || "vi";
system($editor, $compose_filename);
open(C2,">",$compose_filename . ".final")
diff --git a/git-sh-setup.sh b/git-sh-setup.sh
index 4ed07e9..dbc4833 100755
--- a/git-sh-setup.sh
+++ b/git-sh-setup.sh
@@ -28,6 +28,22 @@ set_reflog_action() {
fi
}
+set_editor() {
+ GIT_EDITOR=$(git config core.editor || echo ${VISUAL:-${EDITOR}})
+ case "$GIT_EDITOR,$TERM" in
+ ,dumb)
+ echo >&2 "No editor specified in core.editor, VISUAL, or EDITOR."
+ echo >&2 "Tried to fall back to vi but terminal is dumb."
+ echo >&2 "Please set one of these variables to an appropriate"
+ echo >&2 "editor or run $0 with options that will not cause an"
+ echo >&2 "editor to be invoked (e.g., -m or -F for git-commit)."
+ exit 1
+ ;;
+ esac
+ GIT_EDITOR=${GIT_EDITOR:-vi}
+ export GIT_EDITOR
+}
+
is_bare_repository () {
git rev-parse --is-bare-repository
}
diff --git a/git-tag.sh b/git-tag.sh
index 1c25d88..f1a66d0 100755
--- a/git-tag.sh
+++ b/git-tag.sh
@@ -177,7 +177,8 @@ if [ "$annotate" ]; then
( echo "#"
echo "# Write a tag message"
echo "#" ) > "$GIT_DIR"/TAG_EDITMSG
- ${VISUAL:-${EDITOR:-vi}} "$GIT_DIR"/TAG_EDITMSG || exit
+ set_editor
+ $GIT_EDITOR "$GIT_DIR"/TAG_EDITMSG || exit
else
printf '%s\n' "$message" >"$GIT_DIR"/TAG_EDITMSG
fi
--
1.5.3.rc2.21.gfc4a18-dirty
next prev parent reply other threads:[~2007-07-20 0:28 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-19 5:39 [PATCH] Add commit.editor configuration variable Adam Roben
2007-07-19 6:08 ` Junio C Hamano
2007-07-19 6:17 ` Adam Roben
2007-07-19 6:23 ` Shawn O. Pearce
2007-07-19 6:53 ` Junio C Hamano
2007-07-19 9:54 ` Johannes Schindelin
2007-07-19 18:24 ` [PATCH] Add git-sh-setup::set_editor() Adam Roben
2007-07-19 18:46 ` Johannes Schindelin
2007-07-19 19:26 ` David Kastrup
2007-07-19 21:10 ` [PATCH] Print an error when falling back to vi on a dumb terminal Adam Roben
2007-07-19 21:19 ` Johannes Schindelin
2007-07-20 0:15 ` Junio C Hamano
2007-07-20 0:28 ` Adam Roben [this message]
2007-07-20 5:09 ` [PATCH] Add GIT_EDITOR environment variable and core.editor configuration variable Adam Roben
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=11848913032579-git-send-email-aroben@apple.com \
--to=aroben@apple.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).