"rebase -i": support special-purpose editor to edit insn sheet

The insn sheet used by "rebase -i" is designed to be easily editable by any text editor, but an editor that is specifically meant for it (but is otherwise unsuitable for editing regular text files) could be useful by allowing drag & drop reordering in a GUI environment, for example. The GIT_SEQUENCE_EDITOR environment variable and/or the sequence.editor configuration variable can be used to specify such an editor, while allowing the usual editor to be used to edit commit log messages. As usual, the environment variable takes precedence over the configuration variable. It is envisioned that other "sequencer" based tools will use the same mechanism. Signed-off-by: Peter Oberndorfer <kumbayo84@arcor.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Peter Oberndorfer committed Oct 17, 2011 at 22:26 UTC 821881d88d3012a64a52ece9a8c2571ca00c35cd
2 files changed +20 -1
Documentation/config.txt
+6
@@ -473,6 +473,12 @@ core.editor::
473 variable when it is set, and the environment variable
474 `GIT_EDITOR` is not set. See linkgit:git-var[1].
475
476 +sequence.editor::
477 + Text editor used by `git rebase -i` for editing the rebase insn file.
478 + The value is meant to be interpreted by the shell when it is used.
479 + It can be overridden by the `GIT_SEQUENCE_EDITOR` environment variable.
480 + When not configured the default commit message editor is used instead.
481 +
482 core.pager::
483 The command that git will use to paginate output. Can
484 be overridden with the `GIT_PAGER` environment
git-rebase--interactive.sh
+14 -1
@@ -161,6 +161,19 @@ do_with_author () {
161 )
162 }
163
164 +git_sequence_editor () {
165 + if test -z "$GIT_SEQUENCE_EDITOR"
166 + then
167 + GIT_SEQUENCE_EDITOR="$(git config sequence.editor)"
168 + if [ -z "$GIT_SEQUENCE_EDITOR" ]
169 + then
170 + GIT_SEQUENCE_EDITOR="$(git var GIT_EDITOR)" || return $?
171 + fi
172 + fi
173 +
174 + eval "$GIT_SEQUENCE_EDITOR" '"$@"'
175 +}
176 +
177 pick_one () {
178 ff=--ff
179 case "$1" in -n) sha1=$2; ff= ;; *) sha1=$1 ;; esac
@@ -832,7 +845,7 @@ has_action "$todo" ||
845 die_abort "Nothing to do"
846
847 cp "$todo" "$todo".backup
835 -git_editor "$todo" ||
848 +git_sequence_editor "$todo" ||
849 die_abort "Could not execute editor"
850
851 has_action "$todo" ||