@@ -217,6 +217,20 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
!is_null_oid(&ce->oid),
ce->name, 0);
continue;
+ } else if (ce_intent_to_add(ce) &&
+ !(revs->diffopt.output_format &
+ ~(DIFF_FORMAT_RAW | DIFF_FORMAT_NAME_STATUS))) {
+ struct object_id oid;
+ int ret = lstat(ce->name, &st);
+
+ if (ret < 0)
+ oidclr(&oid);
+ else
+ ret = index_path(istate, &oid,
+ ce->name, &st, 0);
+ diff_addremove(&revs->diffopt, '+', ce->ce_mode,
+ &oid, ret >= 0, ce->name, 0);
+ continue;
} else if (revs->diffopt.ita_invisible_in_index &&
ce_intent_to_add(ce)) {
diff_addremove(&revs->diffopt, '+', ce->ce_mode,
@@ -240,7 +240,6 @@ test_expect_success 'i-t-a files shown as new for "diff", "diff-files"; not-new
hash_e=$(git hash-object empty) &&
hash_n=$(git hash-object not-empty) &&
- hash_t=$(git hash-object -t tree /dev/null) &&
cat >expect.diff_p <<-EOF &&
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
create mode 100644 not-empty
EOF
cat >expect.diff_a <<-EOF &&
- :000000 100644 0000000 $(git rev-parse --short $hash_t) A$(printf "\t")empty
- :000000 100644 0000000 $(git rev-parse --short $hash_t) A$(printf "\t")not-empty
+ :000000 100644 0000000 $(git rev-parse --short $hash_e) A$(printf "\t")empty
+ :000000 100644 0000000 $(git rev-parse --short $hash_n) A$(printf "\t")not-empty
EOF
git add -N empty not-empty &&
@@ -89,4 +89,14 @@ test_expect_success 'git diff-files --patch --no-patch does not show the patch'
test_must_be_empty err
'
+test_expect_success 'git diff-files --raw handles intent-to-add files correctly' '
+ echo 123 >ita &&
+ git add -N ita &&
+ printf ":000000 100644 %s %s A\\tita\n" \
+ $ZERO_OID $(git hash-object --stdin <ita) >expect &&
+ git diff-files --raw ita >actual &&
+ test_cmp expect actual
+'
+
+
test_done