]> git.ipfire.org Git - thirdparty/git.git/commitdiff
diff-lib: use worktree mode in diffs from i-t-a entries
authorRaymond E. Pasco <ray@ameretat.dev>
Sat, 8 Aug 2020 07:53:23 +0000 (03:53 -0400)
committerJunio C Hamano <gitster@pobox.com>
Sun, 9 Aug 2020 18:14:29 +0000 (11:14 -0700)
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>
diff-lib.c

index 25fd2dee19c4a8f6408d768d44d8dc92aeaf0ed3..50521e2093fc581ce3cedc76b3036a61f31bef35 100644 (file)
@@ -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;
                        }