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 1/2] diff --cached: do not report i-t-a entries as "new"
Date: Sat, 14 Mar 2015 23:55:09 -0700 [thread overview]
Message-ID: <xmqqmw3evjg2.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <1425910445-27383-2-git-send-email-pclouds@gmail.com> ("Nguyễn Thái Ngọc Duy"'s message of "Mon, 9 Mar 2015 21:14:04 +0700")
Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
> Paths marked by "git add -N" are simply a reminder to the user that
> these files should be staged. If the user does not stage any of them,
> "git commit" will not record them.
>
> Align the behavior of "diff --cached" and "git commit". The most
> prominent result of this patch is "git status" no longer reports i-t-a
> paths as "Changes to be committed".
>
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
> diff-lib.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/diff-lib.c b/diff-lib.c
> index a85c497..db0e6f8 100644
> --- a/diff-lib.c
> +++ b/diff-lib.c
> @@ -400,6 +400,8 @@ static void do_oneway_diff(struct unpack_trees_options *o,
> * Something added to the tree?
> */
> if (!tree) {
> + if (idx && (idx->ce_flags & CE_INTENT_TO_ADD))
> + return;
> show_new_file(revs, idx, cached, match_missing);
> return;
> }
This hunk by itself feels like it is going in the right direction.
The HEAD does not have it, and even though there is idx, it merely
is an i-t-a entry.
Don't you need to special case the call to show_modified() at the
end of this function as well, though? idx is i-t-a, and tree has a
concrete object. Should it appear as if the path already exists in
the index, or should we pretend as if idx is not yet there?
For example, after this sequence:
$ git init
$ >void
$ git add void
$ git commit -m void
$ git rm --cached void
$ git add -N void
HEAD has "void" with an empty blob, the index has i-t-a. I am not
sure if we should say something about path "void" when asked:
$ git diff --cached
Perhaps something like this to cover that case?
/*
* Something removed from the tree?
*/
- if (!idx) {
+ if (!idx || (ix->ce_flags & CE_INTENT_TO_ADD)) {
diff_index_show_file(revs, "-", tree, tree->sha1, 1, tree->ce_mode, 0);
return;
}
next prev parent reply other threads:[~2015-03-15 6:55 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-09 14:14 [PATCH/RFC 0/2] Bug fixes regarding diff and "git add -N" Nguyễn Thái Ngọc Duy
2015-03-09 14:14 ` [PATCH 1/2] diff --cached: do not report i-t-a entries as "new" Nguyễn Thái Ngọc Duy
2015-03-15 6:55 ` Junio C Hamano [this message]
2015-03-16 13:56 ` [PATCH v2] diff-lib.c: adjust position of i-t-a entries in diff Nguyễn Thái Ngọc Duy
2015-03-16 15:15 ` Michael J Gruber
2015-03-16 16:05 ` Junio C Hamano
2015-03-17 14:07 ` Duy Nguyen
2015-03-17 17:57 ` Junio C Hamano
2015-03-18 12:47 ` Duy Nguyen
2015-03-18 20:30 ` Junio C Hamano
2015-03-19 6:00 ` Junio C Hamano
2015-03-24 1:15 ` Duy Nguyen
2015-03-24 17:00 ` Junio C Hamano
2015-03-23 20:52 ` Junio C Hamano
2015-03-09 14:14 ` [PATCH 2/2] diff-files: mark i-t-a paths as "new" Nguyễn Thái Ngọc Duy
2015-03-15 7:05 ` Junio C Hamano
2015-03-09 15:45 ` [PATCH] t2203,t4011: adjust to changed intent-to-add treatment Michael J Gruber
2015-03-15 7:07 ` 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=xmqqmw3evjg2.fsf@gitster.dls.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 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).