Skip to content

Commit

Permalink
rebase -i: Teach "--edit-todo" action
Browse files Browse the repository at this point in the history
This allows users to edit the todo file while they're stopped in the
middle of an interactive rebase. When this action is executed, all
comments from the original todo file are stripped, and new help messages
are appended to the end.

Signed-off-by: Andrew Wong <andrew.kw.w@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Andrew Wong authored and Junio C Hamano committed Sep 18, 2012
1 parent fcc5ef1 commit eb9a7cb
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
5 changes: 4 additions & 1 deletion Documentation/git-rebase.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ SYNOPSIS
[<upstream>] [<branch>]
'git rebase' [-i | --interactive] [options] [--exec <cmd>] [--onto <newbase>]
--root [<branch>]
'git rebase' --continue | --skip | --abort
'git rebase' --continue | --skip | --abort | --edit-todo

DESCRIPTION
-----------
Expand Down Expand Up @@ -245,6 +245,9 @@ leave out at most one of A and B, in which case it defaults to HEAD.
--skip::
Restart the rebasing process by skipping the current patch.

--edit-todo::
Edit the todo list during an interactive rebase.

-m::
--merge::
Use merging strategies to rebase. When the recursive (default) merge
Expand Down
17 changes: 17 additions & 0 deletions git-rebase--interactive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,23 @@ skip)

do_rest
;;
edit-todo)
sed -e '/^#/d' < "$todo" > "$todo".new
mv -f "$todo".new "$todo"
append_todo_help
cat >> "$todo" << EOF
#
# You are editing the todo file of an ongoing interactive rebase.
# To continue rebase after editing, run:
# git rebase --continue
#
EOF

git_sequence_editor "$todo" ||
die "Could not execute editor"

exit
;;
esac

git var GIT_COMMITTER_IDENT >/dev/null ||
Expand Down
13 changes: 11 additions & 2 deletions git-rebase.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ OPTIONS_KEEPDASHDASH=
OPTIONS_SPEC="\
git rebase [-i] [options] [--exec <cmd>] [--onto <newbase>] [<upstream>] [<branch>]
git rebase [-i] [options] [--exec <cmd>] [--onto <newbase>] --root [<branch>]
git-rebase --continue | --abort | --skip
git-rebase --continue | --abort | --skip | --edit-todo
--
Available options are
v,verbose! display a diffstat of what changed upstream
Expand Down Expand Up @@ -38,6 +38,7 @@ C=! passed to 'git apply'
continue! continue
abort! abort and check out the original branch
skip! skip current patch and continue
edit-todo! edit the todo list during an interactive rebase
"
. git-sh-setup
. git-sh-i18n
Expand Down Expand Up @@ -190,7 +191,7 @@ do
--verify)
ok_to_skip_pre_rebase=
;;
--continue|--skip|--abort)
--continue|--skip|--abort|--edit-todo)
test $total_argc -eq 2 || usage
action=${1##--}
;;
Expand Down Expand Up @@ -306,6 +307,11 @@ then
fi
fi

if test "$action" = "edit-todo" && test "$type" != "interactive"
then
die "$(gettext "The --edit-todo action can only be used during interactive rebase.")"
fi

case "$action" in
continue)
# Sanity check
Expand Down Expand Up @@ -338,6 +344,9 @@ abort)
rm -r "$state_dir"
exit
;;
edit-todo)
run_specific_rebase
;;
esac

# Make sure no rebase is in progress
Expand Down

0 comments on commit eb9a7cb

Please sign in to comment.