git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Bug Report: "git reset --hard" does not cancel an on-going rebase
@ 2020-08-31 21:59 Thomas Bétous
  2020-08-31 23:11 ` Junio C Hamano
  0 siblings, 1 reply; 2+ messages in thread
From: Thomas Bétous @ 2020-08-31 21:59 UTC (permalink / raw)
  To: git

Hello,

I 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.
When 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.
I 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.

The issue can be reproduced with the following commands:
# First trigger a rebase that will paused because of a conflict
# (there is probably a simpler way to end up in this use case)
$ git init test-repo-rebase-reset
$ cd test-repo-rebase-reset/
$ touch file
$ git add file
$ git commit file -m 'First commit’
$ echo "dummy line" > file
$ git commit --all -m 'Second commit’
$ git switch --create new-branch HEAD~1
$ git rm file
$ git commit -m 'Remove file’
$ git rebase master
# Let’s check that the rebase got paused because of the conflict
$ git status
$ git reset --hard
# Even after the “git reset --hard“ the rebase was not aborted
$ git status
# Now let’s check what happens with the cherry-pick command
$ git rebase --abort
$ git switch master
$ git cherry-pick $(git rev-parse -1 new-branch)
# The cherry-pick got paused because of the same conflict
git status
# Let’s try to abort the cherry-pick with the reset command
git reset --hard
# Double check the cherry-pick was aborted
git status

I 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

Note 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.

What do you think? Does this behavior seems normal to you?

Thank you in advance for your answer.

Best regards,

Thomas

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Bug Report: "git reset --hard" does not cancel an on-going rebase
  2020-08-31 21:59 Bug Report: "git reset --hard" does not cancel an on-going rebase Thomas Bétous
@ 2020-08-31 23:11 ` Junio C Hamano
  0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2020-08-31 23:11 UTC (permalink / raw)
  To: Thomas Bétous; +Cc: git

Thomas Bétous <th.betous@gmail.com> writes:

> I 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.
> When 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.  I 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.

It is reasonable and desirable for multi-commit operations like
"rebase", "cherry-pick A..B" and "revert A..B" not to abort the
entire sequence with a mere "reset --hard".  After a step resulted
in conflicts, the user may try to resolve them, getting into too
deep a hole by botching resolution, and wish to redo the current
step from scratch, and "reset --hard" can be a way to clean the
slate before recreating the same conflict.  To abort the whole
thing, "rebase --abort" and "cherry-pick --abort" would be needed
to differentiate from the "clean this single step" request made with
"reset --hard".

On the other hand, operations on a single commit like "cherry-pick
X" does not have to retain "what to do after we have dealt with the
current step", so "reset --hard" that finishes the whole thing
(after all, the whole thing is the single step that may have
conflicted) would just be a convenient short-hand.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-08-31 23:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-31 21:59 Bug Report: "git reset --hard" does not cancel an on-going rebase Thomas Bétous
2020-08-31 23:11 ` Junio C Hamano

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).