add -i, send-email, svn, p4, etc: use "git var GIT_EDITOR"
Use the new "git var GIT_EDITOR" feature to decide what editor to use, instead of duplicating its logic elsewhere. This should make the behavior of commands in edge cases (e.g., editor names with spaces) a little more consistent. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
6361824589
commit
b4479f0747
@ -387,9 +387,7 @@ core.editor::
|
|||||||
Commands such as `commit` and `tag` that lets you edit
|
Commands such as `commit` and `tag` that lets you edit
|
||||||
messages by launching an editor uses the value of this
|
messages by launching an editor uses the value of this
|
||||||
variable when it is set, and the environment variable
|
variable when it is set, and the environment variable
|
||||||
`GIT_EDITOR` is not set. The order of preference is
|
`GIT_EDITOR` is not set. See linkgit:git-var[1].
|
||||||
`GIT_EDITOR` environment, `core.editor`, `VISUAL` and
|
|
||||||
`EDITOR` environment variables and then finally `vi`.
|
|
||||||
|
|
||||||
core.pager::
|
core.pager::
|
||||||
The command that git will use to paginate output. Can
|
The command that git will use to paginate output. Can
|
||||||
|
@ -323,7 +323,7 @@ ENVIRONMENT AND CONFIGURATION VARIABLES
|
|||||||
The editor used to edit the commit log message will be chosen from the
|
The editor used to edit the commit log message will be chosen from the
|
||||||
GIT_EDITOR environment variable, the core.editor configuration variable, the
|
GIT_EDITOR environment variable, the core.editor configuration variable, the
|
||||||
VISUAL environment variable, or the EDITOR environment variable (in that
|
VISUAL environment variable, or the EDITOR environment variable (in that
|
||||||
order).
|
order). See linkgit:git-var[1] for details.
|
||||||
|
|
||||||
HOOKS
|
HOOKS
|
||||||
-----
|
-----
|
||||||
|
@ -60,8 +60,8 @@ The --bcc option must be repeated for each user you want on the bcc list.
|
|||||||
The --cc option must be repeated for each user you want on the cc list.
|
The --cc option must be repeated for each user you want on the cc list.
|
||||||
|
|
||||||
--compose::
|
--compose::
|
||||||
Use $GIT_EDITOR, core.editor, $VISUAL, or $EDITOR to edit an
|
Invoke a text editor (see GIT_EDITOR in linkgit:git-var[1])
|
||||||
introductory message for the patch series.
|
to edit an introductory message for the patch series.
|
||||||
+
|
+
|
||||||
When '--compose' is used, git send-email will use the From, Subject, and
|
When '--compose' is used, git send-email will use the From, Subject, and
|
||||||
In-Reply-To headers specified in the message. If the body of the message
|
In-Reply-To headers specified in the message. If the body of the message
|
||||||
|
@ -729,13 +729,10 @@ class P4Submit(Command):
|
|||||||
tmpFile.write(submitTemplate + separatorLine + diff + newdiff)
|
tmpFile.write(submitTemplate + separatorLine + diff + newdiff)
|
||||||
tmpFile.close()
|
tmpFile.close()
|
||||||
mtime = os.stat(fileName).st_mtime
|
mtime = os.stat(fileName).st_mtime
|
||||||
defaultEditor = "vi"
|
|
||||||
if platform.system() == "Windows":
|
|
||||||
defaultEditor = "notepad"
|
|
||||||
if os.environ.has_key("P4EDITOR"):
|
if os.environ.has_key("P4EDITOR"):
|
||||||
editor = os.environ.get("P4EDITOR")
|
editor = os.environ.get("P4EDITOR")
|
||||||
else:
|
else:
|
||||||
editor = os.environ.get("EDITOR", defaultEditor);
|
editor = read_pipe("git var GIT_EDITOR")
|
||||||
system(editor + " " + fileName)
|
system(editor + " " + fileName)
|
||||||
|
|
||||||
response = "y"
|
response = "y"
|
||||||
|
@ -987,8 +987,7 @@ sub edit_hunk_manually {
|
|||||||
EOF
|
EOF
|
||||||
close $fh;
|
close $fh;
|
||||||
|
|
||||||
my $editor = $ENV{GIT_EDITOR} || $repo->config("core.editor")
|
chomp(my $editor = run_cmd_pipe(qw(git var GIT_EDITOR)));
|
||||||
|| $ENV{VISUAL} || $ENV{EDITOR} || "vi";
|
|
||||||
system('sh', '-c', $editor.' "$@"', $editor, $hunkfile);
|
system('sh', '-c', $editor.' "$@"', $editor, $hunkfile);
|
||||||
|
|
||||||
if ($? != 0) {
|
if ($? != 0) {
|
||||||
|
@ -162,7 +162,8 @@ my $compose_filename;
|
|||||||
|
|
||||||
# Handle interactive edition of files.
|
# Handle interactive edition of files.
|
||||||
my $multiedit;
|
my $multiedit;
|
||||||
my $editor = $ENV{GIT_EDITOR} || Git::config(@repo, "core.editor") || $ENV{VISUAL} || $ENV{EDITOR} || "vi";
|
my $editor = Git::command_oneline('var', 'GIT_EDITOR');
|
||||||
|
|
||||||
sub do_edit {
|
sub do_edit {
|
||||||
if (defined($multiedit) && !$multiedit) {
|
if (defined($multiedit) && !$multiedit) {
|
||||||
map {
|
map {
|
||||||
|
@ -99,19 +99,12 @@ set_reflog_action() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
git_editor() {
|
git_editor() {
|
||||||
: "${GIT_EDITOR:=$(git config core.editor)}"
|
if test -z "${GIT_EDITOR:+set}"
|
||||||
: "${GIT_EDITOR:=${VISUAL:-${EDITOR}}}"
|
then
|
||||||
case "$GIT_EDITOR,$TERM" in
|
GIT_EDITOR="$(git var GIT_EDITOR)" || return $?
|
||||||
,dumb)
|
fi
|
||||||
echo >&2 "No editor specified in GIT_EDITOR, core.editor, VISUAL,"
|
|
||||||
echo >&2 "or EDITOR. Tried to fall back to vi but terminal is dumb."
|
eval "$GIT_EDITOR" '"$@"'
|
||||||
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
|
|
||||||
eval "${GIT_EDITOR:=vi}" '"$@"'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
is_bare_repository () {
|
is_bare_repository () {
|
||||||
|
@ -1321,9 +1321,8 @@ sub get_commit_entry {
|
|||||||
close $log_fh or croak $!;
|
close $log_fh or croak $!;
|
||||||
|
|
||||||
if ($_edit || ($type eq 'tree')) {
|
if ($_edit || ($type eq 'tree')) {
|
||||||
my $editor = $ENV{VISUAL} || $ENV{EDITOR} || 'vi';
|
chomp(my $editor = command_oneline(qw(var GIT_EDITOR)));
|
||||||
# TODO: strip out spaces, comments, like git-commit.sh
|
system('sh', '-c', $editor.' "$@"', $editor, $commit_editmsg);
|
||||||
system($editor, $commit_editmsg);
|
|
||||||
}
|
}
|
||||||
rename $commit_editmsg, $commit_msg or croak $!;
|
rename $commit_editmsg, $commit_msg or croak $!;
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user