@matheusbsbs / matheus-bagliano / commits / cb0dd22b82
Fork 0

diff-lib: use worktree mode in diffs from i-t-a entries

When creating "new file" diffs against i-t-a index entries, diff-lib erroneously used the mode of the cache entry rather than the mode of the file in the worktree. This changes run_diff_files() to correctly use the mode of the worktree file in this case. Signed-off-by: Raymond E. Pasco <ray@ameretat.dev> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Raymond E. Pasco committed Aug 8, 2020 at 03:53 UTC cb0dd22b827a0533a8ba105764388269e59d010c
1 file changed +2 -1
diff-lib.c
+2 -1
@@ -219,7 +219,8 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
219 continue;
220 } else if (revs->diffopt.ita_invisible_in_index &&
221 ce_intent_to_add(ce)) {
222 - diff_addremove(&revs->diffopt, '+', ce->ce_mode,
222 + newmode = ce_mode_from_stat(ce, st.st_mode);
223 + diff_addremove(&revs->diffopt, '+', newmode,
224 &null_oid, 0, ce->name, 0);
225 continue;
226 }