diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2016-11-12 09:00:41 +0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-12-11 13:51:41 -0800 |
commit | 9512177b68263085fef84cdbd45ecdee7bfe2377 (patch) | |
tree | 669bb556ed96ba389a0f7c3bfe83d663bf21ee96 /t/t3407-rebase-abort.sh | |
parent | 0b65a8dbdb38962e700ee16776a3042beb489060 (diff) | |
download | git-9512177b68263085fef84cdbd45ecdee7bfe2377.tar.gz git-9512177b68263085fef84cdbd45ecdee7bfe2377.tar.xz |
rebase: add --quit to cleanup rebase, leave everything else untouched
There are occasions when you decide to abort an in-progress rebase and
move on to do something else but you forget to do "git rebase --abort"
first. Or the rebase has been in progress for so long you forgot about
it. By the time you realize that (e.g. by starting another rebase)
it's already too late to retrace your steps. The solution is normally
rm -r .git/<some rebase dir>
and continue with your life. But there could be two different
directories for <some rebase dir> (and it obviously requires some
knowledge of how rebase works), and the ".git" part could be much
longer if you are not at top-dir, or in a linked worktree. And
"rm -r" is very dangerous to do in .git, a mistake in there could
destroy object database or other important data.
Provide "git rebase --quit" for this use case, mimicking a precedent
that is "git cherry-pick --quit".
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t3407-rebase-abort.sh')
-rwxr-xr-x | t/t3407-rebase-abort.sh | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/t/t3407-rebase-abort.sh b/t/t3407-rebase-abort.sh index a6a6c40a9..910f21828 100755 --- a/t/t3407-rebase-abort.sh +++ b/t/t3407-rebase-abort.sh @@ -99,4 +99,28 @@ testrebase() { testrebase "" .git/rebase-apply 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 |