git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: pclouds@gmail.com
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>,
	Jonathan Nieder <jrnieder@gmail.com>
Subject: [PATCH v2 1/4] diff: ignore --ita-[in]visible-in-index when diffing worktree-to-tree
Date: Sat, 26 May 2018 14:08:43 +0200	[thread overview]
Message-ID: <20180526120846.23663-2-pclouds@gmail.com> (raw)
In-Reply-To: <20180526120846.23663-1-pclouds@gmail.com>

This option is supposed to fix the diff of "diff-files" (not reporting
ita entries as new files) and "diff-index --cached <tree>" ( showing
ita entries as present in the index with empty content) but not
"diff-index <tree>".

When --ita-invisible-in-index is set on "git diff-index <tree>",
unpack_trees() will eventually call oneway_diff() on the ita entry
with the same code flow as "diff-index --cached <tree>". We want to
ignore the ita entry for "diff-index --cached <tree>" but not
"diff-index <tree>" since the latter will examine and produce a diff
based on worktree entry's (real) content, not ita index entry's
(empty) content.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 diff-lib.c            | 8 ++++++--
 t/t2203-add-intent.sh | 2 +-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/diff-lib.c b/diff-lib.c
index 104f954a25..a9f38eb5a3 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -389,8 +389,12 @@ static void do_oneway_diff(struct unpack_trees_options *o,
 	struct rev_info *revs = o->unpack_data;
 	int match_missing, cached;
 
-	/* i-t-a entries do not actually exist in the index */
-	if (revs->diffopt.ita_invisible_in_index &&
+	/*
+	 * i-t-a entries do not actually exist in the index (if we're
+	 * looking at its content)
+	 */
+	if (o->index_only &&
+	    revs->diffopt.ita_invisible_in_index &&
 	    idx && ce_intent_to_add(idx)) {
 		idx = NULL;
 		if (!tree)
diff --git a/t/t2203-add-intent.sh b/t/t2203-add-intent.sh
index 78236dc7d8..3ab07cb404 100755
--- a/t/t2203-add-intent.sh
+++ b/t/t2203-add-intent.sh
@@ -70,7 +70,7 @@ test_expect_success 'i-t-a entry is simply ignored' '
 	git commit -m second &&
 	test $(git ls-tree HEAD -- nitfol | wc -l) = 0 &&
 	test $(git diff --name-only HEAD -- nitfol | wc -l) = 1 &&
-	test $(git diff --name-only --ita-invisible-in-index HEAD -- nitfol | wc -l) = 0 &&
+	test $(git diff --name-only --ita-invisible-in-index HEAD -- nitfol | wc -l) = 1 &&
 	test $(git diff --name-only --ita-invisible-in-index -- nitfol | wc -l) = 1
 '
 
-- 
2.17.0.705.g3525833791


  reply	other threads:[~2018-05-26 12:08 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-13 17:54 [PATCH 1/2] diff: turn --ita-invisible-in-index on by default Nguyễn Thái Ngọc Duy
2018-05-13 17:54 ` [PATCH 2/2] apply: add --intent-to-add Nguyễn Thái Ngọc Duy
2018-05-14  2:33   ` Junio C Hamano
2018-05-20  6:34     ` Duy Nguyen
2018-05-21  3:14       ` Junio C Hamano
2018-05-25  3:39 ` [PATCH 1/2] diff: turn --ita-invisible-in-index on by default Jonathan Nieder
2018-05-25 14:30   ` Duy Nguyen
2018-05-25 16:43     ` Jonathan Nieder
2018-05-25 16:59       ` Duy Nguyen
2018-05-26 12:08 ` [PATCH v2 0/4] Fix i-t-a entries in git-diff and git-apply Nguyễn Thái Ngọc Duy
2018-05-26 12:08   ` Nguyễn Thái Ngọc Duy [this message]
2018-05-27  7:18     ` [PATCH v2 1/4] diff: ignore --ita-[in]visible-in-index when diffing worktree-to-tree Eric Sunshine
2018-05-26 12:08   ` [PATCH v2 2/4] diff: turn --ita-invisible-in-index on by default Nguyễn Thái Ngọc Duy
2018-05-26 12:08   ` [PATCH v2 3/4] t2203: add a test about "diff HEAD" case Nguyễn Thái Ngọc Duy
2018-05-26 12:08   ` [PATCH v2 4/4] apply: add --intent-to-add Nguyễn Thái Ngọc Duy

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180526120846.23663-2-pclouds@gmail.com \
    --to=pclouds@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jrnieder@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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).