{"thread":{"id":"9103","subject":"[PATCH] Add commit.editor configuration variable","startedAt":"2007-07-19T05:39:48Z","lastAt":"2007-07-20T05:09:35Z","messageCount":14,"participants":["Adam Roben","Junio C Hamano","Shawn O. Pearce","Johannes Schindelin","David Kastrup"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"47809","messageId":"11848235881723-git-send-email-aroben@apple.com","threadId":"9103","inReplyTo":null,"subject":"[PATCH] Add commit.editor configuration variable","fromName":"Adam Roben","fromEmail":"aroben@apple.com","sentAt":"2007-07-19T05:39:48Z","receivedAt":"2007-07-19T05:39:48Z","isPatch":true,"sender":{"key":"aroben@apple.com","avatar":"https://gravatar.com/avatar/9d3697e1de53890adf241331f4b970bdd2b18962b2ff0b8028ebb00e085807f8?d=mp&s=160"},"body":"This variable lets you specify a different editor for editing commit messages.\nIf commit.editor is not set, git-commit falls back to VISUAL, then EDITOR as\nbefore.\n\nSigned-off-by: Adam Roben <aroben@apple.com>\n---\n Documentation/git-commit.txt |    9 +++++----\n git-commit.sh                |   13 +++++++------\n 2 files changed, 12 insertions(+), 10 deletions(-)\n\ndiff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt\nindex f96142f..1a628be 100644\n--- a/Documentation/git-commit.txt\n+++ b/Documentation/git-commit.txt\n@@ -244,10 +244,11 @@ on the Subject: line and the rest of the commit in the body.\n \n include::i18n.txt[]\n \n-ENVIRONMENT VARIABLES\n----------------------\n-The command specified by either the VISUAL or EDITOR environment\n-variables is used to edit the commit log message.\n+ENVIRONMENT AND CONFIGURATION VARIABLES\n+---------------------------------------\n+The editor used to edit the commit log message will be chosen from the\n+commit.editor configuration variable, the VISUAL environment variable, or the\n+EDITOR environment variable (in that order).\n \n HOOKS\n -----\ndiff --git a/git-commit.sh b/git-commit.sh\nindex 3f3de17..c4d8501 100755\n--- a/git-commit.sh\n+++ b/git-commit.sh\n@@ -544,18 +544,19 @@ fi\n \n case \"$no_edit\" in\n '')\n-\tcase \"${VISUAL:-$EDITOR},$TERM\" in\n+\tcommit_editor=$(git config commit.editor || echo ${VISUAL:-$EDITOR})\n+\tcase \"$commit_editor,$TERM\" in\n \t,dumb)\n-\t\techo >&2 \"Terminal is dumb but no VISUAL nor EDITOR defined.\"\n-\t\techo >&2 \"Please supply the commit log message using either\"\n-\t\techo >&2 \"-m or -F option.  A boilerplate log message has\"\n-\t\techo >&2 \"been prepared in $GIT_DIR/COMMIT_EDITMSG\"\n+\t\techo >&2 \"Terminal is dumb but commit.editor, VISUAL, and EDITOR\"\n+\t\techo >&2 \"are undefined. Please supply the commit log message\"\n+\t\techo >&2 \"using either -m or -F option.  A boilerplate log message\"\n+\t\techo >&2 \"has been prepared in $GIT_DIR/COMMIT_EDITMSG\"\n \t\texit 1\n \t\t;;\n \tesac\n \tgit-var GIT_AUTHOR_IDENT > /dev/null  || die\n \tgit-var GIT_COMMITTER_IDENT > /dev/null  || die\n-\t${VISUAL:-${EDITOR:-vi}} \"$GIT_DIR/COMMIT_EDITMSG\"\n+\t${commit_editor:-vi} \"$GIT_DIR/COMMIT_EDITMSG\"\n \t;;\n esac\n \n-- \n1.5.2.2.620.g42358-dirty\n"},{"id":"47811","messageId":"7v7iox3oz8.fsf@assigned-by-dhcp.cox.net","threadId":"9103","inReplyTo":"11848235881723-git-send-email-aroben@apple.com","subject":"Re: [PATCH] Add commit.editor configuration variable","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-07-19T06:08:11Z","receivedAt":"2007-07-19T06:08:11Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"I do not think commit.editor is a good name.  Wouldn't we want\nthat customized editor for \"git tag -a\" as well?  Probably\ncore.editor would come nicely next to core.pager we already\nhave.\n"},{"id":"47814","messageId":"47EE39C7-0D57-48EC-B5A0-C10E49997E32@apple.com","threadId":"9103","inReplyTo":"7v7iox3oz8.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Add commit.editor configuration variable","fromName":"Adam Roben","fromEmail":"aroben@apple.com","sentAt":"2007-07-19T06:17:55Z","receivedAt":"2007-07-19T06:17:55Z","isPatch":true,"sender":{"key":"aroben@apple.com","avatar":"https://gravatar.com/avatar/9d3697e1de53890adf241331f4b970bdd2b18962b2ff0b8028ebb00e085807f8?d=mp&s=160"},"body":"On Jul 18, 2007, at 11:08 PM, Junio C Hamano wrote:\n\n> I do not think commit.editor is a good name.  Wouldn't we want\n> that customized editor for \"git tag -a\" as well?  Probably\n> core.editor would come nicely next to core.pager we already\n> have.\n\n    I considered core.editor, but if it's an editor that is *only*  \nused for commit messages then that seems to be a too-general name, and  \nsomething like core.commit_message_editor seemed far too long. Any  \nsuggestions?\n\n    I had forgotten about \"git tag -a\" -- I will add support for that  \nas well.\n\n-Adam\n"},{"id":"47815","messageId":"20070719062302.GG32566@spearce.org","threadId":"9103","inReplyTo":"47EE39C7-0D57-48EC-B5A0-C10E49997E32@apple.com","subject":"Re: [PATCH] Add commit.editor configuration variable","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-07-19T06:23:02Z","receivedAt":"2007-07-19T06:23:02Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Adam Roben <aroben@apple.com> wrote:\n> On Jul 18, 2007, at 11:08 PM, Junio C Hamano wrote:\n> \n> >I do not think commit.editor is a good name.  Wouldn't we want\n> >that customized editor for \"git tag -a\" as well?  Probably\n> >core.editor would come nicely next to core.pager we already\n> >have.\n> \n>    I considered core.editor, but if it's an editor that is *only*  \n> used for commit messages then that seems to be a too-general name, and  \n> something like core.commit_message_editor seemed far too long. Any  \n> suggestions?\n> \n>    I had forgotten about \"git tag -a\" -- I will add support for that  \n> as well.\n\nWe only launch an editor for three reasons: commit messages, tag\nmessages and git-rebase -i.  If we were to ever add a new editor\nusing thingy, odds are the user would want the same editor by\ndefault for that too.\n\nSo please, core.editor, and also use it in git-rebase--interactive.\n\n-- \nShawn.\n"},{"id":"47816","messageId":"7v1wf451fc.fsf@assigned-by-dhcp.cox.net","threadId":"9103","inReplyTo":"20070719062302.GG32566@spearce.org","subject":"Re: [PATCH] Add commit.editor configuration variable","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-07-19T06:53:59Z","receivedAt":"2007-07-19T06:53:59Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Shawn O. Pearce\" <spearce@spearce.org> writes:\n\n> We only launch an editor for three reasons: commit messages, tag\n> messages and git-rebase -i.  If we were to ever add a new editor\n> using thingy, odds are the user would want the same editor by\n> default for that too.\n>\n> So please, core.editor, and also use it in git-rebase--interactive.\n\nAh, add \"git-am -i\" to the mix.  Potentially, git-notes would\nuse it as well.\n"},{"id":"47829","messageId":"Pine.LNX.4.64.0707191053230.14781@racer.site","threadId":"9103","inReplyTo":"7v1wf451fc.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Add commit.editor configuration variable","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-07-19T09:54:12Z","receivedAt":"2007-07-19T09:54:12Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 18 Jul 2007, Junio C Hamano wrote:\n\n> \"Shawn O. Pearce\" <spearce@spearce.org> writes:\n> \n> > We only launch an editor for three reasons: commit messages, tag\n> > messages and git-rebase -i.  If we were to ever add a new editor\n> > using thingy, odds are the user would want the same editor by\n> > default for that too.\n> >\n> > So please, core.editor, and also use it in git-rebase--interactive.\n> \n> Ah, add \"git-am -i\" to the mix.  Potentially, git-notes would\n> use it as well.\n\nNow with so many commands in the lot, how about putting the code into \ngit-sh-setup, into a function \"get_editor()\"?\n\nCiao,\nDscho\n"},{"id":"47886","messageId":"11848694482569-git-send-email-aroben@apple.com","threadId":"9103","inReplyTo":"Pine.LNX.4.64.0707191053230.14781@racer.site","subject":"[PATCH] Add git-sh-setup::set_editor()","fromName":"Adam Roben","fromEmail":"aroben@apple.com","sentAt":"2007-07-19T18:24:08Z","receivedAt":"2007-07-19T18:24:08Z","isPatch":true,"sender":{"key":"aroben@apple.com","avatar":"https://gravatar.com/avatar/9d3697e1de53890adf241331f4b970bdd2b18962b2ff0b8028ebb00e085807f8?d=mp&s=160"},"body":"This function can be used to set the GIT_EDITOR variable to the user's\npreferred editor.\n\nSigned-off-by: Adam Roben <aroben@apple.com>\n---\nOn Jul 19, 2007, at 2:54 AM, Johannes Schindelin wrote:\n> Now with so many commands in the lot, how about putting the code into \n> git-sh-setup, into a function \"get_editor()\"?\n\nHere you go. I didn't add anything similar for git-send-email.perl since that\nis the only case we have in perl of invoking the editor right now, and I wasn't\nsure of a good place to add such a function.\n\n git-am.sh                  |    3 ++-\n git-commit.sh              |    6 +++---\n git-rebase--interactive.sh |    3 ++-\n git-sh-setup.sh            |    5 +++++\n git-tag.sh                 |    3 ++-\n 5 files changed, 14 insertions(+), 6 deletions(-)\n\ndiff --git a/git-am.sh b/git-am.sh\nindex 3a651ae..a5de0a1 100755\n--- a/git-am.sh\n+++ b/git-am.sh\n@@ -7,6 +7,7 @@ USAGE='[--signoff] [--dotest=<dir>] [--utf8 | --no-utf8] [--binary] [--3way]\n   or, when resuming [--skip | --resolved]'\n . git-sh-setup\n set_reflog_action am\n+set_editor\n require_work_tree\n \n git var GIT_COMMITTER_IDENT >/dev/null || exit\n@@ -364,7 +365,7 @@ do\n \t\t[yY]*) action=yes ;;\n \t\t[aA]*) action=yes interactive= ;;\n \t\t[nN]*) action=skip ;;\n-\t\t[eE]*) \"$(git config core.editor || echo ${VISUAL:-${EDITOR:-vi}})\" \"$dotest/final-commit\"\n+\t\t[eE]*) \"$GIT_EDITOR\" \"$dotest/final-commit\"\n \t\t       action=again ;;\n \t\t[vV]*) action=again\n \t\t       LESS=-S ${PAGER:-less} \"$dotest/patch\" ;;\ndiff --git a/git-commit.sh b/git-commit.sh\nindex 72e4cf0..9adb03c 100755\n--- a/git-commit.sh\n+++ b/git-commit.sh\n@@ -6,6 +6,7 @@\n USAGE='[-a | --interactive] [-s] [-v] [--no-verify] [-m <message> | -F <logfile> | (-C|-c) <commit> | --amend] [-u] [-e] [--author <author>] [[-i | -o] <path>...]'\n SUBDIRECTORY_OK=Yes\n . git-sh-setup\n+set_editor\n require_work_tree\n \n git rev-parse --verify HEAD >/dev/null 2>&1 || initial_commit=t\n@@ -544,8 +545,7 @@ fi\n \n case \"$no_edit\" in\n '')\n-\tcommit_editor=$(git config core.editor || echo ${VISUAL:-$EDITOR})\n-\tcase \"$commit_editor,$TERM\" in\n+\tcase \"$GIT_EDITOR,$TERM\" in\n \t,dumb)\n \t\techo >&2 \"Terminal is dumb but core.editor, VISUAL, and EDITOR\"\n \t\techo >&2 \"are undefined. Please supply the commit log message\"\n@@ -556,7 +556,7 @@ case \"$no_edit\" in\n \tesac\n \tgit-var GIT_AUTHOR_IDENT > /dev/null  || die\n \tgit-var GIT_COMMITTER_IDENT > /dev/null  || die\n-\t${commit_editor:-vi} \"$GIT_DIR/COMMIT_EDITMSG\"\n+\t$GIT_EDITOR \"$GIT_DIR/COMMIT_EDITMSG\"\n \t;;\n esac\n \ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 2e15abb..32d1f53 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -15,6 +15,7 @@ USAGE='(--continue | --abort | --skip | [--preserve-merges] [--verbose]\n \n . git-sh-setup\n require_work_tree\n+set_editor\n \n DOTEST=\"$GIT_DIR/.dotest-merge\"\n TODO=\"$DOTEST\"/todo\n@@ -414,7 +415,7 @@ EOF\n \t\t\tdie_abort \"Nothing to do\"\n \n \t\tcp \"$TODO\" \"$TODO\".backup\n-\t\t$(git config core.editor || echo ${VISUAL:-${EDITOR:-vi}}) \"$TODO\" ||\n+\t\t$GIT_EDITOR \"$TODO\" ||\n \t\t\tdie \"Could not execute editor\"\n \n \t\ttest -z \"$(grep -ve '^$' -e '^#' < $TODO)\" &&\ndiff --git a/git-sh-setup.sh b/git-sh-setup.sh\nindex 4ed07e9..f43ab33 100755\n--- a/git-sh-setup.sh\n+++ b/git-sh-setup.sh\n@@ -28,6 +28,11 @@ set_reflog_action() {\n \tfi\n }\n \n+set_editor() {\n+    GIT_EDITOR=$(git config core.editor || echo ${VISUAL:-${EDITOR:-vi}})\n+    export GIT_EDITOR\n+}\n+\n is_bare_repository () {\n \tgit rev-parse --is-bare-repository\n }\ndiff --git a/git-tag.sh b/git-tag.sh\nindex 9aa30b4..0a6f2e7 100755\n--- a/git-tag.sh\n+++ b/git-tag.sh\n@@ -4,6 +4,7 @@\n USAGE='[-n [<num>]] -l [<pattern>] | [-a | -s | -u <key-id>] [-f | -d | -v] [-m <msg>] <tagname> [<head>]'\n SUBDIRECTORY_OK='Yes'\n . git-sh-setup\n+set_editor\n \n message_given=\n annotate=\n@@ -177,7 +178,7 @@ if [ \"$annotate\" ]; then\n         ( echo \"#\"\n           echo \"# Write a tag message\"\n           echo \"#\" ) > \"$GIT_DIR\"/TAG_EDITMSG\n-        $(git config core.editor || echo ${VISUAL:-${EDITOR:-vi}}) \"$GIT_DIR\"/TAG_EDITMSG || exit\n+        $GIT_EDITOR \"$GIT_DIR\"/TAG_EDITMSG || exit\n     else\n         printf '%s\\n' \"$message\" >\"$GIT_DIR\"/TAG_EDITMSG\n     fi\n-- \n1.5.3.rc2.20.g8e32-dirty\n"},{"id":"47889","messageId":"Pine.LNX.4.64.0707191944560.14781@racer.site","threadId":"9103","inReplyTo":"11848694482569-git-send-email-aroben@apple.com","subject":"Re: [PATCH] Add git-sh-setup::set_editor()","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-07-19T18:46:50Z","receivedAt":"2007-07-19T18:46:50Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Thu, 19 Jul 2007, Adam Roben wrote:\n\n> This function can be used to set the GIT_EDITOR variable to the user's\n> preferred editor.\n\nMuch nicer, thank you.\n\nHowever,\n\n> -\tcommit_editor=$(git config core.editor || echo ${VISUAL:-$EDITOR})\n> -\tcase \"$commit_editor,$TERM\" in\n> +\tcase \"$GIT_EDITOR,$TERM\" in\n>  \t,dumb)\n\nThis can no longer happen, since ...\n\n> +set_editor() {\n> +    GIT_EDITOR=$(git config core.editor || echo ${VISUAL:-${EDITOR:-vi}})\n> +    export GIT_EDITOR\n> +}\n\n... \"vi\" is the last resort, not \"\", right?\n\nSo I guess you just want to drag that test and warning into git-sh-setup \n(where I think it has a better home anyway).\n\nCiao,\nDscho\n"},{"id":"47895","messageId":"86tzs0yz27.fsf@lola.quinscape.zz","threadId":"9103","inReplyTo":"Pine.LNX.4.64.0707191944560.14781@racer.site","subject":"Re: [PATCH] Add git-sh-setup::set_editor()","fromName":"David Kastrup","fromEmail":"dak@gnu.org","sentAt":"2007-07-19T19:26:56Z","receivedAt":"2007-07-19T19:26:56Z","isPatch":true,"sender":{"key":"dak@gnu.org","avatar":"https://avatars.githubusercontent.com/u/52141349?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> On Thu, 19 Jul 2007, Adam Roben wrote:\n>\n>> This function can be used to set the GIT_EDITOR variable to the user's\n>> preferred editor.\n>\n> Much nicer, thank you.\n>\n> However,\n>\n>> -\tcommit_editor=$(git config core.editor || echo ${VISUAL:-$EDITOR})\n>> -\tcase \"$commit_editor,$TERM\" in\n>> +\tcase \"$GIT_EDITOR,$TERM\" in\n>>  \t,dumb)\n>\n> This can no longer happen, since ...\n>\n>> +set_editor() {\n>> +    GIT_EDITOR=$(git config core.editor || echo ${VISUAL:-${EDITOR:-vi}})\n>> +    export GIT_EDITOR\n>> +}\n\nStrictly speaking it can happen when git has an empty string for\ncore.editor configured.  Not that the behavior chosen in this case\nwould make any sense, but just for the record...\n\n-- \nDavid Kastrup\n"},{"id":"47904","messageId":"11848794193942-git-send-email-aroben@apple.com","threadId":"9103","inReplyTo":"Pine.LNX.4.64.0707191944560.14781@racer.site","subject":"[PATCH] Print an error when falling back to vi on a dumb terminal","fromName":"Adam Roben","fromEmail":"aroben@apple.com","sentAt":"2007-07-19T21:10:19Z","receivedAt":"2007-07-19T21:10:19Z","isPatch":true,"sender":{"key":"aroben@apple.com","avatar":"https://gravatar.com/avatar/9d3697e1de53890adf241331f4b970bdd2b18962b2ff0b8028ebb00e085807f8?d=mp&s=160"},"body":"Signed-off-by: Adam Roben <aroben@apple.com>\n---\nOn Jul 19, 2007, at 11:46 AM, Johannes Schindelin wrote:\n\n> > -       commit_editor=$(git config core.editor || echo ${VISUAL:-$EDITOR})\n> > -       case \"$commit_editor,$TERM\" in\n> > +       case \"$GIT_EDITOR,$TERM\" in\n> >         ,dumb)\n> \n>         This can no longer happen, since ...\n> \n> >         +set_editor() {\n> >         +    GIT_EDITOR=$(git config core.editor || echo ${VISUAL:-${EDITOR:-vi}})\n> >         +    export GIT_EDITOR\n> >         +}\n> \n>         ... \"vi\" is the last resort, not \"\", right?\n> \n>         So I guess you just want to drag that test and warning into git-sh-setup \n>         (where I think it has a better home anyway).\n\nHere you go. I'm not terribly happy with the error message, though. I tried to\nbe as clear as possible and to keep some of the nice information that was in\nthe git-commit error message. Please improve upon it if you can.\n\n git-am.sh                  |    4 ++--\n git-commit.sh              |   11 +----------\n git-rebase--interactive.sh |    2 +-\n git-sh-setup.sh            |   15 +++++++++++++--\n git-tag.sh                 |    2 +-\n 5 files changed, 18 insertions(+), 16 deletions(-)\n\ndiff --git a/git-am.sh b/git-am.sh\nindex a5de0a1..dd517f4 100755\n--- a/git-am.sh\n+++ b/git-am.sh\n@@ -7,7 +7,6 @@ USAGE='[--signoff] [--dotest=<dir>] [--utf8 | --no-utf8] [--binary] [--3way]\n   or, when resuming [--skip | --resolved]'\n . git-sh-setup\n set_reflog_action am\n-set_editor\n require_work_tree\n \n git var GIT_COMMITTER_IDENT >/dev/null || exit\n@@ -365,7 +364,8 @@ do\n \t\t[yY]*) action=yes ;;\n \t\t[aA]*) action=yes interactive= ;;\n \t\t[nN]*) action=skip ;;\n-\t\t[eE]*) \"$GIT_EDITOR\" \"$dotest/final-commit\"\n+\t\t[eE]*) set_editor\n+\t\t       \"$GIT_EDITOR\" \"$dotest/final-commit\"\n \t\t       action=again ;;\n \t\t[vV]*) action=again\n \t\t       LESS=-S ${PAGER:-less} \"$dotest/patch\" ;;\ndiff --git a/git-commit.sh b/git-commit.sh\nindex 9adb03c..4d5d898 100755\n--- a/git-commit.sh\n+++ b/git-commit.sh\n@@ -6,7 +6,6 @@\n USAGE='[-a | --interactive] [-s] [-v] [--no-verify] [-m <message> | -F <logfile> | (-C|-c) <commit> | --amend] [-u] [-e] [--author <author>] [[-i | -o] <path>...]'\n SUBDIRECTORY_OK=Yes\n . git-sh-setup\n-set_editor\n require_work_tree\n \n git rev-parse --verify HEAD >/dev/null 2>&1 || initial_commit=t\n@@ -545,15 +544,7 @@ fi\n \n case \"$no_edit\" in\n '')\n-\tcase \"$GIT_EDITOR,$TERM\" in\n-\t,dumb)\n-\t\techo >&2 \"Terminal is dumb but core.editor, VISUAL, and EDITOR\"\n-\t\techo >&2 \"are undefined. Please supply the commit log message\"\n-\t\techo >&2 \"using either -m or -F option.  A boilerplate log message\"\n-\t\techo >&2 \"has been prepared in $GIT_DIR/COMMIT_EDITMSG\"\n-\t\texit 1\n-\t\t;;\n-\tesac\n+\tset_editor\n \tgit-var GIT_AUTHOR_IDENT > /dev/null  || die\n \tgit-var GIT_COMMITTER_IDENT > /dev/null  || die\n \t$GIT_EDITOR \"$GIT_DIR/COMMIT_EDITMSG\"\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 32d1f53..27f8639 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -15,7 +15,6 @@ USAGE='(--continue | --abort | --skip | [--preserve-merges] [--verbose]\n \n . git-sh-setup\n require_work_tree\n-set_editor\n \n DOTEST=\"$GIT_DIR/.dotest-merge\"\n TODO=\"$DOTEST\"/todo\n@@ -415,6 +414,7 @@ EOF\n \t\t\tdie_abort \"Nothing to do\"\n \n \t\tcp \"$TODO\" \"$TODO\".backup\n+\t\tset_editor\n \t\t$GIT_EDITOR \"$TODO\" ||\n \t\t\tdie \"Could not execute editor\"\n \ndiff --git a/git-sh-setup.sh b/git-sh-setup.sh\nindex f43ab33..dbc4833 100755\n--- a/git-sh-setup.sh\n+++ b/git-sh-setup.sh\n@@ -29,8 +29,19 @@ set_reflog_action() {\n }\n \n set_editor() {\n-    GIT_EDITOR=$(git config core.editor || echo ${VISUAL:-${EDITOR:-vi}})\n-    export GIT_EDITOR\n+\tGIT_EDITOR=$(git config core.editor || echo ${VISUAL:-${EDITOR}})\n+\tcase \"$GIT_EDITOR,$TERM\" in\n+\t,dumb)\n+\t\techo >&2 \"No editor specified in core.editor, VISUAL, or EDITOR.\"\n+\t\techo >&2 \"Tried to fall back to vi but terminal is dumb.\"\n+\t\techo >&2 \"Please set one of these variables to an appropriate\"\n+\t\techo >&2 \"editor or run $0 with options that will not cause an\"\n+\t\techo >&2 \"editor to be invoked (e.g., -m or -F for git-commit).\"\n+\t\texit 1\n+\t\t;;\n+\tesac\n+\tGIT_EDITOR=${GIT_EDITOR:-vi}\n+\texport GIT_EDITOR\n }\n \n is_bare_repository () {\ndiff --git a/git-tag.sh b/git-tag.sh\nindex 0a6f2e7..f1a66d0 100755\n--- a/git-tag.sh\n+++ b/git-tag.sh\n@@ -4,7 +4,6 @@\n USAGE='[-n [<num>]] -l [<pattern>] | [-a | -s | -u <key-id>] [-f | -d | -v] [-m <msg>] <tagname> [<head>]'\n SUBDIRECTORY_OK='Yes'\n . git-sh-setup\n-set_editor\n \n message_given=\n annotate=\n@@ -178,6 +177,7 @@ if [ \"$annotate\" ]; then\n         ( echo \"#\"\n           echo \"# Write a tag message\"\n           echo \"#\" ) > \"$GIT_DIR\"/TAG_EDITMSG\n+        set_editor\n         $GIT_EDITOR \"$GIT_DIR\"/TAG_EDITMSG || exit\n     else\n         printf '%s\\n' \"$message\" >\"$GIT_DIR\"/TAG_EDITMSG\n-- \n1.5.3.rc2.21.gfc4a18-dirty\n"},{"id":"47905","messageId":"Pine.LNX.4.64.0707192219000.14781@racer.site","threadId":"9103","inReplyTo":"11848794193942-git-send-email-aroben@apple.com","subject":"Re: [PATCH] Print an error when falling back to vi on a dumb terminal","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-07-19T21:19:05Z","receivedAt":"2007-07-19T21:19:05Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Thu, 19 Jul 2007, Adam Roben wrote:\n\n> Signed-off-by: Adam Roben <aroben@apple.com>\n\nAcked-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n\nThanks,\nDscho\n"},{"id":"47911","messageId":"7vfy3k2an7.fsf@assigned-by-dhcp.cox.net","threadId":"9103","inReplyTo":"11848794193942-git-send-email-aroben@apple.com","subject":"Re: [PATCH] Print an error when falling back to vi on a dumb terminal","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-07-20T00:15:24Z","receivedAt":"2007-07-20T00:15:24Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Adam Roben <aroben@apple.com> writes:\n\n> Here you go. I'm not terribly happy with the error message, though. I tried to\n> be as clear as possible and to keep some of the nice information that was in\n> the git-commit error message. Please improve upon it if you can.\n>\n>  git-am.sh                  |    4 ++--\n>  git-commit.sh              |   11 +----------\n>  git-rebase--interactive.sh |    2 +-\n>  git-sh-setup.sh            |   15 +++++++++++++--\n>  git-tag.sh                 |    2 +-\n>  5 files changed, 18 insertions(+), 16 deletions(-)\n>\n> diff --git a/git-am.sh b/git-am.sh\n> index a5de0a1..dd517f4 100755\n> --- a/git-am.sh\n> +++ b/git-am.sh\n> @@ -7,7 +7,6 @@ USAGE='[--signoff] [--dotest=<dir>] [--utf8 | --no-utf8] [--binary] [--3way]\n>    or, when resuming [--skip | --resolved]'\n>  . git-sh-setup\n>  set_reflog_action am\n> -set_editor\n>  require_work_tree\n>  \n>  git var GIT_COMMITTER_IDENT >/dev/null || exit\n> @@ -365,7 +364,8 @@ do\n>  \t\t[yY]*) action=yes ;;\n>  \t\t[aA]*) action=yes interactive= ;;\n>  \t\t[nN]*) action=skip ;;\n> -\t\t[eE]*) \"$GIT_EDITOR\" \"$dotest/final-commit\"\n> +\t\t[eE]*) set_editor\n> +\t\t       \"$GIT_EDITOR\" \"$dotest/final-commit\"\n>  \t\t       action=again ;;\n>  \t\t[vV]*) action=again\n>  \t\t       LESS=-S ${PAGER:-less} \"$dotest/patch\" ;;\n\nSounds sane.\n\nCould you please re-diff to make this into a single patch\nwithout intermediate \"Oh, doing it this way is cleaner\", and\nalso with Dscho's Ack?  I do not think we would need to have 3\ncommits for this topic --- it is not like wide userbase tested\neach iteration.\n"},{"id":"47915","messageId":"11848913032579-git-send-email-aroben@apple.com","threadId":"9103","inReplyTo":"7vfy3k2an7.fsf@assigned-by-dhcp.cox.net","subject":"[PATCH] Add core.editor configuration variable","fromName":"Adam Roben","fromEmail":"aroben@apple.com","sentAt":"2007-07-20T00:28:23Z","receivedAt":"2007-07-20T00:28:23Z","isPatch":true,"sender":{"key":"aroben@apple.com","avatar":"https://gravatar.com/avatar/9d3697e1de53890adf241331f4b970bdd2b18962b2ff0b8028ebb00e085807f8?d=mp&s=160"},"body":"This variable lets you specify an editor that will be launched in preference to\nthe EDITOR and VISUAL environment variables.\n\nSigned-off-by: Adam Roben <aroben@apple.com>\nAcked-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n---\nOn Jul 19, 2007, at 5:15 PM, Junio C Hamano wrote:\n\n> Could you please re-diff to make this into a single patch\n> without intermediate \"Oh, doing it this way is cleaner\", and\n> also with Dscho's Ack?  I do not think we would need to have 3\n> commits for this topic --- it is not like wide userbase tested\n> each iteration.\n\n Documentation/git-commit.txt     |    9 +++++----\n Documentation/git-send-email.txt |    4 ++--\n git-am.sh                        |    3 ++-\n git-commit.sh                    |   12 ++----------\n git-rebase--interactive.sh       |    3 ++-\n git-send-email.perl              |    3 +--\n git-sh-setup.sh                  |   16 ++++++++++++++++\n git-tag.sh                       |    3 ++-\n 8 files changed, 32 insertions(+), 21 deletions(-)\n\ndiff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt\nindex f96142f..5caad56 100644\n--- a/Documentation/git-commit.txt\n+++ b/Documentation/git-commit.txt\n@@ -244,10 +244,11 @@ on the Subject: line and the rest of the commit in the body.\n \n include::i18n.txt[]\n \n-ENVIRONMENT VARIABLES\n----------------------\n-The command specified by either the VISUAL or EDITOR environment\n-variables is used to edit the commit log message.\n+ENVIRONMENT AND CONFIGURATION VARIABLES\n+---------------------------------------\n+The editor used to edit the commit log message will be chosen from the\n+core.editor configuration variable, the VISUAL environment variable, or the\n+EDITOR environment variable (in that order).\n \n HOOKS\n -----\ndiff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt\nindex 293686c..e7723c9 100644\n--- a/Documentation/git-send-email.txt\n+++ b/Documentation/git-send-email.txt\n@@ -44,8 +44,8 @@ The --cc option must be repeated for each user you want on the cc list.\n \tvalue; if that is unspecified, default to --chain-reply-to.\n \n --compose::\n-\tUse $EDITOR to edit an introductory message for the\n-\tpatch series.\n+\tUse core.editor, $VISUAL, or $EDITOR to edit an introductory message\n+\tfor the patch series.\n \n --from::\n \tSpecify the sender of the emails.  This will default to\ndiff --git a/git-am.sh b/git-am.sh\nindex e5e6f2c..dd517f4 100755\n--- a/git-am.sh\n+++ b/git-am.sh\n@@ -364,7 +364,8 @@ do\n \t\t[yY]*) action=yes ;;\n \t\t[aA]*) action=yes interactive= ;;\n \t\t[nN]*) action=skip ;;\n-\t\t[eE]*) \"${VISUAL:-${EDITOR:-vi}}\" \"$dotest/final-commit\"\n+\t\t[eE]*) set_editor\n+\t\t       \"$GIT_EDITOR\" \"$dotest/final-commit\"\n \t\t       action=again ;;\n \t\t[vV]*) action=again\n \t\t       LESS=-S ${PAGER:-less} \"$dotest/patch\" ;;\ndiff --git a/git-commit.sh b/git-commit.sh\nindex 3f3de17..4d5d898 100755\n--- a/git-commit.sh\n+++ b/git-commit.sh\n@@ -544,18 +544,10 @@ fi\n \n case \"$no_edit\" in\n '')\n-\tcase \"${VISUAL:-$EDITOR},$TERM\" in\n-\t,dumb)\n-\t\techo >&2 \"Terminal is dumb but no VISUAL nor EDITOR defined.\"\n-\t\techo >&2 \"Please supply the commit log message using either\"\n-\t\techo >&2 \"-m or -F option.  A boilerplate log message has\"\n-\t\techo >&2 \"been prepared in $GIT_DIR/COMMIT_EDITMSG\"\n-\t\texit 1\n-\t\t;;\n-\tesac\n+\tset_editor\n \tgit-var GIT_AUTHOR_IDENT > /dev/null  || die\n \tgit-var GIT_COMMITTER_IDENT > /dev/null  || die\n-\t${VISUAL:-${EDITOR:-vi}} \"$GIT_DIR/COMMIT_EDITMSG\"\n+\t$GIT_EDITOR \"$GIT_DIR/COMMIT_EDITMSG\"\n \t;;\n esac\n \ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex f395076..27f8639 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -414,7 +414,8 @@ EOF\n \t\t\tdie_abort \"Nothing to do\"\n \n \t\tcp \"$TODO\" \"$TODO\".backup\n-\t\t${VISUAL:-${EDITOR:-vi}} \"$TODO\" ||\n+\t\tset_editor\n+\t\t$GIT_EDITOR \"$TODO\" ||\n \t\t\tdie \"Could not execute editor\"\n \n \t\ttest -z \"$(grep -ve '^$' -e '^#' < $TODO)\" &&\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 7552cac..ad17b4e 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -341,8 +341,7 @@ GIT: for the patch you are writing.\n EOT\n \tclose(C);\n \n-\tmy $editor = $ENV{EDITOR};\n-\t$editor = 'vi' unless defined $editor;\n+\tmy $editor = $repo->config(\"core.editor\") || $ENV{VISUAL} || $ENV{EDITOR} || \"vi\";\n \tsystem($editor, $compose_filename);\n \n \topen(C2,\">\",$compose_filename . \".final\")\ndiff --git a/git-sh-setup.sh b/git-sh-setup.sh\nindex 4ed07e9..dbc4833 100755\n--- a/git-sh-setup.sh\n+++ b/git-sh-setup.sh\n@@ -28,6 +28,22 @@ set_reflog_action() {\n \tfi\n }\n \n+set_editor() {\n+\tGIT_EDITOR=$(git config core.editor || echo ${VISUAL:-${EDITOR}})\n+\tcase \"$GIT_EDITOR,$TERM\" in\n+\t,dumb)\n+\t\techo >&2 \"No editor specified in core.editor, VISUAL, or EDITOR.\"\n+\t\techo >&2 \"Tried to fall back to vi but terminal is dumb.\"\n+\t\techo >&2 \"Please set one of these variables to an appropriate\"\n+\t\techo >&2 \"editor or run $0 with options that will not cause an\"\n+\t\techo >&2 \"editor to be invoked (e.g., -m or -F for git-commit).\"\n+\t\texit 1\n+\t\t;;\n+\tesac\n+\tGIT_EDITOR=${GIT_EDITOR:-vi}\n+\texport GIT_EDITOR\n+}\n+\n is_bare_repository () {\n \tgit rev-parse --is-bare-repository\n }\ndiff --git a/git-tag.sh b/git-tag.sh\nindex 1c25d88..f1a66d0 100755\n--- a/git-tag.sh\n+++ b/git-tag.sh\n@@ -177,7 +177,8 @@ if [ \"$annotate\" ]; then\n         ( echo \"#\"\n           echo \"# Write a tag message\"\n           echo \"#\" ) > \"$GIT_DIR\"/TAG_EDITMSG\n-        ${VISUAL:-${EDITOR:-vi}} \"$GIT_DIR\"/TAG_EDITMSG || exit\n+        set_editor\n+        $GIT_EDITOR \"$GIT_DIR\"/TAG_EDITMSG || exit\n     else\n         printf '%s\\n' \"$message\" >\"$GIT_DIR\"/TAG_EDITMSG\n     fi\n-- \n1.5.3.rc2.21.gfc4a18-dirty\n"},{"id":"47925","messageId":"11849081753870-git-send-email-aroben@apple.com","threadId":"9103","inReplyTo":"11848913032579-git-send-email-aroben@apple.com","subject":"[PATCH] Add GIT_EDITOR environment variable and core.editor configuration variable","fromName":"Adam Roben","fromEmail":"aroben@apple.com","sentAt":"2007-07-20T05:09:35Z","receivedAt":"2007-07-20T05:09:35Z","isPatch":true,"sender":{"key":"aroben@apple.com","avatar":"https://gravatar.com/avatar/9d3697e1de53890adf241331f4b970bdd2b18962b2ff0b8028ebb00e085807f8?d=mp&s=160"},"body":"These variables let you specify an editor that will be launched in preference to\nthe EDITOR and VISUAL environment variables. The order of preference is\nGIT_EDITOR, core.editor, EDITOR, VISUAL.\n\nSigned-off-by: Adam Roben <aroben@apple.com>\n---\nThis patch obsoletes all the previous ones I've sent for this change.\n\nAfter discussing a bit with Junio and Shawn, this patch introduces\ngit-sh-setup::git_editor() to handle invoking the editor. It also respects the\nGIT_EDITOR environment variable for overriding the choice of editor.\n\nHopefully this is the last version of this patch :-)\n\n Documentation/git-commit.txt     |   10 ++++++----\n Documentation/git-send-email.txt |    4 ++--\n git-am.sh                        |    2 +-\n git-commit.sh                    |   11 +----------\n git-rebase--interactive.sh       |    2 +-\n git-send-email.perl              |    7 +++----\n git-sh-setup.sh                  |   15 +++++++++++++++\n git-tag.sh                       |    2 +-\n 8 files changed, 30 insertions(+), 23 deletions(-)\n\ndiff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt\nindex f96142f..8e0e7e2 100644\n--- a/Documentation/git-commit.txt\n+++ b/Documentation/git-commit.txt\n@@ -244,10 +244,12 @@ on the Subject: line and the rest of the commit in the body.\n \n include::i18n.txt[]\n \n-ENVIRONMENT VARIABLES\n----------------------\n-The command specified by either the VISUAL or EDITOR environment\n-variables is used to edit the commit log message.\n+ENVIRONMENT AND CONFIGURATION VARIABLES\n+---------------------------------------\n+The editor used to edit the commit log message will be chosen from the\n+GIT_EDITOR environment variable, the core.editor configuration variable, the\n+VISUAL environment variable, or the EDITOR environment variable (in that\n+order).\n \n HOOKS\n -----\ndiff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt\nindex 293686c..d243ed1 100644\n--- a/Documentation/git-send-email.txt\n+++ b/Documentation/git-send-email.txt\n@@ -44,8 +44,8 @@ The --cc option must be repeated for each user you want on the cc list.\n \tvalue; if that is unspecified, default to --chain-reply-to.\n \n --compose::\n-\tUse $EDITOR to edit an introductory message for the\n-\tpatch series.\n+\tUse $GIT_EDITOR, core.editor, $VISUAL, or $EDITOR to edit an\n+\tintroductory message for the patch series.\n \n --from::\n \tSpecify the sender of the emails.  This will default to\ndiff --git a/git-am.sh b/git-am.sh\nindex e5e6f2c..bfd65dc 100755\n--- a/git-am.sh\n+++ b/git-am.sh\n@@ -364,7 +364,7 @@ do\n \t\t[yY]*) action=yes ;;\n \t\t[aA]*) action=yes interactive= ;;\n \t\t[nN]*) action=skip ;;\n-\t\t[eE]*) \"${VISUAL:-${EDITOR:-vi}}\" \"$dotest/final-commit\"\n+\t\t[eE]*) git_editor \"$dotest/final-commit\"\n \t\t       action=again ;;\n \t\t[vV]*) action=again\n \t\t       LESS=-S ${PAGER:-less} \"$dotest/patch\" ;;\ndiff --git a/git-commit.sh b/git-commit.sh\nindex 3f3de17..92749df 100755\n--- a/git-commit.sh\n+++ b/git-commit.sh\n@@ -544,18 +544,9 @@ fi\n \n case \"$no_edit\" in\n '')\n-\tcase \"${VISUAL:-$EDITOR},$TERM\" in\n-\t,dumb)\n-\t\techo >&2 \"Terminal is dumb but no VISUAL nor EDITOR defined.\"\n-\t\techo >&2 \"Please supply the commit log message using either\"\n-\t\techo >&2 \"-m or -F option.  A boilerplate log message has\"\n-\t\techo >&2 \"been prepared in $GIT_DIR/COMMIT_EDITMSG\"\n-\t\texit 1\n-\t\t;;\n-\tesac\n \tgit-var GIT_AUTHOR_IDENT > /dev/null  || die\n \tgit-var GIT_COMMITTER_IDENT > /dev/null  || die\n-\t${VISUAL:-${EDITOR:-vi}} \"$GIT_DIR/COMMIT_EDITMSG\"\n+\tgit_editor \"$GIT_DIR/COMMIT_EDITMSG\"\n \t;;\n esac\n \ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex f395076..a2d4d09 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -414,7 +414,7 @@ EOF\n \t\t\tdie_abort \"Nothing to do\"\n \n \t\tcp \"$TODO\" \"$TODO\".backup\n-\t\t${VISUAL:-${EDITOR:-vi}} \"$TODO\" ||\n+\t\tgit_editor \"$TODO\" ||\n \t\t\tdie \"Could not execute editor\"\n \n \t\ttest -z \"$(grep -ve '^$' -e '^#' < $TODO)\" &&\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 7552cac..a09b1c9 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -49,8 +49,8 @@ Options:\n    --bcc          Specify a list of email addresses that should be Bcc:\n \t\t  on all the emails.\n \n-   --compose      Use \\$EDITOR to edit an introductory message for the\n-                  patch series.\n+   --compose      Use \\$GIT_EDITOR, core.editor, \\$EDITOR, or \\$VISUAL to edit\n+\t\t  an introductory message for the patch series.\n \n    --subject      Specify the initial \"Subject:\" line.\n                   Only necessary if --compose is also set.  If --compose\n@@ -341,8 +341,7 @@ GIT: for the patch you are writing.\n EOT\n \tclose(C);\n \n-\tmy $editor = $ENV{EDITOR};\n-\t$editor = 'vi' unless defined $editor;\n+\tmy $editor = $ENV{GIT_EDITOR} || $repo->config(\"core.editor\") || $ENV{VISUAL} || $ENV{EDITOR} || \"vi\";\n \tsystem($editor, $compose_filename);\n \n \topen(C2,\">\",$compose_filename . \".final\")\ndiff --git a/git-sh-setup.sh b/git-sh-setup.sh\nindex 4ed07e9..c51985e 100755\n--- a/git-sh-setup.sh\n+++ b/git-sh-setup.sh\n@@ -28,6 +28,21 @@ set_reflog_action() {\n \tfi\n }\n \n+git_editor() {\n+\tGIT_EDITOR=${GIT_EDITOR:-$(git config core.editor || echo ${VISUAL:-${EDITOR}})}\n+\tcase \"$GIT_EDITOR,$TERM\" in\n+\t,dumb)\n+\t\techo >&2 \"No editor specified in GIT_EDITOR, core.editor, VISUAL,\"\n+\t\techo >&2 \"or EDITOR. Tried to fall back to vi but terminal is dumb.\"\n+\t\techo >&2 \"Please set one of these variables to an appropriate\"\n+\t\techo >&2 \"editor or run $0 with options that will not cause an\"\n+\t\techo >&2 \"editor to be invoked (e.g., -m or -F for git-commit).\"\n+\t\texit 1\n+\t\t;;\n+\tesac\n+\t\"${GIT_EDITOR:-vi}\" \"$1\"\n+}\n+\n is_bare_repository () {\n \tgit rev-parse --is-bare-repository\n }\ndiff --git a/git-tag.sh b/git-tag.sh\nindex 1c25d88..5ee3f50 100755\n--- a/git-tag.sh\n+++ b/git-tag.sh\n@@ -177,7 +177,7 @@ if [ \"$annotate\" ]; then\n         ( echo \"#\"\n           echo \"# Write a tag message\"\n           echo \"#\" ) > \"$GIT_DIR\"/TAG_EDITMSG\n-        ${VISUAL:-${EDITOR:-vi}} \"$GIT_DIR\"/TAG_EDITMSG || exit\n+        git_editor \"$GIT_DIR\"/TAG_EDITMSG || exit\n     else\n         printf '%s\\n' \"$message\" >\"$GIT_DIR\"/TAG_EDITMSG\n     fi\n-- \n1.5.3.rc2.20.g2e098-dirty\n"}]}