Skip to content

Commit

Permalink
"rebase -i": support special-purpose editor to edit insn sheet
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
kumbayo authored and gitster committed Oct 17, 2011
1 parent 2c46103 commit 821881d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
6 changes: 6 additions & 0 deletions Documentation/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,12 @@ core.editor::
variable when it is set, and the environment variable
`GIT_EDITOR` is not set. See linkgit:git-var[1].

sequence.editor::
Text editor used by `git rebase -i` for editing the rebase insn file.
The value is meant to be interpreted by the shell when it is used.
It can be overridden by the `GIT_SEQUENCE_EDITOR` environment variable.
When not configured the default commit message editor is used instead.

core.pager::
The command that git will use to paginate output. Can
be overridden with the `GIT_PAGER` environment
Expand Down
15 changes: 14 additions & 1 deletion git-rebase--interactive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,19 @@ do_with_author () {
)
}

git_sequence_editor () {
if test -z "$GIT_SEQUENCE_EDITOR"
then
GIT_SEQUENCE_EDITOR="$(git config sequence.editor)"
if [ -z "$GIT_SEQUENCE_EDITOR" ]
then
GIT_SEQUENCE_EDITOR="$(git var GIT_EDITOR)" || return $?
fi
fi

eval "$GIT_SEQUENCE_EDITOR" '"$@"'
}

pick_one () {
ff=--ff
case "$1" in -n) sha1=$2; ff= ;; *) sha1=$1 ;; esac
Expand Down Expand Up @@ -832,7 +845,7 @@ has_action "$todo" ||
die_abort "Nothing to do"

cp "$todo" "$todo".backup
git_editor "$todo" ||
git_sequence_editor "$todo" ||
die_abort "Could not execute editor"

has_action "$todo" ||
Expand Down

0 comments on commit 821881d

Please sign in to comment.