Skip to content

Commit 821881d

Browse files
kumbayogitster
authored andcommitted
"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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2c46103 commit 821881d

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

Documentation/config.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,12 @@ core.editor::
473473
variable when it is set, and the environment variable
474474
`GIT_EDITOR` is not set. See linkgit:git-var[1].
475475

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+
476482
core.pager::
477483
The command that git will use to paginate output. Can
478484
be overridden with the `GIT_PAGER` environment

git-rebase--interactive.sh

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,19 @@ do_with_author () {
161161
)
162162
}
163163

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+
164177
pick_one () {
165178
ff=--ff
166179
case "$1" in -n) sha1=$2; ff= ;; *) sha1=$1 ;; esac
@@ -832,7 +845,7 @@ has_action "$todo" ||
832845
die_abort "Nothing to do"
833846

834847
cp "$todo" "$todo".backup
835-
git_editor "$todo" ||
848+
git_sequence_editor "$todo" ||
836849
die_abort "Could not execute editor"
837850

838851
has_action "$todo" ||

0 commit comments

Comments
 (0)