{"thread":{"id":"44375","subject":"[PATCH] rebase: add --forget to cleanup rebase, leave HEAD untouched","startedAt":"2016-10-26T09:47:18Z","lastAt":"2016-11-12T02:16:02Z","messageCount":10,"participants":["Nguyễn Thái Ngọc Duy","Junio C Hamano","Duy Nguyen"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"304885","messageId":"20161026094658.20704-1-pclouds@gmail.com","threadId":"44375","inReplyTo":null,"subject":"[PATCH] rebase: add --forget to cleanup rebase, leave HEAD untouched","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-10-26T09:46:58Z","receivedAt":"2016-10-26T09:47:18Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"There are occasions when you decide to abort an in-progress rebase and\nmove on to do something else but you forget to do \"git rebase --abort\"\nfirst. Or the rebase has been in progress for so long you forgot about\nit. By the time you realize that (e.g. by starting another rebase)\nit's already too late to retrace your steps. The solution is normally\n\n    rm -r .git/<some rebase dir>\n\nand continue with your life. But there could be two different\ndirectories for <some rebase dir> (and it obviously requires some\nknowledge of how rebase works), and the \".git\" part could be much\nlonger if you are not at top-dir, or in a linked worktree. And\n\"rm -r\" is very dangerous to do in .git, a mistake in there could\ndestroy object database or other important data.\n\nProvide \"git rebase --forget\" for this exact use case.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n Documentation/git-rebase.txt           |  5 ++++-\n contrib/completion/git-completion.bash |  4 ++--\n git-rebase.sh                          |  6 +++++-\n t/t3407-rebase-abort.sh                | 24 ++++++++++++++++++++++++\n 4 files changed, 35 insertions(+), 4 deletions(-)\n\ndiff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt\nindex de222c8..5a58fb3 100644\n--- a/Documentation/git-rebase.txt\n+++ b/Documentation/git-rebase.txt\n@@ -12,7 +12,7 @@ SYNOPSIS\n \t[<upstream> [<branch>]]\n 'git rebase' [-i | --interactive] [options] [--exec <cmd>] [--onto <newbase>]\n \t--root [<branch>]\n-'git rebase' --continue | --skip | --abort | --edit-todo\n+'git rebase' --continue | --skip | --abort | --forget | --edit-todo\n \n DESCRIPTION\n -----------\n@@ -252,6 +252,9 @@ leave out at most one of A and B, in which case it defaults to HEAD.\n \twill be reset to where it was when the rebase operation was\n \tstarted.\n \n+--forget::\n+\tAbort the rebase operation but leave HEAD where it is.\n+\n --keep-empty::\n \tKeep the commits that do not change anything from its\n \tparents in the result.\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 9c8f738..bb64fb4 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1733,10 +1733,10 @@ _git_rebase ()\n {\n \tlocal dir=\"$(__gitdir)\"\n \tif [ -f \"$dir\"/rebase-merge/interactive ]; then\n-\t\t__gitcomp \"--continue --skip --abort --edit-todo\"\n+\t\t__gitcomp \"--continue --skip --abort --forget --edit-todo\"\n \t\treturn\n \telif [ -d \"$dir\"/rebase-apply ] || [ -d \"$dir\"/rebase-merge ]; then\n-\t\t__gitcomp \"--continue --skip --abort\"\n+\t\t__gitcomp \"--continue --skip --abort --forget\"\n \t\treturn\n \tfi\n \t__git_complete_strategy && return\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex 04f6e44..de712b7 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -43,6 +43,7 @@ continue!          continue\n abort!             abort and check out the original branch\n skip!              skip current patch and continue\n edit-todo!         edit the todo list during an interactive rebase\n+forget!            abort but keep HEAD where it is\n \"\n . git-sh-setup\n set_reflog_action rebase\n@@ -241,7 +242,7 @@ do\n \t--verify)\n \t\tok_to_skip_pre_rebase=\n \t\t;;\n-\t--continue|--skip|--abort|--edit-todo)\n+\t--continue|--skip|--abort|--forget|--edit-todo)\n \t\ttest $total_argc -eq 2 || usage\n \t\taction=${1##--}\n \t\t;;\n@@ -399,6 +400,9 @@ abort)\n \tfinish_rebase\n \texit\n \t;;\n+forget)\n+\texec rm -rf \"$state_dir\"\n+\t;;\n edit-todo)\n \trun_specific_rebase\n \t;;\ndiff --git a/t/t3407-rebase-abort.sh b/t/t3407-rebase-abort.sh\nindex a6a6c40..6bc5e71 100755\n--- a/t/t3407-rebase-abort.sh\n+++ b/t/t3407-rebase-abort.sh\n@@ -99,4 +99,28 @@ testrebase() {\n testrebase \"\" .git/rebase-apply\n testrebase \" --merge\" .git/rebase-merge\n \n+test_expect_success 'rebase --forget' '\n+\tcd \"$work_dir\" &&\n+\t# Clean up the state from the previous one\n+\tgit reset --hard pre-rebase &&\n+\ttest_must_fail git rebase master &&\n+\ttest_path_is_dir .git/rebase-apply &&\n+\thead_before=$(git rev-parse HEAD) &&\n+\tgit rebase --forget &&\n+\ttest $(git rev-parse HEAD) = $head_before &&\n+\ttest ! -d .git/rebase-apply\n+'\n+\n+test_expect_success 'rebase --merge --forget' '\n+\tcd \"$work_dir\" &&\n+\t# Clean up the state from the previous one\n+\tgit reset --hard pre-rebase &&\n+\ttest_must_fail git rebase --merge master &&\n+\ttest_path_is_dir .git/rebase-merge &&\n+\thead_before=$(git rev-parse HEAD) &&\n+\tgit rebase --forget &&\n+\ttest $(git rev-parse HEAD) = $head_before &&\n+\ttest ! -d .git/rebase-merge\n+'\n+\n test_done\n-- \n2.8.2.524.g6ff3d78\n\n"},{"id":"304900","messageId":"xmqq60ofcavd.fsf@gitster.mtv.corp.google.com","threadId":"44375","inReplyTo":"20161026094658.20704-1-pclouds@gmail.com","subject":"Re: [PATCH] rebase: add --forget to cleanup rebase, leave HEAD untouched","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-10-26T16:51:02Z","receivedAt":"2016-10-26T16:51:10Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:\n\n> There are occasions when you decide to abort an in-progress rebase and\n> move on to do something else but you forget to do \"git rebase --abort\"\n> first. Or the rebase has been in progress for so long you forgot about\n> it. By the time you realize that (e.g. by starting another rebase)\n> it's already too late to retrace your steps. The solution is normally\n>\n>     rm -r .git/<some rebase dir>\n>\n> and continue with your life. But there could be two different\n> directories for <some rebase dir> (and it obviously requires some\n> knowledge of how rebase works), and the \".git\" part could be much\n> longer if you are not at top-dir, or in a linked worktree. And\n> \"rm -r\" is very dangerous to do in .git, a mistake in there could\n> destroy object database or other important data.\n>\n> Provide \"git rebase --forget\" for this exact use case.\n\nTwo and a half comments.\n\n - The title says \"leave HEAD untouched\".  Are my working tree files\n   and my index also safe from this operation, or is HEAD the only\n   thing that is protected?\n\n - I think I saw a variant of this gotcha for an unconcluded\n   cherry-pick that was left behind, which the bash-prompt script\n   did not notice but the next \"git cherry-pick\" did by complaining\n   \"you are in the middle\" or something like that.  Perhaps we would\n   want to have a similarly sounding option to help that case, too,\n   not in this patch but as another patch on the same theme?\n\n - Would it have helped if bash-prompt were in use?  I am not saying\n   that this patch becomes unnecessary if you use it; I am trying to\n   see if it helps its users by reminding them what state they are\n   in.\n\n"},{"id":"304960","messageId":"CACsJy8CSz-2A56okV6kWBjGqUgiL7DrmmVJ=2jEQhKmqe41cRg@mail.gmail.com","threadId":"44375","inReplyTo":"xmqq60ofcavd.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH] rebase: add --forget to cleanup rebase, leave HEAD untouched","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2016-10-27T10:40:43Z","receivedAt":"2016-10-27T14:27:44Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Wed, Oct 26, 2016 at 11:51 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:\n>\n>> There are occasions when you decide to abort an in-progress rebase and\n>> move on to do something else but you forget to do \"git rebase --abort\"\n>> first. Or the rebase has been in progress for so long you forgot about\n>> it. By the time you realize that (e.g. by starting another rebase)\n>> it's already too late to retrace your steps. The solution is normally\n>>\n>>     rm -r .git/<some rebase dir>\n>>\n>> and continue with your life. But there could be two different\n>> directories for <some rebase dir> (and it obviously requires some\n>> knowledge of how rebase works), and the \".git\" part could be much\n>> longer if you are not at top-dir, or in a linked worktree. And\n>> \"rm -r\" is very dangerous to do in .git, a mistake in there could\n>> destroy object database or other important data.\n>>\n>> Provide \"git rebase --forget\" for this exact use case.\n>\n> Two and a half comments.\n>\n>  - The title says \"leave HEAD untouched\".  Are my working tree files\n>    and my index also safe from this operation, or is HEAD the only\n>    thing that is protected?\n\nEverything is protected. I will rephrase the title a bit. The option\nis basically a safe form of \"rm -r .git/rebase-{apply,merge}\".\n\n>  - I think I saw a variant of this gotcha for an unconcluded\n>    cherry-pick that was left behind, which the bash-prompt script\n>    did not notice but the next \"git cherry-pick\" did by complaining\n>    \"you are in the middle\" or something like that.  Perhaps we would\n>    want to have a similarly sounding option to help that case, too,\n>    not in this patch but as another patch on the same theme?\n\nThat would be nice. I don't put lots of git info on my shell prompt\nthough, so it does not help me. And it's probably difficult to report\nthe right thing too. Sometimes in the middle of rebase I would switch\nto another branch, look or do stuff, then \"git checkout -\" back. I\ndon't think we can make the prompt script clever enough to see my\nintention.\n\n>  - Would it have helped if bash-prompt were in use?  I am not saying\n>    that this patch becomes unnecessary if you use it; I am trying to\n>    see if it helps its users by reminding them what state they are\n>    in.\n\nSince I don't use it because I want to keep shell prompt short and\nlight, it doe not help me. But it looks like git-prompt.sh does print\nrebase in progress and others (only checked the code, didn't test it).\n-- \nDuy\n"},{"id":"305203","messageId":"xmqqshrctj5v.fsf@gitster.mtv.corp.google.com","threadId":"44375","inReplyTo":"CACsJy8CSz-2A56okV6kWBjGqUgiL7DrmmVJ=2jEQhKmqe41cRg@mail.gmail.com","subject":"Re: [PATCH] rebase: add --forget to cleanup rebase, leave HEAD untouched","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-10-31T19:25:48Z","receivedAt":"2016-10-31T19:26:04Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Duy Nguyen <pclouds@gmail.com> writes:\n\n> On Wed, Oct 26, 2016 at 11:51 PM, Junio C Hamano <gitster@pobox.com> wrote:\n>> Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:\n>>\n>>> There are occasions when you decide to abort an in-progress rebase and\n>>> move on to do something else but you forget to do \"git rebase --abort\"\n>>> first. Or the rebase has been in progress for so long you forgot about\n>>> it. By the time you realize that (e.g. by starting another rebase)\n>>> it's already too late to retrace your steps. The solution is normally\n>>>\n>>>     rm -r .git/<some rebase dir>\n>>>\n>>> and continue with your life. But there could be two different\n>>> directories for <some rebase dir> (and it obviously requires some\n>>> knowledge of how rebase works), and the \".git\" part could be much\n>>> longer if you are not at top-dir, or in a linked worktree. And\n>>> \"rm -r\" is very dangerous to do in .git, a mistake in there could\n>>> destroy object database or other important data.\n>>>\n>>> Provide \"git rebase --forget\" for this exact use case.\n>>\n>> Two and a half comments.\n>>\n>>  - The title says \"leave HEAD untouched\".  Are my working tree files\n>>    and my index also safe from this operation, or is HEAD the only\n>>    thing that is protected?\n>\n> Everything is protected. I will rephrase the title a bit. The option\n> is basically a safe form of \"rm -r .git/rebase-{apply,merge}\".\n\nWe are not in a hurry, as it is not likely that this will hit 2.11\neven if we saw a rerolled version yesterday, but it would be nice to\ncook it on 'next' so that it can be on 'master' early after the\nupcoming release.\n\nThanks.\n"},{"id":"305619","messageId":"20161109091131.17933-1-pclouds@gmail.com","threadId":"44375","inReplyTo":"20161026094658.20704-1-pclouds@gmail.com","subject":"[PATCH v2] rebase: add --forget to cleanup rebase, leave everything else untouched","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-11-09T09:11:31Z","receivedAt":"2016-11-09T09:11:57Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"There are occasions when you decide to abort an in-progress rebase and\nmove on to do something else but you forget to do \"git rebase --abort\"\nfirst. Or the rebase has been in progress for so long you forgot about\nit. By the time you realize that (e.g. by starting another rebase)\nit's already too late to retrace your steps. The solution is normally\n\n    rm -r .git/<some rebase dir>\n\nand continue with your life. But there could be two different\ndirectories for <some rebase dir> (and it obviously requires some\nknowledge of how rebase works), and the \".git\" part could be much\nlonger if you are not at top-dir, or in a linked worktree. And\n\"rm -r\" is very dangerous to do in .git, a mistake in there could\ndestroy object database or other important data.\n\nProvide \"git rebase --forget\" for this exact use case.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n v2 changes just the subject line\n\n Documentation/git-rebase.txt           |  5 ++++-\n contrib/completion/git-completion.bash |  4 ++--\n git-rebase.sh                          |  6 +++++-\n t/t3407-rebase-abort.sh                | 24 ++++++++++++++++++++++++\n 4 files changed, 35 insertions(+), 4 deletions(-)\n\ndiff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt\nindex de222c8..5a58fb3 100644\n--- a/Documentation/git-rebase.txt\n+++ b/Documentation/git-rebase.txt\n@@ -12,7 +12,7 @@ SYNOPSIS\n \t[<upstream> [<branch>]]\n 'git rebase' [-i | --interactive] [options] [--exec <cmd>] [--onto <newbase>]\n \t--root [<branch>]\n-'git rebase' --continue | --skip | --abort | --edit-todo\n+'git rebase' --continue | --skip | --abort | --forget | --edit-todo\n \n DESCRIPTION\n -----------\n@@ -252,6 +252,9 @@ leave out at most one of A and B, in which case it defaults to HEAD.\n \twill be reset to where it was when the rebase operation was\n \tstarted.\n \n+--forget::\n+\tAbort the rebase operation but leave HEAD where it is.\n+\n --keep-empty::\n \tKeep the commits that do not change anything from its\n \tparents in the result.\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 21016bf..3143cb0 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1734,10 +1734,10 @@ _git_rebase ()\n {\n \tlocal dir=\"$(__gitdir)\"\n \tif [ -f \"$dir\"/rebase-merge/interactive ]; then\n-\t\t__gitcomp \"--continue --skip --abort --edit-todo\"\n+\t\t__gitcomp \"--continue --skip --abort --forget --edit-todo\"\n \t\treturn\n \telif [ -d \"$dir\"/rebase-apply ] || [ -d \"$dir\"/rebase-merge ]; then\n-\t\t__gitcomp \"--continue --skip --abort\"\n+\t\t__gitcomp \"--continue --skip --abort --forget\"\n \t\treturn\n \tfi\n \t__git_complete_strategy && return\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex 04f6e44..de712b7 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -43,6 +43,7 @@ continue!          continue\n abort!             abort and check out the original branch\n skip!              skip current patch and continue\n edit-todo!         edit the todo list during an interactive rebase\n+forget!            abort but keep HEAD where it is\n \"\n . git-sh-setup\n set_reflog_action rebase\n@@ -241,7 +242,7 @@ do\n \t--verify)\n \t\tok_to_skip_pre_rebase=\n \t\t;;\n-\t--continue|--skip|--abort|--edit-todo)\n+\t--continue|--skip|--abort|--forget|--edit-todo)\n \t\ttest $total_argc -eq 2 || usage\n \t\taction=${1##--}\n \t\t;;\n@@ -399,6 +400,9 @@ abort)\n \tfinish_rebase\n \texit\n \t;;\n+forget)\n+\texec rm -rf \"$state_dir\"\n+\t;;\n edit-todo)\n \trun_specific_rebase\n \t;;\ndiff --git a/t/t3407-rebase-abort.sh b/t/t3407-rebase-abort.sh\nindex a6a6c40..6bc5e71 100755\n--- a/t/t3407-rebase-abort.sh\n+++ b/t/t3407-rebase-abort.sh\n@@ -99,4 +99,28 @@ testrebase() {\n testrebase \"\" .git/rebase-apply\n testrebase \" --merge\" .git/rebase-merge\n \n+test_expect_success 'rebase --forget' '\n+\tcd \"$work_dir\" &&\n+\t# Clean up the state from the previous one\n+\tgit reset --hard pre-rebase &&\n+\ttest_must_fail git rebase master &&\n+\ttest_path_is_dir .git/rebase-apply &&\n+\thead_before=$(git rev-parse HEAD) &&\n+\tgit rebase --forget &&\n+\ttest $(git rev-parse HEAD) = $head_before &&\n+\ttest ! -d .git/rebase-apply\n+'\n+\n+test_expect_success 'rebase --merge --forget' '\n+\tcd \"$work_dir\" &&\n+\t# Clean up the state from the previous one\n+\tgit reset --hard pre-rebase &&\n+\ttest_must_fail git rebase --merge master &&\n+\ttest_path_is_dir .git/rebase-merge &&\n+\thead_before=$(git rev-parse HEAD) &&\n+\tgit rebase --forget &&\n+\ttest $(git rev-parse HEAD) = $head_before &&\n+\ttest ! -d .git/rebase-merge\n+'\n+\n test_done\n-- \n2.8.2.524.g6ff3d78\n\n"},{"id":"305642","messageId":"xmqqh97g9zut.fsf@gitster.mtv.corp.google.com","threadId":"44375","inReplyTo":"20161109091131.17933-1-pclouds@gmail.com","subject":"Re: [PATCH v2] rebase: add --forget to cleanup rebase, leave everything else untouched","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-11-09T20:12:42Z","receivedAt":"2016-11-09T20:12:49Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:\n\n> ---\n>  v2 changes just the subject line\n\nThat's not sufficient, is it?  What you did in the documentation\nwould raise the same \"Hmph, is this only about HEAD?\" and unlike the\ncommit subject, it will carve it in stone for end-users.\n\n"},{"id":"305673","messageId":"CACsJy8D9SHjwb2Ug_DYKmSO+dDxkkqwBFViQrW4eDqbJFjHESw@mail.gmail.com","threadId":"44375","inReplyTo":"xmqqh97g9zut.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH v2] rebase: add --forget to cleanup rebase, leave everything else untouched","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2016-11-10T11:09:30Z","receivedAt":"2016-11-10T11:10:08Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Thu, Nov 10, 2016 at 3:12 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:\n>\n>> ---\n>>  v2 changes just the subject line\n>\n> That's not sufficient, is it?  What you did in the documentation\n> would raise the same \"Hmph, is this only about HEAD?\" and unlike the\n> commit subject, it will carve it in stone for end-users.\n\nOops. I forgot about git-rebase.txt. How about this?\n\n--forget::\n        Abort the rebase operation but leave HEAD, the index and\nworking tree untouched.\n\nAnd think that's all the things rebase touches.\n-- \nDuy\n"},{"id":"305676","messageId":"CACsJy8CHWZyFgZu1=VKCQc+hbHUmZiAQ9ToL=NDF=YBEkLfbog@mail.gmail.com","threadId":"44375","inReplyTo":"CACsJy8D9SHjwb2Ug_DYKmSO+dDxkkqwBFViQrW4eDqbJFjHESw@mail.gmail.com","subject":"Re: [PATCH v2] rebase: add --forget to cleanup rebase, leave everything else untouched","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2016-11-10T11:22:31Z","receivedAt":"2016-11-10T11:23:08Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Thu, Nov 10, 2016 at 6:09 PM, Duy Nguyen <pclouds@gmail.com> wrote:\n> On Thu, Nov 10, 2016 at 3:12 AM, Junio C Hamano <gitster@pobox.com> wrote:\n>> Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:\n>>\n>>> ---\n>>>  v2 changes just the subject line\n>>\n>> That's not sufficient, is it?  What you did in the documentation\n>> would raise the same \"Hmph, is this only about HEAD?\" and unlike the\n>> commit subject, it will carve it in stone for end-users.\n>\n> Oops. I forgot about git-rebase.txt. How about this?\n>\n> --forget::\n>         Abort the rebase operation but leave HEAD, the index and\n> working tree untouched.\n\nOr, since --abort describes it as \"reset HEAD to the original branch\",\nwe could write \"Abort the rebase operation. Unlike --abort, HEAD is\nnot restored back to the original branch\". Index and worktree are\nimplied by \"not restored\". Not sure if it's too subtle.\n-- \nDuy\n"},{"id":"305686","messageId":"xmqqfumz6tnj.fsf@gitster.mtv.corp.google.com","threadId":"44375","inReplyTo":"CACsJy8CHWZyFgZu1=VKCQc+hbHUmZiAQ9ToL=NDF=YBEkLfbog@mail.gmail.com","subject":"Re: [PATCH v2] rebase: add --forget to cleanup rebase, leave everything else untouched","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-11-10T19:07:12Z","receivedAt":"2016-11-10T19:07:20Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Duy Nguyen <pclouds@gmail.com> writes:\n\n> On Thu, Nov 10, 2016 at 6:09 PM, Duy Nguyen <pclouds@gmail.com> wrote:\n>> On Thu, Nov 10, 2016 at 3:12 AM, Junio C Hamano <gitster@pobox.com> wrote:\n>>> Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:\n>>>\n>>>> ---\n>>>>  v2 changes just the subject line\n>>>\n>>> That's not sufficient, is it?  What you did in the documentation\n>>> would raise the same \"Hmph, is this only about HEAD?\" and unlike the\n>>> commit subject, it will carve it in stone for end-users.\n>>\n>> Oops. I forgot about git-rebase.txt. How about this?\n>>\n>> --forget::\n>>         Abort the rebase operation but leave HEAD, the index and\n>> working tree untouched.\n>\n> Or, since --abort describes it as \"reset HEAD to the original branch\",\n> we could write \"Abort the rebase operation. Unlike --abort, HEAD is\n> not restored back to the original branch\". Index and worktree are\n> implied by \"not restored\". Not sure if it's too subtle.\n\nI think you are moving in the right direction, even though \"Abort\nit; unlike --abort, does this instead\" is a bit hard to follow.\n"},{"id":"305838","messageId":"20161112020041.2335-1-pclouds@gmail.com","threadId":"44375","inReplyTo":"20161109091131.17933-1-pclouds@gmail.com","subject":"[PATCH v3] rebase: add --forget to cleanup rebase, leave everything else untouched","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-11-12T02:00:41Z","receivedAt":"2016-11-12T02:16:02Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"There are occasions when you decide to abort an in-progress rebase and\nmove on to do something else but you forget to do \"git rebase --abort\"\nfirst. Or the rebase has been in progress for so long you forgot about\nit. By the time you realize that (e.g. by starting another rebase)\nit's already too late to retrace your steps. The solution is normally\n\n    rm -r .git/<some rebase dir>\n\nand continue with your life. But there could be two different\ndirectories for <some rebase dir> (and it obviously requires some\nknowledge of how rebase works), and the \".git\" part could be much\nlonger if you are not at top-dir, or in a linked worktree. And\n\"rm -r\" is very dangerous to do in .git, a mistake in there could\ndestroy object database or other important data.\n\nProvide \"git rebase --forget\" for this exact use case.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n v3 rewrote the desscription of --forget in git-rebase.txt to be more\n or less along the same line as --abort. What happens to the index and\n worktree is also stated to avoid misunderstanding.\n\n Documentation/git-rebase.txt           |  7 ++++++-\n contrib/completion/git-completion.bash |  4 ++--\n git-rebase.sh                          |  6 +++++-\n t/t3407-rebase-abort.sh                | 24 ++++++++++++++++++++++++\n 4 files changed, 37 insertions(+), 4 deletions(-)\n\ndiff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt\nindex de222c8..1e16c70 100644\n--- a/Documentation/git-rebase.txt\n+++ b/Documentation/git-rebase.txt\n@@ -12,7 +12,7 @@ SYNOPSIS\n \t[<upstream> [<branch>]]\n 'git rebase' [-i | --interactive] [options] [--exec <cmd>] [--onto <newbase>]\n \t--root [<branch>]\n-'git rebase' --continue | --skip | --abort | --edit-todo\n+'git rebase' --continue | --skip | --abort | --forget | --edit-todo\n \n DESCRIPTION\n -----------\n@@ -252,6 +252,11 @@ leave out at most one of A and B, in which case it defaults to HEAD.\n \twill be reset to where it was when the rebase operation was\n \tstarted.\n \n+--forget::\n+\tAbort the rebase operation but HEAD is not reset back to the\n+\toriginal branch. The index and working tree are also left\n+\tunchanged as a result.\n+\n --keep-empty::\n \tKeep the commits that do not change anything from its\n \tparents in the result.\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 21016bf..3143cb0 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1734,10 +1734,10 @@ _git_rebase ()\n {\n \tlocal dir=\"$(__gitdir)\"\n \tif [ -f \"$dir\"/rebase-merge/interactive ]; then\n-\t\t__gitcomp \"--continue --skip --abort --edit-todo\"\n+\t\t__gitcomp \"--continue --skip --abort --forget --edit-todo\"\n \t\treturn\n \telif [ -d \"$dir\"/rebase-apply ] || [ -d \"$dir\"/rebase-merge ]; then\n-\t\t__gitcomp \"--continue --skip --abort\"\n+\t\t__gitcomp \"--continue --skip --abort --forget\"\n \t\treturn\n \tfi\n \t__git_complete_strategy && return\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex 04f6e44..de712b7 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -43,6 +43,7 @@ continue!          continue\n abort!             abort and check out the original branch\n skip!              skip current patch and continue\n edit-todo!         edit the todo list during an interactive rebase\n+forget!            abort but keep HEAD where it is\n \"\n . git-sh-setup\n set_reflog_action rebase\n@@ -241,7 +242,7 @@ do\n \t--verify)\n \t\tok_to_skip_pre_rebase=\n \t\t;;\n-\t--continue|--skip|--abort|--edit-todo)\n+\t--continue|--skip|--abort|--forget|--edit-todo)\n \t\ttest $total_argc -eq 2 || usage\n \t\taction=${1##--}\n \t\t;;\n@@ -399,6 +400,9 @@ abort)\n \tfinish_rebase\n \texit\n \t;;\n+forget)\n+\texec rm -rf \"$state_dir\"\n+\t;;\n edit-todo)\n \trun_specific_rebase\n \t;;\ndiff --git a/t/t3407-rebase-abort.sh b/t/t3407-rebase-abort.sh\nindex a6a6c40..6bc5e71 100755\n--- a/t/t3407-rebase-abort.sh\n+++ b/t/t3407-rebase-abort.sh\n@@ -99,4 +99,28 @@ testrebase() {\n testrebase \"\" .git/rebase-apply\n testrebase \" --merge\" .git/rebase-merge\n \n+test_expect_success 'rebase --forget' '\n+\tcd \"$work_dir\" &&\n+\t# Clean up the state from the previous one\n+\tgit reset --hard pre-rebase &&\n+\ttest_must_fail git rebase master &&\n+\ttest_path_is_dir .git/rebase-apply &&\n+\thead_before=$(git rev-parse HEAD) &&\n+\tgit rebase --forget &&\n+\ttest $(git rev-parse HEAD) = $head_before &&\n+\ttest ! -d .git/rebase-apply\n+'\n+\n+test_expect_success 'rebase --merge --forget' '\n+\tcd \"$work_dir\" &&\n+\t# Clean up the state from the previous one\n+\tgit reset --hard pre-rebase &&\n+\ttest_must_fail git rebase --merge master &&\n+\ttest_path_is_dir .git/rebase-merge &&\n+\thead_before=$(git rev-parse HEAD) &&\n+\tgit rebase --forget &&\n+\ttest $(git rev-parse HEAD) = $head_before &&\n+\ttest ! -d .git/rebase-merge\n+'\n+\n test_done\n-- \n2.8.2.524.g6ff3d78\n\n"}]}