Subject: Re: [PATCH 14/17] reset: Make hard reset remove the sequencer state

From: Jonathan Nieder <[email-masked]>
Date: Tue, 12 Jul 2011 15:15:32 -0500

Hi,

Ramkumar Ramachandra wrote:

> Years of muscle memory have trained users to use "git reset --hard" to
> remove away the branch state after any sort of operation.  In
> retrospect, while this may not have been the best design decision, we
> are stuck with it for historical reasons.

Wait, wait!  If that was a bad design decision, we should try to find
a way to smoothly transition to a world without it, instead of
layering workarounds on top of it.

But actually I think it is good UI.  When you do "git merge", it works
like this:

	git merge <foo>; # conflicts!
	... hack hack hack ...
	# Oh, bother, let me go back to a state I know well and am
	# comfortable with.
	git reset --hard <bar>

And the same psychological effect applies in the cherry-pick case:

	git cherry-pick <foo>; # conflicts!
	... hack hack hack ...
	# Oh, bother, let me go back to a state I know well and am
	# comfortable with.
	git reset --hard <bar>

See, it's about the tool working with you.  When I abandon a merge,
I don't want to have to search through the owner's manual for the
button to get git to clear away this unpleasant and unfamiliar state.

Now, by contrast, sometimes one wants something less aggressive.
For example, to abandon a partial merge conflict resolution but
keep unrelated changes in the worktree:

	git reset --merge HEAD

Or to get out of the "mergy" state but leave the worktree alone:

	git reset

There's no porcelain or plumbing to abandon a rebase without
additional side-effects, but "git status" suggests a command for
it if I remember correctly.

	rm -fr .git/rebase-merge

[...]
> Additionally, this patch ensures that some existing tests don't break
> when features like "--reset" and "--continue" are introduced later in
> the series.

That's not "Additionally" --- it's the same problem.  One way to
phrase it would be "Noticed by running such-and-such test after
such-and-such change".

> +test_expect_success 'reset --hard cleans up sequencer state' '

Hoorah!  Thanks.

Why isn't the .git/sequencer removal in remove_branch_state() like
MERGE_MSG and other similar examples are?  (Not a rhetorical question;
it would be interesting to know.)