git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Martin von Zweigbergk <martinvonz@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] checkout: special case error messages during noop switching
Date: Wed, 17 Jul 2024 09:15:03 -0700	[thread overview]
Message-ID: <xmqqttgo3shk.fsf@gitster.g> (raw)
In-Reply-To: <CANiSa6hs1AEp1e+o0hT55DvCwPe2EUyU1EXg1E4BKCkeuEOPvw@mail.gmail.com> (Martin von Zweigbergk's message of "Wed, 17 Jul 2024 18:05:13 +0200")

Martin von Zweigbergk <martinvonz@gmail.com> 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.

  reply	other threads:[~2024-07-17 16:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-02 20:51 [PATCH] checkout: special case error messages during noop switching Junio C Hamano
2024-07-17 16:05 ` Martin von Zweigbergk
2024-07-17 16:15   ` Junio C Hamano [this message]
2024-07-17 23:38   ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqttgo3shk.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=martinvonz@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 NNTP newsgroup(s).