* [PATCH] rebase: add --forget to cleanup rebase, leave HEAD untouched
@ 2016-10-26 9:46 Nguyễn Thái Ngọc Duy
2016-10-26 16:51 ` Junio C Hamano
2016-11-09 9:11 ` [PATCH v2] rebase: add --forget to cleanup rebase, leave everything else untouched Nguyễn Thái Ngọc Duy
0 siblings, 2 replies; 10+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-10-26 9:46 UTC (permalink / raw)
To: git; +Cc: Nguyễn Thái Ngọc Duy
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 --forget" for this exact use case.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
Documentation/git-rebase.txt | 5 ++++-
contrib/completion/git-completion.bash | 4 ++--
git-rebase.sh | 6 +++++-
t/t3407-rebase-abort.sh | 24 ++++++++++++++++++++++++
4 files changed, 35 insertions(+), 4 deletions(-)
diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt
index de222c8..5a58fb3 100644
--- a/Documentation/git-rebase.txt
+++ b/Documentation/git-rebase.txt
@@ -12,7 +12,7 @@ SYNOPSIS
[<upstream> [<branch>]]
'git rebase' [-i | --interactive] [options] [--exec <cmd>] [--onto <newbase>]
--root [<branch>]
-'git rebase' --continue | --skip | --abort | --edit-todo
+'git rebase' --continue | --skip | --abort | --forget | --edit-todo
DESCRIPTION
-----------
@@ -252,6 +252,9 @@ 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
started.
+--forget::
+ Abort the rebase operation but leave HEAD where it is.
+
--keep-empty::
Keep the commits that do not change anything from its
parents in the result.
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 9c8f738..bb64fb4 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1733,10 +1733,10 @@ _git_rebase ()
{
local dir="$(__gitdir)"
if [ -f "$dir"/rebase-merge/interactive ]; then
- __gitcomp "--continue --skip --abort --edit-todo"
+ __gitcomp "--continue --skip --abort --forget --edit-todo"
return
elif [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then
- __gitcomp "--continue --skip --abort"
+ __gitcomp "--continue --skip --abort --forget"
return
fi
__git_complete_strategy && return
diff --git a/git-rebase.sh b/git-rebase.sh
index 04f6e44..de712b7 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -43,6 +43,7 @@ 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
+forget! abort but keep HEAD where it is
"
. git-sh-setup
set_reflog_action rebase
@@ -241,7 +242,7 @@ do
--verify)
ok_to_skip_pre_rebase=
;;
- --continue|--skip|--abort|--edit-todo)
+ --continue|--skip|--abort|--forget|--edit-todo)
test $total_argc -eq 2 || usage
action=${1##--}
;;
@@ -399,6 +400,9 @@ abort)
finish_rebase
exit
;;
+forget)
+ exec rm -rf "$state_dir"
+ ;;
edit-todo)
run_specific_rebase
;;
diff --git a/t/t3407-rebase-abort.sh b/t/t3407-rebase-abort.sh
index a6a6c40..6bc5e71 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 --forget' '
+ 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 --forget &&
+ test $(git rev-parse HEAD) = $head_before &&
+ test ! -d .git/rebase-apply
+'
+
+test_expect_success 'rebase --merge --forget' '
+ 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 --forget &&
+ test $(git rev-parse HEAD) = $head_before &&
+ test ! -d .git/rebase-merge
+'
+
test_done
--
2.8.2.524.g6ff3d78
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] rebase: add --forget to cleanup rebase, leave HEAD untouched
2016-10-26 9:46 [PATCH] rebase: add --forget to cleanup rebase, leave HEAD untouched Nguyễn Thái Ngọc Duy
@ 2016-10-26 16:51 ` Junio C Hamano
2016-10-27 10:40 ` Duy Nguyen
2016-11-09 9:11 ` [PATCH v2] rebase: add --forget to cleanup rebase, leave everything else untouched Nguyễn Thái Ngọc Duy
1 sibling, 1 reply; 10+ messages in thread
From: Junio C Hamano @ 2016-10-26 16:51 UTC (permalink / raw)
To: Nguyễn Thái Ngọc Duy; +Cc: git
Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
> 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 --forget" for this exact use case.
Two and a half comments.
- The title says "leave HEAD untouched". Are my working tree files
and my index also safe from this operation, or is HEAD the only
thing that is protected?
- I think I saw a variant of this gotcha for an unconcluded
cherry-pick that was left behind, which the bash-prompt script
did not notice but the next "git cherry-pick" did by complaining
"you are in the middle" or something like that. Perhaps we would
want to have a similarly sounding option to help that case, too,
not in this patch but as another patch on the same theme?
- Would it have helped if bash-prompt were in use? I am not saying
that this patch becomes unnecessary if you use it; I am trying to
see if it helps its users by reminding them what state they are
in.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] rebase: add --forget to cleanup rebase, leave HEAD untouched
2016-10-26 16:51 ` Junio C Hamano
@ 2016-10-27 10:40 ` Duy Nguyen
2016-10-31 19:25 ` Junio C Hamano
0 siblings, 1 reply; 10+ messages in thread
From: Duy Nguyen @ 2016-10-27 10:40 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Git Mailing List
On Wed, Oct 26, 2016 at 11:51 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
>
>> 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 --forget" for this exact use case.
>
> Two and a half comments.
>
> - The title says "leave HEAD untouched". Are my working tree files
> and my index also safe from this operation, or is HEAD the only
> thing that is protected?
Everything is protected. I will rephrase the title a bit. The option
is basically a safe form of "rm -r .git/rebase-{apply,merge}".
> - I think I saw a variant of this gotcha for an unconcluded
> cherry-pick that was left behind, which the bash-prompt script
> did not notice but the next "git cherry-pick" did by complaining
> "you are in the middle" or something like that. Perhaps we would
> want to have a similarly sounding option to help that case, too,
> not in this patch but as another patch on the same theme?
That would be nice. I don't put lots of git info on my shell prompt
though, so it does not help me. And it's probably difficult to report
the right thing too. Sometimes in the middle of rebase I would switch
to another branch, look or do stuff, then "git checkout -" back. I
don't think we can make the prompt script clever enough to see my
intention.
> - Would it have helped if bash-prompt were in use? I am not saying
> that this patch becomes unnecessary if you use it; I am trying to
> see if it helps its users by reminding them what state they are
> in.
Since I don't use it because I want to keep shell prompt short and
light, it doe not help me. But it looks like git-prompt.sh does print
rebase in progress and others (only checked the code, didn't test it).
--
Duy
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] rebase: add --forget to cleanup rebase, leave HEAD untouched
2016-10-27 10:40 ` Duy Nguyen
@ 2016-10-31 19:25 ` Junio C Hamano
0 siblings, 0 replies; 10+ messages in thread
From: Junio C Hamano @ 2016-10-31 19:25 UTC (permalink / raw)
To: Duy Nguyen; +Cc: Git Mailing List
Duy Nguyen <pclouds@gmail.com> writes:
> On Wed, Oct 26, 2016 at 11:51 PM, Junio C Hamano <gitster@pobox.com> wrote:
>> Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
>>
>>> 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 --forget" for this exact use case.
>>
>> Two and a half comments.
>>
>> - The title says "leave HEAD untouched". Are my working tree files
>> and my index also safe from this operation, or is HEAD the only
>> thing that is protected?
>
> Everything is protected. I will rephrase the title a bit. The option
> is basically a safe form of "rm -r .git/rebase-{apply,merge}".
We are not in a hurry, as it is not likely that this will hit 2.11
even if we saw a rerolled version yesterday, but it would be nice to
cook it on 'next' so that it can be on 'master' early after the
upcoming release.
Thanks.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2] rebase: add --forget to cleanup rebase, leave everything else untouched
2016-10-26 9:46 [PATCH] rebase: add --forget to cleanup rebase, leave HEAD untouched Nguyễn Thái Ngọc Duy
2016-10-26 16:51 ` Junio C Hamano
@ 2016-11-09 9:11 ` Nguyễn Thái Ngọc Duy
2016-11-09 20:12 ` Junio C Hamano
2016-11-12 2:00 ` [PATCH v3] " Nguyễn Thái Ngọc Duy
1 sibling, 2 replies; 10+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-11-09 9:11 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Nguyễn Thái Ngọc Duy
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 --forget" for this exact use case.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
v2 changes just the subject line
Documentation/git-rebase.txt | 5 ++++-
contrib/completion/git-completion.bash | 4 ++--
git-rebase.sh | 6 +++++-
t/t3407-rebase-abort.sh | 24 ++++++++++++++++++++++++
4 files changed, 35 insertions(+), 4 deletions(-)
diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt
index de222c8..5a58fb3 100644
--- a/Documentation/git-rebase.txt
+++ b/Documentation/git-rebase.txt
@@ -12,7 +12,7 @@ SYNOPSIS
[<upstream> [<branch>]]
'git rebase' [-i | --interactive] [options] [--exec <cmd>] [--onto <newbase>]
--root [<branch>]
-'git rebase' --continue | --skip | --abort | --edit-todo
+'git rebase' --continue | --skip | --abort | --forget | --edit-todo
DESCRIPTION
-----------
@@ -252,6 +252,9 @@ 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
started.
+--forget::
+ Abort the rebase operation but leave HEAD where it is.
+
--keep-empty::
Keep the commits that do not change anything from its
parents in the result.
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 21016bf..3143cb0 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1734,10 +1734,10 @@ _git_rebase ()
{
local dir="$(__gitdir)"
if [ -f "$dir"/rebase-merge/interactive ]; then
- __gitcomp "--continue --skip --abort --edit-todo"
+ __gitcomp "--continue --skip --abort --forget --edit-todo"
return
elif [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then
- __gitcomp "--continue --skip --abort"
+ __gitcomp "--continue --skip --abort --forget"
return
fi
__git_complete_strategy && return
diff --git a/git-rebase.sh b/git-rebase.sh
index 04f6e44..de712b7 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -43,6 +43,7 @@ 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
+forget! abort but keep HEAD where it is
"
. git-sh-setup
set_reflog_action rebase
@@ -241,7 +242,7 @@ do
--verify)
ok_to_skip_pre_rebase=
;;
- --continue|--skip|--abort|--edit-todo)
+ --continue|--skip|--abort|--forget|--edit-todo)
test $total_argc -eq 2 || usage
action=${1##--}
;;
@@ -399,6 +400,9 @@ abort)
finish_rebase
exit
;;
+forget)
+ exec rm -rf "$state_dir"
+ ;;
edit-todo)
run_specific_rebase
;;
diff --git a/t/t3407-rebase-abort.sh b/t/t3407-rebase-abort.sh
index a6a6c40..6bc5e71 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 --forget' '
+ 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 --forget &&
+ test $(git rev-parse HEAD) = $head_before &&
+ test ! -d .git/rebase-apply
+'
+
+test_expect_success 'rebase --merge --forget' '
+ 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 --forget &&
+ test $(git rev-parse HEAD) = $head_before &&
+ test ! -d .git/rebase-merge
+'
+
test_done
--
2.8.2.524.g6ff3d78
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v2] rebase: add --forget to cleanup rebase, leave everything else untouched
2016-11-09 9:11 ` [PATCH v2] rebase: add --forget to cleanup rebase, leave everything else untouched Nguyễn Thái Ngọc Duy
@ 2016-11-09 20:12 ` Junio C Hamano
2016-11-10 11:09 ` Duy Nguyen
2016-11-12 2:00 ` [PATCH v3] " Nguyễn Thái Ngọc Duy
1 sibling, 1 reply; 10+ messages in thread
From: Junio C Hamano @ 2016-11-09 20:12 UTC (permalink / raw)
To: Nguyễn Thái Ngọc Duy; +Cc: git
Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
> ---
> v2 changes just the subject line
That's not sufficient, is it? What you did in the documentation
would raise the same "Hmph, is this only about HEAD?" and unlike the
commit subject, it will carve it in stone for end-users.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2] rebase: add --forget to cleanup rebase, leave everything else untouched
2016-11-09 20:12 ` Junio C Hamano
@ 2016-11-10 11:09 ` Duy Nguyen
2016-11-10 11:22 ` Duy Nguyen
0 siblings, 1 reply; 10+ messages in thread
From: Duy Nguyen @ 2016-11-10 11:09 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Git Mailing List
On Thu, Nov 10, 2016 at 3:12 AM, Junio C Hamano <gitster@pobox.com> wrote:
> Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
>
>> ---
>> v2 changes just the subject line
>
> That's not sufficient, is it? What you did in the documentation
> would raise the same "Hmph, is this only about HEAD?" and unlike the
> commit subject, it will carve it in stone for end-users.
Oops. I forgot about git-rebase.txt. How about this?
--forget::
Abort the rebase operation but leave HEAD, the index and
working tree untouched.
And think that's all the things rebase touches.
--
Duy
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2] rebase: add --forget to cleanup rebase, leave everything else untouched
2016-11-10 11:09 ` Duy Nguyen
@ 2016-11-10 11:22 ` Duy Nguyen
2016-11-10 19:07 ` Junio C Hamano
0 siblings, 1 reply; 10+ messages in thread
From: Duy Nguyen @ 2016-11-10 11:22 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Git Mailing List
On Thu, Nov 10, 2016 at 6:09 PM, Duy Nguyen <pclouds@gmail.com> wrote:
> On Thu, Nov 10, 2016 at 3:12 AM, Junio C Hamano <gitster@pobox.com> wrote:
>> Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
>>
>>> ---
>>> v2 changes just the subject line
>>
>> That's not sufficient, is it? What you did in the documentation
>> would raise the same "Hmph, is this only about HEAD?" and unlike the
>> commit subject, it will carve it in stone for end-users.
>
> Oops. I forgot about git-rebase.txt. How about this?
>
> --forget::
> Abort the rebase operation but leave HEAD, the index and
> working tree untouched.
Or, since --abort describes it as "reset HEAD to the original branch",
we could write "Abort the rebase operation. Unlike --abort, HEAD is
not restored back to the original branch". Index and worktree are
implied by "not restored". Not sure if it's too subtle.
--
Duy
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2] rebase: add --forget to cleanup rebase, leave everything else untouched
2016-11-10 11:22 ` Duy Nguyen
@ 2016-11-10 19:07 ` Junio C Hamano
0 siblings, 0 replies; 10+ messages in thread
From: Junio C Hamano @ 2016-11-10 19:07 UTC (permalink / raw)
To: Duy Nguyen; +Cc: Git Mailing List
Duy Nguyen <pclouds@gmail.com> writes:
> On Thu, Nov 10, 2016 at 6:09 PM, Duy Nguyen <pclouds@gmail.com> wrote:
>> On Thu, Nov 10, 2016 at 3:12 AM, Junio C Hamano <gitster@pobox.com> wrote:
>>> Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
>>>
>>>> ---
>>>> v2 changes just the subject line
>>>
>>> That's not sufficient, is it? What you did in the documentation
>>> would raise the same "Hmph, is this only about HEAD?" and unlike the
>>> commit subject, it will carve it in stone for end-users.
>>
>> Oops. I forgot about git-rebase.txt. How about this?
>>
>> --forget::
>> Abort the rebase operation but leave HEAD, the index and
>> working tree untouched.
>
> Or, since --abort describes it as "reset HEAD to the original branch",
> we could write "Abort the rebase operation. Unlike --abort, HEAD is
> not restored back to the original branch". Index and worktree are
> implied by "not restored". Not sure if it's too subtle.
I think you are moving in the right direction, even though "Abort
it; unlike --abort, does this instead" is a bit hard to follow.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v3] rebase: add --forget to cleanup rebase, leave everything else untouched
2016-11-09 9:11 ` [PATCH v2] rebase: add --forget to cleanup rebase, leave everything else untouched Nguyễn Thái Ngọc Duy
2016-11-09 20:12 ` Junio C Hamano
@ 2016-11-12 2:00 ` Nguyễn Thái Ngọc Duy
1 sibling, 0 replies; 10+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-11-12 2:00 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Nguyễn Thái Ngọc Duy
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 --forget" for this exact use case.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
v3 rewrote the desscription of --forget in git-rebase.txt to be more
or less along the same line as --abort. What happens to the index and
worktree is also stated to avoid misunderstanding.
Documentation/git-rebase.txt | 7 ++++++-
contrib/completion/git-completion.bash | 4 ++--
git-rebase.sh | 6 +++++-
t/t3407-rebase-abort.sh | 24 ++++++++++++++++++++++++
4 files changed, 37 insertions(+), 4 deletions(-)
diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt
index de222c8..1e16c70 100644
--- a/Documentation/git-rebase.txt
+++ b/Documentation/git-rebase.txt
@@ -12,7 +12,7 @@ SYNOPSIS
[<upstream> [<branch>]]
'git rebase' [-i | --interactive] [options] [--exec <cmd>] [--onto <newbase>]
--root [<branch>]
-'git rebase' --continue | --skip | --abort | --edit-todo
+'git rebase' --continue | --skip | --abort | --forget | --edit-todo
DESCRIPTION
-----------
@@ -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
started.
+--forget::
+ 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 the commits that do not change anything from its
parents in the result.
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 21016bf..3143cb0 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1734,10 +1734,10 @@ _git_rebase ()
{
local dir="$(__gitdir)"
if [ -f "$dir"/rebase-merge/interactive ]; then
- __gitcomp "--continue --skip --abort --edit-todo"
+ __gitcomp "--continue --skip --abort --forget --edit-todo"
return
elif [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then
- __gitcomp "--continue --skip --abort"
+ __gitcomp "--continue --skip --abort --forget"
return
fi
__git_complete_strategy && return
diff --git a/git-rebase.sh b/git-rebase.sh
index 04f6e44..de712b7 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -43,6 +43,7 @@ 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
+forget! abort but keep HEAD where it is
"
. git-sh-setup
set_reflog_action rebase
@@ -241,7 +242,7 @@ do
--verify)
ok_to_skip_pre_rebase=
;;
- --continue|--skip|--abort|--edit-todo)
+ --continue|--skip|--abort|--forget|--edit-todo)
test $total_argc -eq 2 || usage
action=${1##--}
;;
@@ -399,6 +400,9 @@ abort)
finish_rebase
exit
;;
+forget)
+ exec rm -rf "$state_dir"
+ ;;
edit-todo)
run_specific_rebase
;;
diff --git a/t/t3407-rebase-abort.sh b/t/t3407-rebase-abort.sh
index a6a6c40..6bc5e71 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 --forget' '
+ 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 --forget &&
+ test $(git rev-parse HEAD) = $head_before &&
+ test ! -d .git/rebase-apply
+'
+
+test_expect_success 'rebase --merge --forget' '
+ 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 --forget &&
+ test $(git rev-parse HEAD) = $head_before &&
+ test ! -d .git/rebase-merge
+'
+
test_done
--
2.8.2.524.g6ff3d78
^ permalink raw reply related [flat|nested] 10+ messages in thread
end of thread, other threads:[~2016-11-12 2:16 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-26 9:46 [PATCH] rebase: add --forget to cleanup rebase, leave HEAD untouched Nguyễn Thái Ngọc Duy
2016-10-26 16:51 ` Junio C Hamano
2016-10-27 10:40 ` Duy Nguyen
2016-10-31 19:25 ` Junio C Hamano
2016-11-09 9:11 ` [PATCH v2] rebase: add --forget to cleanup rebase, leave everything else untouched Nguyễn Thái Ngọc Duy
2016-11-09 20:12 ` Junio C Hamano
2016-11-10 11:09 ` Duy Nguyen
2016-11-10 11:22 ` Duy Nguyen
2016-11-10 19:07 ` Junio C Hamano
2016-11-12 2:00 ` [PATCH v3] " Nguyễn Thái Ngọc Duy
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.