git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: "René Scharfe" <rene.scharfe@lsrfire.ath.cx>
Cc: funeeldy <Marlene_Cote@affirmednetworks.com>, git@vger.kernel.org
Subject: Re: git checkout no longer warning about uncommitted/untracked files!
Date: Mon, 23 May 2011 17:10:42 -0400	[thread overview]
Message-ID: <20110523211042.GC6281@sigill.intra.peff.net> (raw)
In-Reply-To: <4DDAC57D.9020809@lsrfire.ath.cx>

On Mon, May 23, 2011 at 10:37:17PM +0200, René Scharfe wrote:

> 	$ echo 1 >a
> 	$ git add a
> 	$ git commit -m.
> 	[master (root-commit) b0e60d3] .
> 	 1 files changed, 1 insertions(+), 0 deletions(-)
> 	 create mode 100644 a
> 
> 	$ git branch x
> 	$ echo uncommitted >a
> 	$ echo untracked >b
> 
> 	$ git checkout x
> 	M	a
> 	Switched to branch 'x'

But you're not actually switching trees here, so there is by definition
no merge that needs to happen, and the changes stay in place.

> 	$ cat a
> 	uncommitted
> 	$ cat b
> 	untracked

And here, there is no contention over "b" since git would never need to
write it at all.

A better test would be:

  git init repo && cd repo
  echo 1 >a && git add a && git commit -m a1
  echo 2 >a && git add a && git commit -m a2

  git checkout -b check-uncommitted master^
  # should fail because we would have to merge
  echo 3 >a && git checkout master

  git checkout -f master
  echo 4 >b && git add b && git commit -m b4
  git checkout -b check-untracked master^
  echo untracked >b
  # should fail because we would overwrite untracked b
  git checkout master

And indeed, testing with v1.7.3., both of my "should fail" checkouts do
fail, with the following messages respectively:

  error: Your local changes to the following files would be overwritten by checkout:
        a
  Please, commit your changes or stash them before you can switch branches.
  Aborting

and

  error: The following untracked working tree files would be overwritten by checkout:
        b
  Please move or remove them before you can switch branches.
  Aborting

So I still don't know what the bug is.

-Peff

  reply	other threads:[~2011-05-23 21:10 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-23 17:29 git checkout no longer warning about uncommitted/untracked files! funeeldy
2011-05-23 20:37 ` René Scharfe
2011-05-23 21:10   ` Jeff King [this message]
2011-05-23 21:05 ` funeeldy
2011-05-23 21:17   ` funeeldy
2011-05-23 21:18     ` Jeff King
2011-05-23 21:27       ` Marlene Cote
2011-05-23 21:18   ` Jeff King

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=20110523211042.GC6281@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=Marlene_Cote@affirmednetworks.com \
    --cc=git@vger.kernel.org \
    --cc=rene.scharfe@lsrfire.ath.cx \
    /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).