]> git.ipfire.org Git - thirdparty/git.git/commitdiff
diff: ignore --ita-[in]visible-in-index when diffing worktree-to-tree
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Sat, 26 May 2018 12:08:43 +0000 (14:08 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 29 May 2018 03:36:31 +0000 (12:36 +0900)
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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff-lib.c
t/t2203-add-intent.sh

index 104f954a25700a4eee95507e7ebb7734e94b67c6..a9f38eb5a3e0e17d111301b581d06876ce5fd510 100644 (file)
@@ -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)
index 78236dc7d851663c4488e7acae5e6997edd35f1c..3ab07cb40407f74369f53e6fb9c7edf5367f9a5b 100755 (executable)
@@ -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
 '