From: Junio C Hamano <gitster@pobox.com>
To: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] unpack-trees: do not delete i-t-a entries in worktree even when forced
Date: Wed, 24 Feb 2016 15:23:04 -0800 [thread overview]
Message-ID: <xmqq60xdsnfr.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <xmqqa8mpsom6.fsf@gitster.mtv.corp.google.com> (Junio C. Hamano's message of "Wed, 24 Feb 2016 14:57:37 -0800")
Junio C Hamano <gitster@pobox.com> writes:
> Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
>
>> Intent-to-add entries are basically "I may want to commit these files
>> later, but for now they are untracked". As such, when the user does "git
>> reset --hard <tree>", which removes i-t-a entries from the index, i-t-a
>> entries in worktree should be kept as untracked.
>
> Hmm, I can see that the control flow of "reset --hard" for an i-t-a
> path does pass through this function, but it is not very obvious
> to see how this will not negatively affect other uses of the
> unpack-trees machinery (e.g. "checkout" and "merge", especially when
> such a path needs to turn into a directory by getting removed).
>
Thinking about it more, I have to say that I do not agree with the
basic premise of this patch. I-T-A is not "may want to commit, but
they are untracked" at all. It is "I know I want to add, I just
cannot yet decide the exact contents".
That is why "git add -N newfile && git grep string" would find the
string from newfile, and "git add -N newfile && git diff HEAD newfile"
would show the addition.
Sane people would expect that "git reset --hard HEAD" would behave
as "git diff HEAD | git apply --index -R" when your index is fully
merged, but this change will break the expectation.
Earlier we changed "git commit" to pretend as if an I-T-A entry does
not exist in "git add -N newfile && git commit", but I think that
was a mistake that was caused by the same fuzzy thinking.
3f6d56de (commit: ignore intent-to-add entries instead of refusing,
2012-02-07) does talk about the use of "git add -N" in conjunction
with "git status" and "git diff", but somehow nobody realized that
it was introducing inconsistency in the semantics.
next prev parent reply other threads:[~2016-02-24 23:23 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-24 11:45 [PATCH] unpack-trees: do not delete i-t-a entries in worktree even when forced Nguyễn Thái Ngọc Duy
2016-02-24 22:57 ` Junio C Hamano
2016-02-24 23:23 ` Junio C Hamano [this message]
2016-02-25 10:45 ` Duy Nguyen
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=xmqq60xdsnfr.fsf@gitster.mtv.corp.google.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=pclouds@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 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.