{"thread":{"id":"54168","subject":"Bug Report: \"git reset --hard\" does not cancel an on-going rebase","startedAt":"2020-08-31T21:59:46Z","lastAt":"2020-08-31T23:11:53Z","messageCount":2,"participants":["Thomas Bétous","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"404832","messageId":"34B7EFB9-8710-4993-ACCD-604313D543E7@gmail.com","threadId":"54168","inReplyTo":null,"subject":"Bug Report: \"git reset --hard\" does not cancel an on-going rebase","fromName":"Thomas Bétous","fromEmail":"th.betous@gmail.com","sentAt":"2020-08-31T21:59:38Z","receivedAt":"2020-08-31T21:59:46Z","isPatch":false,"sender":{"key":"th.betous@gmail.com","avatar":null},"body":"Hello,\n\nI would like to report an inconsistent behavior of the rebase/reset commands. I don’t know whether it is an actual bug or something else but according to me something is not right.\nWhen a rebase gets paused (because of a conflict for instance) I would expect the command \"git reset --hard\" to cancel this on-going rebase but it does not.\nI expect this because for instance \"git reset --hard\" cancels a cherry-pick in the same use case so I think the behavior of these 2 commands should be consistent.\n\nThe issue can be reproduced with the following commands:\n# First trigger a rebase that will paused because of a conflict\n# (there is probably a simpler way to end up in this use case)\n$ git init test-repo-rebase-reset\n$ cd test-repo-rebase-reset/\n$ touch file\n$ git add file\n$ git commit file -m 'First commit’\n$ echo \"dummy line\" > file\n$ git commit --all -m 'Second commit’\n$ git switch --create new-branch HEAD~1\n$ git rm file\n$ git commit -m 'Remove file’\n$ git rebase master\n# Let’s check that the rebase got paused because of the conflict\n$ git status\n$ git reset --hard\n# Even after the “git reset --hard“ the rebase was not aborted\n$ git status\n# Now let’s check what happens with the cherry-pick command\n$ git rebase --abort\n$ git switch master\n$ git cherry-pick $(git rev-parse -1 new-branch)\n# The cherry-pick got paused because of the same conflict\ngit status\n# Let’s try to abort the cherry-pick with the reset command\ngit reset --hard\n# Double check the cherry-pick was aborted\ngit status\n\nI think the behavior will be the same on all OS but if it helps I was able to reproduce it on Cygwin/Windows 10 with git 2.28.0 and Mac OS with git 2.26.0\n\nNote that in the commands above I didn’t give any revision to the reset command but the issue would be the same if I did. Moreover it makes it even more confusing I think: you can move your HEAD to any revision while the rebase is still waiting to be completed.\n\nWhat do you think? Does this behavior seems normal to you?\n\nThank you in advance for your answer.\n\nBest regards,\n\nThomas"},{"id":"404834","messageId":"xmqqimcye7gu.fsf@gitster.c.googlers.com","threadId":"54168","inReplyTo":"34B7EFB9-8710-4993-ACCD-604313D543E7@gmail.com","subject":"Re: Bug Report: \"git reset --hard\" does not cancel an on-going rebase","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-08-31T23:11:45Z","receivedAt":"2020-08-31T23:11:53Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thomas Bétous <th.betous@gmail.com> writes:\n\n> I would like to report an inconsistent behavior of the\n> rebase/reset commands. I don’t know whether it is an actual bug\n> or something else but according to me something is not right.\n> When a rebase gets paused (because of a conflict for instance) I\n> would expect the command \"git reset --hard\" to cancel this\n> on-going rebase but it does not.  I expect this because for\n> instance \"git reset --hard\" cancels a cherry-pick in the same use\n> case so I think the behavior of these 2 commands should be\n> consistent.\n\nIt is reasonable and desirable for multi-commit operations like\n\"rebase\", \"cherry-pick A..B\" and \"revert A..B\" not to abort the\nentire sequence with a mere \"reset --hard\".  After a step resulted\nin conflicts, the user may try to resolve them, getting into too\ndeep a hole by botching resolution, and wish to redo the current\nstep from scratch, and \"reset --hard\" can be a way to clean the\nslate before recreating the same conflict.  To abort the whole\nthing, \"rebase --abort\" and \"cherry-pick --abort\" would be needed\nto differentiate from the \"clean this single step\" request made with\n\"reset --hard\".\n\nOn the other hand, operations on a single commit like \"cherry-pick\nX\" does not have to retain \"what to do after we have dealt with the\ncurrent step\", so \"reset --hard\" that finishes the whole thing\n(after all, the whole thing is the single step that may have\nconflicted) would just be a convenient short-hand.\n\n"}]}