提交 06cd5a1e 编写于 作者: J Junio C Hamano

Merge branch 'nd/rebase-forget'

"git rebase" learned "--quit" option, which allows a user to
remove the metadata left by an earlier "git rebase" that was
manually aborted without using "git rebase --abort".

* nd/rebase-forget:
  rebase: add --quit to cleanup rebase, leave everything else untouched
...@@ -12,7 +12,7 @@ SYNOPSIS ...@@ -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 | --edit-todo 'git rebase' --continue | --skip | --abort | --quit | --edit-todo
DESCRIPTION DESCRIPTION
----------- -----------
...@@ -252,6 +252,11 @@ leave out at most one of A and B, in which case it defaults to HEAD. ...@@ -252,6 +252,11 @@ leave out at most one of A and B, in which case it defaults to HEAD.
will be reset to where it was when the rebase operation was will be reset to where it was when the rebase operation was
started. started.
--quit::
Abort the rebase operation but HEAD is not reset back to the
original branch. The index and working tree are also left
unchanged as a result.
--keep-empty:: --keep-empty::
Keep the commits that do not change anything from its Keep the commits that do not change anything from its
parents in the result. parents in the result.
......
...@@ -1734,10 +1734,10 @@ _git_rebase () ...@@ -1734,10 +1734,10 @@ _git_rebase ()
{ {
local dir="$(__gitdir)" local dir="$(__gitdir)"
if [ -f "$dir"/rebase-merge/interactive ]; then if [ -f "$dir"/rebase-merge/interactive ]; then
__gitcomp "--continue --skip --abort --edit-todo" __gitcomp "--continue --skip --abort --quit --edit-todo"
return return
elif [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then elif [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then
__gitcomp "--continue --skip --abort" __gitcomp "--continue --skip --abort --quit"
return return
fi fi
__git_complete_strategy && return __git_complete_strategy && return
......
...@@ -43,6 +43,7 @@ continue! continue ...@@ -43,6 +43,7 @@ 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 edit-todo! edit the todo list during an interactive rebase
quit! abort but keep HEAD where it is
" "
. git-sh-setup . git-sh-setup
set_reflog_action rebase set_reflog_action rebase
...@@ -241,7 +242,7 @@ do ...@@ -241,7 +242,7 @@ do
--verify) --verify)
ok_to_skip_pre_rebase= ok_to_skip_pre_rebase=
;; ;;
--continue|--skip|--abort|--edit-todo) --continue|--skip|--abort|--quit|--edit-todo)
test $total_argc -eq 2 || usage test $total_argc -eq 2 || usage
action=${1##--} action=${1##--}
;; ;;
...@@ -399,6 +400,9 @@ abort) ...@@ -399,6 +400,9 @@ abort)
finish_rebase finish_rebase
exit exit
;; ;;
quit)
exec rm -rf "$state_dir"
;;
edit-todo) edit-todo)
run_specific_rebase run_specific_rebase
;; ;;
......
...@@ -99,4 +99,28 @@ testrebase() { ...@@ -99,4 +99,28 @@ testrebase() {
testrebase "" .git/rebase-apply testrebase "" .git/rebase-apply
testrebase " --merge" .git/rebase-merge testrebase " --merge" .git/rebase-merge
test_expect_success 'rebase --quit' '
cd "$work_dir" &&
# Clean up the state from the previous one
git reset --hard pre-rebase &&
test_must_fail git rebase master &&
test_path_is_dir .git/rebase-apply &&
head_before=$(git rev-parse HEAD) &&
git rebase --quit &&
test $(git rev-parse HEAD) = $head_before &&
test ! -d .git/rebase-apply
'
test_expect_success 'rebase --merge --quit' '
cd "$work_dir" &&
# Clean up the state from the previous one
git reset --hard pre-rebase &&
test_must_fail git rebase --merge master &&
test_path_is_dir .git/rebase-merge &&
head_before=$(git rev-parse HEAD) &&
git rebase --quit &&
test $(git rev-parse HEAD) = $head_before &&
test ! -d .git/rebase-merge
'
test_done test_done
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册