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 2/2] diff-files: mark i-t-a paths as "new"
Date: Sun, 15 Mar 2015 00:05:45 -0700 [thread overview]
Message-ID: <xmqqioe2viye.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <1425910445-27383-3-git-send-email-pclouds@gmail.com> ("Nguyễn Thái Ngọc Duy"'s message of "Mon, 9 Mar 2015 21:14:05 +0700")
Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
> builtin/add.c | 1 +
> diff-lib.c | 5 +++++
> 2 files changed, 6 insertions(+)
>
> diff --git a/builtin/add.c b/builtin/add.c
> index 3390933..ee370b0 100644
> --- a/builtin/add.c
> +++ b/builtin/add.c
> @@ -63,6 +63,7 @@ static void update_callback(struct diff_queue_struct *q,
> switch (fix_unmerged_status(p, data)) {
> default:
> die(_("unexpected diff status %c"), p->status);
> + case DIFF_STATUS_ADDED:
> case DIFF_STATUS_MODIFIED:
> case DIFF_STATUS_TYPE_CHANGED:
> if (add_file_to_index(&the_index, path, data->flags)) {
Is this related to making "diff-files" show an i-t-a as "new", or
something else?
Ahh, "added" would have never appeared in diff-files output (because
by definition comparing index and working tree for only paths known
to the index would never produce "add"), and the point of this series
is to use that status to signal that the path is marked as i-t-a.
And an i-t-a path is "not yet exist in the index, known to the
system, and exists in the working tree", so catching that new case
here and calling add_file_to_index() would cause such a path to be
truly added to the index (this is "add -u" codepath, right?).
Makes sense.
> diff --git a/diff-lib.c b/diff-lib.c
> index db0e6f8..5f1afa4 100644
> --- a/diff-lib.c
> +++ b/diff-lib.c
> @@ -212,6 +212,11 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
> ce->sha1, !is_null_sha1(ce->sha1),
> ce->name, 0);
> continue;
> + } else if (ce->ce_flags & CE_INTENT_TO_ADD) {
> + diff_addremove(&revs->diffopt, '+', ce->ce_mode,
> + EMPTY_BLOB_SHA1_BIN, 0,
> + ce->name, 0);
> + continue;
> }
>
> changed = match_stat_with_submodule(&revs->diffopt, ce, &st,
And this makes sense, of course.
The way "add -N" entries appear in "git status" has been disturbing
for quite a while to me, too. Thanks for starting to look into it.
next prev parent reply other threads:[~2015-03-15 7:06 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
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 [this message]
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=xmqqioe2viye.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 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.