]> git.ipfire.org Git - thirdparty/git.git/commit
apply: ignore working tree filemode when !core.filemode
authorChandra Pratap <chandrapratap3519@gmail.com>
Tue, 26 Dec 2023 23:32:16 +0000 (15:32 -0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 27 Dec 2023 05:20:32 +0000 (21:20 -0800)
commit0482c32c334b046ff2dd2190c026cfd4ec564233
treecbed3dd64531f6f842004efa82444ee928731845
parent564d0252ca632e0264ed670534a51d18a689ef5d
apply: ignore working tree filemode when !core.filemode

When applying a patch that adds an executable file, git apply
ignores the core.fileMode setting (core.fileMode in git config
specifies whether the executable bit on files in the working tree
should be honored or not) resulting in warnings like:

warning: script.sh has type 100644, expected 100755

even when core.fileMode is set to false, which is undesired. This
is extra true for systems like Windows.

Fix this by inferring the correct file mode from either the existing
index entry, and when it is unavailable, assuming that the file mode
was OK by pretending it had the mode that the preimage wants to see,
when core.filemode is set to false. Add a test case that verifies
the change and prevents future regression.

Signed-off-by: Chandra Pratap <chandrapratap3519@gmail.com>
Reviewed-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
apply.c
t/t4129-apply-samemode.sh