apply: symbolic links lack a "trustable executable bit"

When 0482c32c334b (apply: ignore working tree filemode when !core.filemode, 2023-12-26) fixed `git apply` to stop warning about executable files, it inadvertently changed the code flow also for symbolic links and directories. Let's narrow the scope of the special `!trust_executable_git` code path to apply only to regular files. This is needed to let t4115.5(symlink escape when creating new files) pass on Windows when symbolic link support is enabled in the MSYS2 runtime. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Schindelin committed Dec 17, 2025 at 14:18 UTC b90a926371bbb45b2abd27241a8ef682f1450b99
1 file changed +1 -1
apply.c
+1 -1
@@ -3779,7 +3779,7 @@ static int check_preimage(struct apply_state *state,
3779 if (*ce && !(*ce)->ce_mode)
3780 BUG("ce_mode == 0 for path '%s'", old_name);
3781
3782 - if (trust_executable_bit)
3782 + if (trust_executable_bit || !S_ISREG(st->st_mode))
3783 st_mode = ce_mode_from_stat(*ce, st->st_mode);
3784 else if (*ce)
3785 st_mode = (*ce)->ce_mode;