Subject: Re: [PATCH] checkout: special case error messages during noop switching

From: Junio C Hamano <[email-masked]>
Date: Wed, 17 Jul 2024 09:15:03 -0700

Martin von Zweigbergk <[email-masked]> writes:

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

It does but you wouldn't know unless you have modified paths.

Also checkout and switch would only allow checking out another
branch when these modified paths are the same between the original
HEAD and the other branch.

        $ git reset --hard
        $ echo >>GIT-VERSION-GEN
        $ git checkout
	M       GIT-VERSION-GEN

With a modified file, no-op checkout, report only.

	$ git checkout next
	M       GIT-VERSION-GEN
	Switched to branch 'next'

With a modified file, checkout another branch, with report.

	$ git checkout maint
	error: Your local changes to the following files would be overwritten...
		GIT-VERSION-GEN
	Please commit your changes or stash them...

With a modified file, that is different between next and maint, fail
to checkout the other branch.