{"thread":{"id":"25264","subject":"[PATCH] commit: do not switch branch during a rebase unless -f is given","startedAt":"2010-09-28T04:52:44Z","lastAt":"2010-11-09T14:38:16Z","messageCount":12,"participants":["Nguyễn Thái Ngọc Duy","Jonathan Nieder","Junio C Hamano","Nguyen Thai Ngoc Duy","Sverre Rabbelier"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"151874","messageId":"1285649564-24737-1-git-send-email-pclouds@gmail.com","threadId":"25264","inReplyTo":null,"subject":"[PATCH] commit: do not switch branch during a rebase unless -f is given","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-09-28T04:52:44Z","receivedAt":"2010-09-28T04:52:44Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"It does not make much sense to switch branch when you are in a middle\nof a rebase. Sometimes you might want to switch away for a moment then\nback with \"git checkout - \". But I find myself so many times switching\naway then forget that I was rebasing something.\n\nAvoid doing that by default. Users can use -f if they really want to.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n I know there are other commands like rebase (\"git am\" comes to mind)\n but I don't use those. Feel free to put some more on top if somebody\n finds it a good thing to do.\n\n builtin/checkout.c         |    7 +++++++\n t/t2018-checkout-branch.sh |   22 ++++++++++++++++++++++\n 2 files changed, 29 insertions(+), 0 deletions(-)\n\ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex cc622c0..7d8ba04 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -571,6 +571,13 @@ static int switch_branches(struct checkout_opts *opts, struct branch_info *new)\n \tstruct branch_info old;\n \tunsigned char rev[20];\n \tint flag;\n+\tstruct stat st;\n+\n+\tif (!opts->force &&\n+\t    ((!stat(git_path(\"rebase-merge\"), &st) && S_ISDIR(st.st_mode)) ||\n+\t     (!stat(git_path(\"rebase-apply\"), &st) && S_ISDIR(st.st_mode))))\n+\t\tdie(\"You should not switch branch during a rebase. Use '-f' if you really want to.\");\n+\n \tmemset(&old, 0, sizeof(old));\n \told.path = resolve_ref(\"HEAD\", rev, 0, &flag);\n \told.commit = lookup_commit_reference_gently(rev, 1);\ndiff --git a/t/t2018-checkout-branch.sh b/t/t2018-checkout-branch.sh\nindex fa69016..95a1da8 100755\n--- a/t/t2018-checkout-branch.sh\n+++ b/t/t2018-checkout-branch.sh\n@@ -169,4 +169,26 @@ test_expect_success 'checkout -f -B to an existing branch with mergeable changes\n \ttest_must_fail test_dirty_mergeable\n '\n \n+test_expect_success 'checkout fails during rebase' '\n+\tgit reset --hard &&\n+\tgit checkout branch1 &&\n+\tmkdir .git/rebase-merge &&\n+\ttest_must_fail git checkout branch2 &&\n+\tgit checkout -f branch2\n+'\n+\n+test_expect_success 'checkout fails during rebase (2)' '\n+\trmdir .git/rebase-merge &&\n+\tgit reset --hard &&\n+\tgit checkout branch1 &&\n+\tmkdir .git/rebase-apply &&\n+\ttest_must_fail git checkout branch2 &&\n+\tgit checkout -f branch2\n+'\n+\n+# this is to be incorporated to the next test\n+test_expect_success 'cleanup' '\n+\trmdir .git/rebase-apply\n+'\n+\n test_done\n-- \n1.7.1.rc1.70.g788ca\n"},{"id":"151875","messageId":"1285649702-24773-1-git-send-email-pclouds@gmail.com","threadId":"25264","inReplyTo":"1285649564-24737-1-git-send-email-pclouds@gmail.com","subject":"[PATCH] checkout: do not switch branch during a rebase unless -f is given","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-09-28T04:55:02Z","receivedAt":"2010-09-28T04:55:02Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"It does not make much sense to switch branch when you are in a middle\nof a rebase. Sometimes you might want to switch away for a moment then\nback with \"git checkout - \". But I find myself so many times switching\naway then forget that I was rebasing something.\n\nAvoid doing that by default. Users can use -f if they really want to.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n Sorry, the previous patch had wrong subject line\n\n I know there are other commands like rebase (\"git am\" comes to mind)\n but I don't use those. Feel free to put some more on top if somebody\n finds it a good thing to do.\n\n builtin/checkout.c         |    7 +++++++\n t/t2018-checkout-branch.sh |   22 ++++++++++++++++++++++\n 2 files changed, 29 insertions(+), 0 deletions(-)\n\ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex cc622c0..7d8ba04 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -571,6 +571,13 @@ static int switch_branches(struct checkout_opts *opts, struct branch_info *new)\n \tstruct branch_info old;\n \tunsigned char rev[20];\n \tint flag;\n+\tstruct stat st;\n+\n+\tif (!opts->force &&\n+\t    ((!stat(git_path(\"rebase-merge\"), &st) && S_ISDIR(st.st_mode)) ||\n+\t     (!stat(git_path(\"rebase-apply\"), &st) && S_ISDIR(st.st_mode))))\n+\t\tdie(\"You should not switch branch during a rebase. Use '-f' if you really want to.\");\n+\n \tmemset(&old, 0, sizeof(old));\n \told.path = resolve_ref(\"HEAD\", rev, 0, &flag);\n \told.commit = lookup_commit_reference_gently(rev, 1);\ndiff --git a/t/t2018-checkout-branch.sh b/t/t2018-checkout-branch.sh\nindex fa69016..95a1da8 100755\n--- a/t/t2018-checkout-branch.sh\n+++ b/t/t2018-checkout-branch.sh\n@@ -169,4 +169,26 @@ test_expect_success 'checkout -f -B to an existing branch with mergeable changes\n \ttest_must_fail test_dirty_mergeable\n '\n \n+test_expect_success 'checkout fails during rebase' '\n+\tgit reset --hard &&\n+\tgit checkout branch1 &&\n+\tmkdir .git/rebase-merge &&\n+\ttest_must_fail git checkout branch2 &&\n+\tgit checkout -f branch2\n+'\n+\n+test_expect_success 'checkout fails during rebase (2)' '\n+\trmdir .git/rebase-merge &&\n+\tgit reset --hard &&\n+\tgit checkout branch1 &&\n+\tmkdir .git/rebase-apply &&\n+\ttest_must_fail git checkout branch2 &&\n+\tgit checkout -f branch2\n+'\n+\n+# this is to be incorporated to the next test\n+test_expect_success 'cleanup' '\n+\trmdir .git/rebase-apply\n+'\n+\n test_done\n-- \n1.7.1.rc1.70.g788ca\n"},{"id":"151877","messageId":"AANLkTinUudOXmhKW-+rkcpzb-VNnSBLZwGZcjrS6UdMu@mail.gmail.com","threadId":"25264","inReplyTo":"1285649702-24773-1-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH] checkout: do not switch branch during a rebase unless -f is given","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-09-28T05:33:38Z","receivedAt":"2010-09-28T05:33:38Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"(+cc: Frédéric, Dscho, Christian)\n\nNguyễn Thái Ngọc Duy wrote:\n\n> It does not make much sense to switch branch when you are in a middle\n> of a rebase. Sometimes you might want to switch away for a moment then\n> back with \"git checkout - \". But I find myself so many times switching\n> away then forget that I was rebasing something.\n>\n> Avoid doing that by default. Users can use -f if they really want to.\n\nNice! But I worry is that scripts that use \"git checkout\" porcelain\nduring a rebase would be broken.\n\nEven rebase --interactive uses checkout from time to time:\n\n - for preserving merges\n - to move to the correct branch in response to \"git rebase -i\n<upstream> <branch>\"\n - to move to the target in \"git rebase -i --onto <new base> <upstream>\"\n\nUnfortunately I do not have any good advice. Would it make sense to\n\n - first, change these call sites in git to use checkout -f\n - teach checkout to warn (without erroring out) to give people time\nto change their scripts\n - warn loudly about the upcoming change in the release notes\n - later, change checkout to error out when -f is not supplied\n\nor am I being too paranoid?\n\n>  I know there are other commands like rebase (\"git am\" comes to mind)\n>  but I don't use those. Feel free to put some more on top if somebody\n>  finds it a good thing to do.\n\nAnother interesting one is \"git bisect\".\n"},{"id":"151878","messageId":"7vfwwuv35o.fsf@alter.siamese.dyndns.org","threadId":"25264","inReplyTo":"1285649564-24737-1-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH] commit: do not switch branch during a rebase unless -f is given","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-09-28T05:38:11Z","receivedAt":"2010-09-28T05:38:11Z","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> It does not make much sense to switch branch when you are in a middle\n> of a rebase. Sometimes you might want to switch away for a moment then\n> back with \"git checkout - \". But I find myself so many times switching\n> away then forget that I was rebasing something.\n>\n> Avoid doing that by default. Users can use -f if they really want to.\n>\n> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n\nI think you need to retitle the patch.\n\nYou should realize that overloading \"-f\" and conflating its totally\ndifferent meaning, which is to discard local changes, with this new usage\nto say \"override the 'you are in rebase' switch\" closes the door to future\nimprovements we could make to rebase so that it does not to require a\ntotally clean working tree.  It would be Ok with today's rebase, as you\nwouldn't have local changes when it runs, but we might regret this 9\nmonths down the road.\n\n>  I know there are other commands like rebase (\"git am\" comes to mind)\n>  but I don't use those. Feel free to put some more on top if somebody\n>  finds it a good thing to do.\n\nIf you envision something similar to be used during \"git am\", then you\nreally shouldn't be reusing \"-f\", as \"git am\" is designed to be usable in\na dirty working tree.\n"},{"id":"151879","messageId":"AANLkTin19PREB3B68s+ejsgtXwe3CBxZF-caCvRp4UXv@mail.gmail.com","threadId":"25264","inReplyTo":"AANLkTinUudOXmhKW-+rkcpzb-VNnSBLZwGZcjrS6UdMu@mail.gmail.com","subject":"Re: [PATCH] checkout: do not switch branch during a rebase unless -f is given","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-09-28T05:47:50Z","receivedAt":"2010-09-28T05:47:50Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"2010/9/28 Jonathan Nieder <jrnieder@gmail.com>:\n> (+cc: Frédéric, Dscho, Christian)\n>\n> Nguyễn Thái Ngọc Duy wrote:\n>\n>> It does not make much sense to switch branch when you are in a middle\n>> of a rebase. Sometimes you might want to switch away for a moment then\n>> back with \"git checkout - \". But I find myself so many times switching\n>> away then forget that I was rebasing something.\n>>\n>> Avoid doing that by default. Users can use -f if they really want to.\n>\n> Nice! But I worry is that scripts that use \"git checkout\" porcelain\n> during a rebase would be broken.\n\nRight. I used git-rebase from my installation, the new \"git checkout\"\nfrom worktree and missed that as a result.\n\n> Even rebase --interactive uses checkout from time to time:\n>\n>  - for preserving merges\n>  - to move to the correct branch in response to \"git rebase -i\n> <upstream> <branch>\"\n>  - to move to the target in \"git rebase -i --onto <new base> <upstream>\"\n>\n> Unfortunately I do not have any good advice. Would it make sense to\n>\n>  - first, change these call sites in git to use checkout -f\n>  - teach checkout to warn (without erroring out) to give people time\n> to change their scripts\n>  - warn loudly about the upcoming change in the release notes\n>  - later, change checkout to error out when -f is not supplied\n>\n> or am I being too paranoid?\n\nNo. But I don't like the idea of making scripts use \"checkout -f\". My\nintention was to stop users from doing that, not scripts. Putting \"-f\"\neverywhere might have more negative side effects.\n\nMaybe adding \"--porcelain\" to checkout first, updating scripts to use\nit, then only check for rebase/bisect/am when --porcelain is missing.\n-- \nDuy\n"},{"id":"151896","messageId":"AANLkTi=upKKahxpu5918yxW+J6nHWMvPfonJNB=yuCTy@mail.gmail.com","threadId":"25264","inReplyTo":"1285649564-24737-1-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH] commit: do not switch branch during a rebase unless -f is given","fromName":"Sverre Rabbelier","fromEmail":"srabbelier@gmail.com","sentAt":"2010-09-28T11:24:59Z","receivedAt":"2010-09-28T11:24:59Z","isPatch":true,"sender":{"key":"srabbelier@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3098?v=4"},"body":"Heya,\n\n2010/9/28 Nguyễn Thái Ngọc Duy <pclouds@gmail.com>:\n> +               die(\"You should not switch branch during a rebase. Use '-f' if you really want to.\");\n\nOn top of Junio's comments, I think it makes sense here to add \"or use\n'git rebase --abort' to abort the rebase that is in progress\".\n\n-- \nCheers,\n\nSverre Rabbelier\n"},{"id":"155487","messageId":"AANLkTinKNF6OEX=k1aepD-Zrm2_4GzHaB+SVHdfTMG-j@mail.gmail.com","threadId":"25264","inReplyTo":"AANLkTin19PREB3B68s+ejsgtXwe3CBxZF-caCvRp4UXv@mail.gmail.com","subject":"Re: [PATCH] checkout: do not switch branch during a rebase unless -f is given","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-11-09T13:40:06Z","receivedAt":"2010-11-09T13:40:06Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"2010/9/28 Nguyen Thai Ngoc Duy <pclouds@gmail.com>:\n>> Even rebase --interactive uses checkout from time to time:\n>>\n>>  - for preserving merges\n>>  - to move to the correct branch in response to \"git rebase -i\n>> <upstream> <branch>\"\n>>  - to move to the target in \"git rebase -i --onto <new base> <upstream>\"\n>>\n>> Unfortunately I do not have any good advice. Would it make sense to\n>>\n>>  - first, change these call sites in git to use checkout -f\n>>  - teach checkout to warn (without erroring out) to give people time\n>> to change their scripts\n>>  - warn loudly about the upcoming change in the release notes\n>>  - later, change checkout to error out when -f is not supplied\n>>\n>> or am I being too paranoid?\n>\n> No. But I don't like the idea of making scripts use \"checkout -f\". My\n> intention was to stop users from doing that, not scripts. Putting \"-f\"\n> everywhere might have more negative side effects.\n>\n> Maybe adding \"--porcelain\" to checkout first, updating scripts to use\n> it, then only check for rebase/bisect/am when --porcelain is missing.\n\nAnother approach is to let checkout work as usual, but refuse update refs:\n\n - after rebase starts, HEAD can only be updated either by rebase, or\nany commands that keep HEAD a headless ref.\n - the branch being rebased is locked. No commands but rebase can update it.\n\nI think the second point is good for all interactive commands like\nrebase. Create a .lock file with a signature inside (e.g. command\nname). If update_ref() callers do not give correct signature, refuse\nto update.\n-- \nDuy\n"},{"id":"155489","messageId":"20101109140615.GA18960@burratino","threadId":"25264","inReplyTo":"AANLkTinKNF6OEX=k1aepD-Zrm2_4GzHaB+SVHdfTMG-j@mail.gmail.com","subject":"Re: [PATCH] checkout: do not switch branch during a rebase unless -f is given","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-11-09T14:06:15Z","receivedAt":"2010-11-09T14:06:15Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Nguyen Thai Ngoc Duy wrote:\n\n> Another approach is to let checkout work as usual, but refuse update refs:\n> \n>  - after rebase starts, HEAD can only be updated either by rebase, or\n> any commands that keep HEAD a headless ref.\n>  - the branch being rebased is locked. No commands but rebase can update it.\n> \n> I think the second point is good for all interactive commands like\n> rebase. Create a .lock file with a signature inside (e.g. command\n> name). If update_ref() callers do not give correct signature, refuse\n> to update.\n\nI like it.  Would it be possible to make sure the (widespread?) practice\nof using\n\n\trm -fr .git/rebase-merge\n\nto terminate a rebase without going back to the original branch\nstill works?  I think it should be.\n"},{"id":"155490","messageId":"AANLkTi=2q1-1zmR=JquN75DP9sGGuPVkAu4mVs1U9DZo@mail.gmail.com","threadId":"25264","inReplyTo":"20101109140615.GA18960@burratino","subject":"Re: [PATCH] checkout: do not switch branch during a rebase unless -f is given","fromName":"Sverre Rabbelier","fromEmail":"srabbelier@gmail.com","sentAt":"2010-11-09T14:11:42Z","receivedAt":"2010-11-09T14:11:42Z","isPatch":true,"sender":{"key":"srabbelier@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3098?v=4"},"body":"Heya,\n\n2010/11/9 Jonathan Nieder <jrnieder@gmail.com>:\n> I like it.  Would it be possible to make sure the (widespread?) practice\n> of using\n>\n>        rm -fr .git/rebase-merge\n\nAwr, and here I was, all hopeful reading your message up to here.\n\n> to terminate a rebase without going back to the original branch\n> still works?  I think it should be.\n\nAnd then here you smash my hopes that you were suggesting we stop\nasking the user to mess around in the .git directory :(. After all, if\nwe let that rm be handled by some 'git rebase' mode, it could also\nunlock any branches it has locked.\n\n-- \nCheers,\n\nSverre Rabbelier\n"},{"id":"155491","messageId":"AANLkTi=VtP=T7PwY-PcZ9sHy0FjU8Nj=Fe1eWc44Q+OE@mail.gmail.com","threadId":"25264","inReplyTo":"20101109140615.GA18960@burratino","subject":"Re: [PATCH] checkout: do not switch branch during a rebase unless -f is given","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-11-09T14:15:02Z","receivedAt":"2010-11-09T14:15:02Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"2010/11/9 Jonathan Nieder <jrnieder@gmail.com>:\n> Nguyen Thai Ngoc Duy wrote:\n>\n>> Another approach is to let checkout work as usual, but refuse update refs:\n>>\n>>  - after rebase starts, HEAD can only be updated either by rebase, or\n>> any commands that keep HEAD a headless ref.\n>>  - the branch being rebased is locked. No commands but rebase can update it.\n>>\n>> I think the second point is good for all interactive commands like\n>> rebase. Create a .lock file with a signature inside (e.g. command\n>> name). If update_ref() callers do not give correct signature, refuse\n>> to update.\n>\n> I like it.  Would it be possible to make sure the (widespread?) practice\n> of using\n>\n>        rm -fr .git/rebase-merge\n>\n> to terminate a rebase without going back to the original branch\n> still works?  I think it should be.\n>\n\nI don't know. If we can place the branch lock inside\n.git/rebase-merge, then yes removing that directory will also remove\nthe lock. But how does git find the locks if they are everywhere in\n.git?\n-- \nDuy\n"},{"id":"155492","messageId":"20101109143601.GB18960@burratino","threadId":"25264","inReplyTo":"AANLkTi=2q1-1zmR=JquN75DP9sGGuPVkAu4mVs1U9DZo@mail.gmail.com","subject":"Re: [PATCH] checkout: do not switch branch during a rebase unless -f is given","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-11-09T14:36:01Z","receivedAt":"2010-11-09T14:36:01Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Sverre Rabbelier wrote:\n\n> And then here you smash my hopes that you were suggesting we stop\n> asking the user to mess around in the .git directory :(. After all, if\n> we let that rm be handled by some 'git rebase' mode, it could also\n> unlock any branches it has locked.\n\nWell, I think that is worth doing, too.  It's just that it's hard to\nchange existing practices and much easier to change the tools to\nkeep supporting them.\n\nI don't think the manual advertises .git/rebase-merge anywhere.  I\nhave witnessed people succumbing to the temptation to delete it when\nanother rebase fails.\n\nMaybe \"git rebase\" should have a --override-rebase-in-progress option?\nThe following is simpler, sort of imitating the \"git bisect reset\"\ncommand.  With it applied, if you do\n\n\tgit rebase --abort HEAD\n\nthen the rebase will abort without changing the current HEAD (yes,\nI know this interface is stupid; please feel free to pick it up\nand do better).\n\nOther practices worth abstracting away:\n\n\t- Reading .git/rebase-merge/patch and\n\t  .git/rebase-merge/message when a patch had conflicts\n\t- Checking for the existence of .git/rebase-merge in $PS1\n\t  prompt\n\t- Tweaking .git/rebase-merge/todo to reflect a change of plan\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\ndiff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt\nindex 30e5c0e..3a587a1 100644\n--- a/Documentation/git-rebase.txt\n+++ b/Documentation/git-rebase.txt\n@@ -227,6 +227,9 @@ leave out at most one of A and B, in which case it defaults to HEAD.\n --abort::\n \tRestore the original branch and abort the rebase operation.\n \n+--abort HEAD::\n+\tAbort the rebase operation, without changing the current branch.\n+\n --skip::\n \tRestart the rebasing process by skipping the current patch.\n \ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex a27952d..2e1c074 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -772,6 +772,14 @@ first and then run 'git rebase --continue' again.\"\n \t\tdo_rest\n \t\t;;\n \t--abort)\n+\t\tif test \"$2\" = HEAD\n+\t\tthen\n+\t\t\tshift\n+\t\t\tis_standalone \"$@\" || usage\n+\t\t\tget_saved_options\n+\t\t\trm -rf \"$DOTEST\"\n+\t\t\texit\n+\t\tfi\n \t\tis_standalone \"$@\" || usage\n \t\tget_saved_options\n \t\tcomment_for_reflog abort\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex e5df23b..0f88a00 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -273,6 +273,11 @@ do\n \t\ttest -d \"$dotest\" -o -d \"$GIT_DIR\"/rebase-apply ||\n \t\t\tdie \"No rebase in progress?\"\n \n+\t\tif test \"$2\" = HEAD\n+\t\tthen\n+\t\t\trm -r \"$dotest\"\n+\t\t\texit\n+\t\tfi\n \t\tgit rerere clear\n \t\tif test -d \"$dotest\"\n \t\tthen\n"},{"id":"155493","messageId":"20101109143816.GC18960@burratino","threadId":"25264","inReplyTo":"AANLkTi=VtP=T7PwY-PcZ9sHy0FjU8Nj=Fe1eWc44Q+OE@mail.gmail.com","subject":"Re: [PATCH] checkout: do not switch branch during a rebase unless -f is given","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-11-09T14:38:16Z","receivedAt":"2010-11-09T14:38:16Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Nguyen Thai Ngoc Duy wrote:\n\n> I don't know. If we can place the branch lock inside\n> .git/rebase-merge, then yes removing that directory will also remove\n> the lock. But how does git find the locks if they are everywhere in\n> .git?\n\nCould the lock signature say something to the effect that \"this lock\nis only valid against commands that don't declare this signature, and\nonly so long as .git/rebase-merge/ref has such-and-such content\"?\n"}]}