rebase -i: Teach "--edit-todo" action
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>
Andrew Wong committed
Sep 17, 2012 at 21:28 UTC
eb9a7cb4bdbd4ea9c7e7ef2ca8de5b2753e3584c
3 files changed
+32
-3
Documentation/git-rebase.txt
+4
-1
@@ -12,7 +12,7 @@ SYNOPSIS
12
[<upstream>] [<branch>]
13
'git rebase' [-i | --interactive] [options] [--exec <cmd>] [--onto <newbase>]
14
--root [<branch>]
15
-'git rebase' --continue | --skip | --abort
15
+'git rebase' --continue | --skip | --abort | --edit-todo
16
17
DESCRIPTION
18
-----------
@@ -245,6 +245,9 @@ leave out at most one of A and B, in which case it defaults to HEAD.
245
--skip::
246
Restart the rebasing process by skipping the current patch.
247
248
+--edit-todo::
249
+ Edit the todo list during an interactive rebase.
250
+
251
-m::
252
--merge::
253
Use merging strategies to rebase. When the recursive (default) merge
git-rebase--interactive.sh
+17
@@ -792,6 +792,23 @@ skip)
792
793
do_rest
794
;;
795
+edit-todo)
796
+ sed -e '/^#/d' < "$todo" > "$todo".new
797
+ mv -f "$todo".new "$todo"
798
+ append_todo_help
799
+ cat >> "$todo" << EOF
800
+#
801
+# You are editing the todo file of an ongoing interactive rebase.
802
+# To continue rebase after editing, run:
803
+# git rebase --continue
804
+#
805
+EOF
806
+
807
+ git_sequence_editor "$todo" ||
808
+ die "Could not execute editor"
809
+
810
+ exit
811
+ ;;
812
esac
813
814
git var GIT_COMMITTER_IDENT >/dev/null ||
git-rebase.sh
+11
-2
@@ -8,7 +8,7 @@ OPTIONS_KEEPDASHDASH=
8
OPTIONS_SPEC="\
9
git rebase [-i] [options] [--exec <cmd>] [--onto <newbase>] [<upstream>] [<branch>]
10
git rebase [-i] [options] [--exec <cmd>] [--onto <newbase>] --root [<branch>]
11
-git-rebase --continue | --abort | --skip
11
+git-rebase --continue | --abort | --skip | --edit-todo
12
--
13
Available options are
14
v,verbose! display a diffstat of what changed upstream
@@ -38,6 +38,7 @@ C=! passed to 'git apply'
38
continue! continue
39
abort! abort and check out the original branch
40
skip! skip current patch and continue
41
+edit-todo! edit the todo list during an interactive rebase
42
"
43
. git-sh-setup
44
. git-sh-i18n
@@ -190,7 +191,7 @@ do
191
--verify)
192
ok_to_skip_pre_rebase=
193
;;
193
- --continue|--skip|--abort)
194
+ --continue|--skip|--abort|--edit-todo)
195
test $total_argc -eq 2 || usage
196
action=${1##--}
197
;;
@@ -306,6 +307,11 @@ then
307
fi
308
fi
309
310
+if test "$action" = "edit-todo" && test "$type" != "interactive"
311
+then
312
+ die "$(gettext "The --edit-todo action can only be used during interactive rebase.")"
313
+fi
314
+
315
case "$action" in
316
continue)
317
# Sanity check
@@ -338,6 +344,9 @@ abort)
344
rm -r "$state_dir"
345
exit
346
;;
347
+edit-todo)
348
+ run_specific_rebase
349
+ ;;
350
esac
351
352
# Make sure no rebase is in progress