From: Junio C Hamano <gitster@pobox.com>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: git@vger.kernel.org
Subject: Re: [BUG?] git checkout $commit -- somedir doesn't drop files
Date: Tue, 17 Sep 2013 12:58:07 -0700 [thread overview]
Message-ID: <xmqqeh8nxltc.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <20130917190659.GA15588@pengutronix.de> ("Uwe Kleine-König"'s message of "Tue, 17 Sep 2013 21:06:59 +0200")
Uwe Kleine-König <u.kleine-koenig@pengutronix.de> writes:
> after these commands:
>
> $ git init
> $ mkdir subdir
> $ echo a > subdir/a
> $ git add subdir/a
> $ git commit -m a
> $ echo more a >> subdir/a
> $ echo b > subdir/b
> $ git add subdir/*
> $ git commit -m b
> $ git checkout HEAD^ -- subdir
>
> I'd expect that subdir/b is removed from the index as this file didn't
> exist in HEAD^ but git-status only reports:
>
> # On branch master
> # Changes to be committed:
> # (use "git reset HEAD <file>..." to unstage)
> #
> # modified: subdir/a
> #
>
> Is this intended?
>
> (I'm using git 1.8.4.rc3 as shipped by Debian (package version
> 1:1.8.4~rc3-1).)
The intended behaviour of "git checkout tree-ish -- pathspec" has
always been "grab paths that match pathspec from tree-ish, add them
to the index and check them out to the working tree". If you have
subdir/b in the index and the working tree, it will be kept when the
paths that match "subdir" pathspec is grabbed out of the tree-ish
HEAD^ (namely, subdir/a) is added to the index and to the working
tree.
I could argue that the above intended behaviour is suboptimal and it
should have been "the resulting paths in the index and the work tree
that match the given pathspec must be identical to that of the
tree-ish". In the resulting index or working tree, paths that match
"subdir" pathspec in the above result is subdir/a and subdir/b, and
that is different from what exists in the given tree-ish (which has
only subdir/a and not subdir/b), and under that modified definition,
what the current one does is not correct.
I vaguely recall arguing for the updated behaviour described in the
above paragraph, and I even might have started working on it, but I
do not think we changed this behaviour recently, unfortunately.
next prev parent reply other threads:[~2013-09-17 19:58 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-17 19:06 [BUG?] git checkout $commit -- somedir doesn't drop files Uwe Kleine-König
2013-09-17 19:58 ` Junio C Hamano [this message]
2013-09-17 20:13 ` Jeff King
2013-09-17 20:27 ` Junio C Hamano
2013-09-17 20:29 ` Jeff King
2013-09-17 20:40 ` Junio C Hamano
2013-09-17 21:21 ` Jeff King
2013-09-17 22:00 ` Junio C Hamano
2013-09-17 22:03 ` Jeff King
2013-09-17 22:14 ` Junio C Hamano
2013-09-19 7:46 ` Jeff King
2013-09-19 18:02 ` Junio C Hamano
2013-09-19 22:13 ` Jeff King
2013-09-20 22:54 ` Junio C Hamano
2013-09-17 20:10 ` 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=xmqqeh8nxltc.fsf@gitster.dls.corp.google.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=u.kleine-koenig@pengutronix.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.