From ba4e356109e5bf2b86bde335128c0ab4161268a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Sat, 26 May 2018 14:08:43 +0200 Subject: diff: ignore --ita-[in]visible-in-index when diffing worktree-to-tree MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This option is supposed to fix the diff of "diff-files" (not reporting ita entries as new files) and "diff-index --cached " (showing ita entries as present in the index with empty content) but not "diff-index ". When --ita-invisible-in-index is set on "git diff-index ", unpack_trees() will eventually call oneway_diff() on the ita entry with the same code flow as "diff-index --cached ". We want to ignore the ita entry for "diff-index --cached " but not "diff-index " 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 Signed-off-by: Junio C Hamano diff --git a/diff-lib.c b/diff-lib.c index 104f954..a9f38eb 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 78236dc..3ab07cb 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 ' -- cgit v0.10.2-6-g49f6