Skip to content

Commit 0ac0947

Browse files
committed
Merge branch 'js/diff-files-i-t-a-fix-for-difftool'
"git difftool" has trouble dealing with paths added to the index with the intent-to-add bit. * js/diff-files-i-t-a-fix-for-difftool: difftool -d: ensure that intent-to-add files are handled correctly diff-files --raw: show correct post-image of intent-to-add files
2 parents 11cbda2 + 3080c50 commit 0ac0947

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

diff-lib.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,7 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
220220
} else if (revs->diffopt.ita_invisible_in_index &&
221221
ce_intent_to_add(ce)) {
222222
diff_addremove(&revs->diffopt, '+', ce->ce_mode,
223-
the_hash_algo->empty_tree, 0,
224-
ce->name, 0);
223+
&null_oid, 0, ce->name, 0);
225224
continue;
226225
}
227226

t/t2203-add-intent.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ test_expect_success 'i-t-a files shown as new for "diff", "diff-files"; not-new
240240
241241
hash_e=$(git hash-object empty) &&
242242
hash_n=$(git hash-object not-empty) &&
243-
hash_t=$(git hash-object -t tree /dev/null) &&
244243
245244
cat >expect.diff_p <<-EOF &&
246245
diff --git a/empty b/empty
@@ -259,8 +258,8 @@ test_expect_success 'i-t-a files shown as new for "diff", "diff-files"; not-new
259258
create mode 100644 not-empty
260259
EOF
261260
cat >expect.diff_a <<-EOF &&
262-
:000000 100644 0000000 $(git rev-parse --short $hash_t) A$(printf "\t")empty
263-
:000000 100644 0000000 $(git rev-parse --short $hash_t) A$(printf "\t")not-empty
261+
:000000 100644 0000000 0000000 A$(printf "\t")empty
262+
:000000 100644 0000000 0000000 A$(printf "\t")not-empty
264263
EOF
265264
266265
git add -N empty not-empty &&

t/t7800-difftool.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,14 @@ test_expect_success SYMLINKS 'difftool --dir-diff handles modified symlinks' '
720720
test_cmp expect actual
721721
'
722722

723+
test_expect_success 'add -N and difftool -d' '
724+
test_when_finished git reset --hard &&
725+
726+
test_write_lines A B C >intent-to-add &&
727+
git add -N intent-to-add &&
728+
git difftool --dir-diff --extcmd ls
729+
'
730+
723731
test_expect_success 'outside worktree' '
724732
echo 1 >1 &&
725733
echo 2 >2 &&

0 commit comments

Comments
 (0)