{"thread":{"id":"28704","subject":"[PATCH] Allow to specify the editor used for git rebase -i by config/environment var","startedAt":"2011-10-17T20:26:23Z","lastAt":"2011-10-17T21:36:27Z","messageCount":2,"participants":["Peter Oberndorfer","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"177886","messageId":"57346812.Rh0UlzroDp@soybean","threadId":"28704","inReplyTo":null,"subject":"[PATCH] Allow to specify the editor used for git rebase -i by config/environment var","fromName":"Peter Oberndorfer","fromEmail":"kumbayo84@arcor.de","sentAt":"2011-10-17T20:26:23Z","receivedAt":"2011-10-17T20:26:23Z","isPatch":true,"sender":{"key":"kumbayo84@arcor.de","avatar":"https://avatars.githubusercontent.com/u/1041267?v=4"},"body":"The search order for choosing the sequence editor is:\n$GIT_SEQUENCE_EDITOR\ngit config sequence.editor\ngit var GIT_EDITOR (default editor for commit messages)\n\nWith this change is it possible to have a separate\n(possibly graphical) editor that helps the user\nduring a interactive rebase.\n\nUsing $GIT_EDITOR or core.editor config var for this is not possible\nsince they is also used to start the commit message editor for reword action.\n\nSigned-off-by: Peter Oberndorfer <kumbayo84@arcor.de>\n---\nI reworded the commit message and the config description a bit.\nrenamed to sequence.editor / $GIT_SEQUENCE_EDITOR\nand moved the helper to git-rebase--interactive.sh\n\n Documentation/config.txt   |    7 +++++++\n git-rebase--interactive.sh |   15 ++++++++++++++-\n 2 files changed, 21 insertions(+), 1 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 03296b7..048c5f9 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -473,6 +473,13 @@ core.editor::\n \tvariable when it is set, and the environment variable\n \t`GIT_EDITOR` is not set.  See linkgit:git-var[1].\n \n+sequence.editor::\n+\tText editor used by git rebase -i for editing the rebase todo file.\n+\tThe value is meant to be interpreted by the shell when it is used.\n+\tIt can be overridden by the 'GIT_SEQUENCE_EDITOR' environment variable.\n+\tWhen not configured the default commit message editor is used instead.\n+\tSee linkgit:git-var[1]\n+\n core.pager::\n \tThe command that git will use to paginate output.  Can\n \tbe overridden with the `GIT_PAGER` environment\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 94f36c2..13a0661 100644\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -161,6 +161,19 @@ do_with_author () {\n \t)\n }\n \n+git_sequence_editor() {\n+\tif test -z \"${GIT_SEQUENCE_EDITOR:+set}\"\n+\tthen\n+\t\tGIT_SEQUENCE_EDITOR=\"$(git config sequence.editor)\"\n+\t\tif [ -z \"$GIT_SEQUENCE_EDITOR\" ]\n+\t\tthen\n+\t\t\tGIT_SEQUENCE_EDITOR=\"$(git var GIT_EDITOR)\" || return $?\n+\t\tfi\n+\tfi\n+\n+\teval \"$GIT_SEQUENCE_EDITOR\" '\"$@\"'\n+}\n+\n pick_one () {\n \tff=--ff\n \tcase \"$1\" in -n) sha1=$2; ff= ;; *) sha1=$1 ;; esac\n@@ -832,7 +845,7 @@ has_action \"$todo\" ||\n \tdie_abort \"Nothing to do\"\n \n cp \"$todo\" \"$todo\".backup\n-git_editor \"$todo\" ||\n+git_sequence_editor \"$todo\" ||\n \tdie_abort \"Could not execute editor\"\n \n has_action \"$todo\" ||\n-- \n1.7.7.329.g2140c\n"},{"id":"177893","messageId":"7v1uubl2qs.fsf@alter.siamese.dyndns.org","threadId":"28704","inReplyTo":"57346812.Rh0UlzroDp@soybean","subject":"Re: [PATCH] Allow to specify the editor used for git rebase -i by config/environment var","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-10-17T21:36:27Z","receivedAt":"2011-10-17T21:36:27Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Peter Oberndorfer <kumbayo84@arcor.de> writes:\n\n> The search order for choosing the sequence editor is:\n> $GIT_SEQUENCE_EDITOR\n> git config sequence.editor\n> git var GIT_EDITOR (default editor for commit messages)\n>\n> With this change is it possible to have a separate\n> (possibly graphical) editor that helps the user\n> during a interactive rebase.\n>\n> Using $GIT_EDITOR or core.editor config var for this is not possible\n> since they is also used to start the commit message editor for reword action.\n\nThanks. I'll reword the proposed commit log message before queuing,\nbecause it won't make _any_ sense to talk about the search order before\ntelling what these things that are searched would do, or why they are\nuseful things to have.\n\n    \"rebase -i\": support special-purpose editor to edit insn sheet\n\n    The insn sheet used by \"rebase -i\" is designed to be easily editable by\n    any text editor, but an editor that is specifically meant for it (but\n    is otherwise unsuitable for editing regular text files) could be useful\n    by allowing drag & drop reordering in a GUI environment, for example.\n\n    The GIT_SEQUENCE_EDITOR environment variable and/or the sequence.editor\n    configuration variable can be used to specify such an editor, while\n    allowing the usual editor to be used to edit commit log messages. As\n    usual, the environment variable takes precedence over the configuration\n    variable.\n\n    It is envisioned that other \"sequencer\" based tools will use the same\n    mechanism.\n\n    Signed-off-by: Peter Oberndorfer <kumbayo84@arcor.de>\n    Signed-off-by: Junio C Hamano <gitster@pobox.com>\n"}]}