Skip to content

Commit ba4e356

Browse files
pcloudsgitster
authored andcommitted
diff: ignore --ita-[in]visible-in-index when diffing worktree-to-tree
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ccdcbd5 commit ba4e356

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

diff-lib.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,8 +389,12 @@ static void do_oneway_diff(struct unpack_trees_options *o,
389389
struct rev_info *revs = o->unpack_data;
390390
int match_missing, cached;
391391

392-
/* i-t-a entries do not actually exist in the index */
393-
if (revs->diffopt.ita_invisible_in_index &&
392+
/*
393+
* i-t-a entries do not actually exist in the index (if we're
394+
* looking at its content)
395+
*/
396+
if (o->index_only &&
397+
revs->diffopt.ita_invisible_in_index &&
394398
idx && ce_intent_to_add(idx)) {
395399
idx = NULL;
396400
if (!tree)

t/t2203-add-intent.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ test_expect_success 'i-t-a entry is simply ignored' '
7070
git commit -m second &&
7171
test $(git ls-tree HEAD -- nitfol | wc -l) = 0 &&
7272
test $(git diff --name-only HEAD -- nitfol | wc -l) = 1 &&
73-
test $(git diff --name-only --ita-invisible-in-index HEAD -- nitfol | wc -l) = 0 &&
73+
test $(git diff --name-only --ita-invisible-in-index HEAD -- nitfol | wc -l) = 1 &&
7474
test $(git diff --name-only --ita-invisible-in-index -- nitfol | wc -l) = 1
7575
'
7676

0 commit comments

Comments
 (0)