@@ -219,7 +219,8 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
continue;
} else if (revs->diffopt.ita_invisible_in_index &&
ce_intent_to_add(ce)) {
- diff_addremove(&revs->diffopt, '+', ce->ce_mode,
+ newmode = ce_mode_from_stat(ce, st.st_mode);
+ diff_addremove(&revs->diffopt, '+', newmode,
&null_oid, 0, ce->name, 0);
continue;
}
@@ -15,6 +15,12 @@ test_expect_success 'diff between i-t-a and file should be new file' '
grep "new file mode 100644" output
'
+test_expect_success 'new file diff should use worktree mode' '
+ chmod 755 test-file &&
+ git diff >output &&
+ grep "new file mode 100755" output
+'
+
test_expect_success 'diff between i-t-a and no file should be deletion' '
rm -f test-file &&
git diff >output &&