Merge branch 'aw/rebase-i-edit-todo'
Teach an option to edit the insn sheet to "git rebase -i". * aw/rebase-i-edit-todo: rebase -i: suggest using --edit-todo to fix an unknown instruction rebase -i: Add tests for "--edit-todo" rebase -i: Teach "--edit-todo" action rebase -i: Refactor help messages for todo file rebase usage: subcommands can not be combined with -i
This commit is contained in:
@ -12,7 +12,7 @@ SYNOPSIS
|
|||||||
[<upstream>] [<branch>]
|
[<upstream>] [<branch>]
|
||||||
'git rebase' [-i | --interactive] [options] [--exec <cmd>] [--onto <newbase>]
|
'git rebase' [-i | --interactive] [options] [--exec <cmd>] [--onto <newbase>]
|
||||||
--root [<branch>]
|
--root [<branch>]
|
||||||
'git rebase' --continue | --skip | --abort
|
'git rebase' --continue | --skip | --abort | --edit-todo
|
||||||
|
|
||||||
DESCRIPTION
|
DESCRIPTION
|
||||||
-----------
|
-----------
|
||||||
@ -245,6 +245,9 @@ leave out at most one of A and B, in which case it defaults to HEAD.
|
|||||||
--skip::
|
--skip::
|
||||||
Restart the rebasing process by skipping the current patch.
|
Restart the rebasing process by skipping the current patch.
|
||||||
|
|
||||||
|
--edit-todo::
|
||||||
|
Edit the todo list during an interactive rebase.
|
||||||
|
|
||||||
-m::
|
-m::
|
||||||
--merge::
|
--merge::
|
||||||
Use merging strategies to rebase. When the recursive (default) merge
|
Use merging strategies to rebase. When the recursive (default) merge
|
||||||
|
@ -115,6 +115,23 @@ mark_action_done () {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
append_todo_help () {
|
||||||
|
cat >> "$todo" << EOF
|
||||||
|
#
|
||||||
|
# Commands:
|
||||||
|
# p, pick = use commit
|
||||||
|
# r, reword = use commit, but edit the commit message
|
||||||
|
# e, edit = use commit, but stop for amending
|
||||||
|
# s, squash = use commit, but meld into previous commit
|
||||||
|
# f, fixup = like "squash", but discard this commit's log message
|
||||||
|
# x, exec = run command (the rest of the line) using shell
|
||||||
|
#
|
||||||
|
# These lines can be re-ordered; they are executed from top to bottom.
|
||||||
|
#
|
||||||
|
# If you remove a line here THAT COMMIT WILL BE LOST.
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
make_patch () {
|
make_patch () {
|
||||||
sha1_and_parents="$(git rev-list --parents -1 "$1")"
|
sha1_and_parents="$(git rev-list --parents -1 "$1")"
|
||||||
case "$sha1_and_parents" in
|
case "$sha1_and_parents" in
|
||||||
@ -562,11 +579,12 @@ do_next () {
|
|||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
warn "Unknown command: $command $sha1 $rest"
|
warn "Unknown command: $command $sha1 $rest"
|
||||||
|
fixtodo="Please fix this using 'git rebase --edit-todo'."
|
||||||
if git rev-parse --verify -q "$sha1" >/dev/null
|
if git rev-parse --verify -q "$sha1" >/dev/null
|
||||||
then
|
then
|
||||||
die_with_patch $sha1 "Please fix this in the file $todo."
|
die_with_patch $sha1 "$fixtodo"
|
||||||
else
|
else
|
||||||
die "Please fix this in the file $todo."
|
die "$fixtodo"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@ -779,6 +797,23 @@ skip)
|
|||||||
|
|
||||||
do_rest
|
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
|
esac
|
||||||
|
|
||||||
git var GIT_COMMITTER_IDENT >/dev/null ||
|
git var GIT_COMMITTER_IDENT >/dev/null ||
|
||||||
@ -905,18 +940,10 @@ test -n "$cmd" && add_exec_commands "$todo"
|
|||||||
cat >> "$todo" << EOF
|
cat >> "$todo" << EOF
|
||||||
|
|
||||||
# Rebase $shortrevisions onto $shortonto
|
# Rebase $shortrevisions onto $shortonto
|
||||||
|
EOF
|
||||||
|
append_todo_help
|
||||||
|
cat >> "$todo" << EOF
|
||||||
#
|
#
|
||||||
# Commands:
|
|
||||||
# p, pick = use commit
|
|
||||||
# r, reword = use commit, but edit the commit message
|
|
||||||
# e, edit = use commit, but stop for amending
|
|
||||||
# s, squash = use commit, but meld into previous commit
|
|
||||||
# f, fixup = like "squash", but discard this commit's log message
|
|
||||||
# x, exec = run command (the rest of the line) using shell
|
|
||||||
#
|
|
||||||
# These lines can be re-ordered; they are executed from top to bottom.
|
|
||||||
#
|
|
||||||
# If you remove a line here THAT COMMIT WILL BE LOST.
|
|
||||||
# However, if you remove everything, the rebase will be aborted.
|
# However, if you remove everything, the rebase will be aborted.
|
||||||
#
|
#
|
||||||
EOF
|
EOF
|
||||||
|
@ -8,7 +8,7 @@ OPTIONS_KEEPDASHDASH=
|
|||||||
OPTIONS_SPEC="\
|
OPTIONS_SPEC="\
|
||||||
git rebase [-i] [options] [--exec <cmd>] [--onto <newbase>] [<upstream>] [<branch>]
|
git rebase [-i] [options] [--exec <cmd>] [--onto <newbase>] [<upstream>] [<branch>]
|
||||||
git rebase [-i] [options] [--exec <cmd>] [--onto <newbase>] --root [<branch>]
|
git rebase [-i] [options] [--exec <cmd>] [--onto <newbase>] --root [<branch>]
|
||||||
git-rebase [-i] --continue | --abort | --skip
|
git-rebase --continue | --abort | --skip | --edit-todo
|
||||||
--
|
--
|
||||||
Available options are
|
Available options are
|
||||||
v,verbose! display a diffstat of what changed upstream
|
v,verbose! display a diffstat of what changed upstream
|
||||||
@ -38,6 +38,7 @@ C=! passed to 'git apply'
|
|||||||
continue! continue
|
continue! continue
|
||||||
abort! abort and check out the original branch
|
abort! abort and check out the original branch
|
||||||
skip! skip current patch and continue
|
skip! skip current patch and continue
|
||||||
|
edit-todo! edit the todo list during an interactive rebase
|
||||||
"
|
"
|
||||||
. git-sh-setup
|
. git-sh-setup
|
||||||
. git-sh-i18n
|
. git-sh-i18n
|
||||||
@ -190,7 +191,7 @@ do
|
|||||||
--verify)
|
--verify)
|
||||||
ok_to_skip_pre_rebase=
|
ok_to_skip_pre_rebase=
|
||||||
;;
|
;;
|
||||||
--continue|--skip|--abort)
|
--continue|--skip|--abort|--edit-todo)
|
||||||
test $total_argc -eq 2 || usage
|
test $total_argc -eq 2 || usage
|
||||||
action=${1##--}
|
action=${1##--}
|
||||||
;;
|
;;
|
||||||
@ -306,6 +307,11 @@ then
|
|||||||
fi
|
fi
|
||||||
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
|
case "$action" in
|
||||||
continue)
|
continue)
|
||||||
# Sanity check
|
# Sanity check
|
||||||
@ -338,6 +344,9 @@ abort)
|
|||||||
rm -r "$state_dir"
|
rm -r "$state_dir"
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
|
edit-todo)
|
||||||
|
run_specific_rebase
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Make sure no rebase is in progress
|
# Make sure no rebase is in progress
|
||||||
|
@ -922,4 +922,22 @@ test_expect_success 'rebase -i --root fixup root commit' '
|
|||||||
test 0 = $(git cat-file commit HEAD | grep -c ^parent\ )
|
test 0 = $(git cat-file commit HEAD | grep -c ^parent\ )
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'rebase --edit-todo does not works on non-interactive rebase' '
|
||||||
|
git reset --hard &&
|
||||||
|
git checkout conflict-branch &&
|
||||||
|
test_must_fail git rebase --onto HEAD~2 HEAD~ &&
|
||||||
|
test_must_fail git rebase --edit-todo &&
|
||||||
|
git rebase --abort
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'rebase --edit-todo can be used to modify todo' '
|
||||||
|
git reset --hard &&
|
||||||
|
git checkout no-conflict-branch^0 &&
|
||||||
|
FAKE_LINES="edit 1 2 3" git rebase -i HEAD~3 &&
|
||||||
|
FAKE_LINES="2 1" git rebase --edit-todo &&
|
||||||
|
git rebase --continue
|
||||||
|
test M = $(git cat-file commit HEAD^ | sed -ne \$p) &&
|
||||||
|
test L = $(git cat-file commit HEAD | sed -ne \$p)
|
||||||
|
'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
Reference in New Issue
Block a user