Re: [PATCH] checkout: special case error messages during noop switching
- From
Martin von Zweigbergk <martinvonz@gmail.com>
- Date
- Jul 17, 2024, 16:05 UTC
- Message-ID
- <CANiSa6hs1AEp1e+o0hT55DvCwPe2EUyU1EXg1E4BKCkeuEOPvw@mail.gmail.com>
- In-Reply-To
- <xmqqikxnqzz4.fsf@gitster.g>
Thanks! (This is a fix for a bug I reported internally at work.)
On Tue, Jul 2, 2024 at 10:52 PM Junio C Hamano <gitster@pobox.com> wrote:
Show 7 quoted lines
> > "git checkout" ran with no branch and no pathspec behaves like > switching the branch to the current branch (in other words, a > no-op, except that it gives a side-effect "here are the modified > paths" report). But unlike "git checkout HEAD" or "git checkout > main" (when you are on the 'main' branch), the user is much less > conscious that they are "switching" to the current branch.
Yes, that's exactly what happened to me. I should have used `git restore` instead. I know that's the modern way of updating paths, so I don't know why I didn't think of it. I just verified that `git restore --ours <path>` works for restoring a conflicted file to my side.
Show 5 quoted lines
> [Footnote] > > * Yes, the end-users are irrational. When they did not give > "--ours", they take it granted that "git checkout" gives a short > status, e.g..
I actually did not even know that it does that :) I'm a bit surprised that it does, especially since `git checkout <non-HEAD>` doesn't seem to do that. But that's off topic.