From: Jeff King <peff@peff.net>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: Re: [BUG?] git checkout $commit -- somedir doesn't drop files
Date: Tue, 17 Sep 2013 16:10:04 -0400 [thread overview]
Message-ID: <20130917201003.GA16860@sigill.intra.peff.net> (raw)
In-Reply-To: <20130917190659.GA15588@pengutronix.de>
On Tue, Sep 17, 2013 at 09:06:59PM +0200, Uwe Kleine-König wrote:
> $ 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:
I'm not sure if this is intentional or not. The definition of "git
checkout $tree $path" given in commit 0a1283b says:
Checking paths out of a tree is (currently) defined to do:
- Grab the paths from the named tree that match the given pathspec,
and add them to the index;
- Check out the contents from the index for paths that match the
pathspec to the working tree; and while at it
- If the given pathspec did not match anything, suspect a typo from the
command line and error out without updating the index nor the working
tree.
So we are applying the pathspec to the named tree, and pulling anything
that matches into the index. Which by definition cannot involve a
deletion, because there is no comparison happening (so we either have
it, or we do not). Whereas what you are expecting is to compare the tree
and the index, limited by the pathspec, and pull any changes from the
tree into the index.
I tend to agree that the latter is more like how other git commands
behave (e.g., if you tried to use "read-tree" to emulate what
git-checkout was doing, I think you would end up with a two-way merge).
But there may be implications I haven't thought of.
Note also that "git checkout -p" does present "subdir/b" as a deletion.
It works by doing a pathspec-limited diff between the two endpoints,
which will notice deletions. So there is some inconsistency there with
the baseline form.
-Peff
prev parent reply other threads:[~2013-09-17 20:10 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
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 [this message]
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=20130917201003.GA16860@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--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 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).