aboutsummaryrefslogtreecommitdiff
path: root/apply.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2026-02-27 15:11:52 -0800
committerJunio C Hamano <gitster@pobox.com>2026-02-27 15:11:52 -0800
commit0f0a57e1e3df3a41c1ccc6dcbd4642b83e977346 (patch)
treed489c04cfe1a2c38c3364c5fff2c7e81c47632e6 /apply.c
parentc33b464dfdc5b3d2ebfefbc497efb4f30e369e18 (diff)
parent6a41481c6de1cedb059930a710896c5ab2508a12 (diff)
downloadgit-0f0a57e1e3df3a41c1ccc6dcbd4642b83e977346.tar.xz
Merge branch 'jc/whitespace-incomplete-line'
It does not make much sense to apply the "incomplete-line" whitespace rule to symbolic links, whose contents almost always lack the final newline. "git apply" and "git diff" are now taught to exclude them for a change to symbolic links. * jc/whitespace-incomplete-line: whitespace: symbolic links usually lack LF at the end
Diffstat (limited to 'apply.c')
-rw-r--r--apply.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/apply.c b/apply.c
index e4c4bf7af9..d044c95d50 100644
--- a/apply.c
+++ b/apply.c
@@ -1725,6 +1725,26 @@ static int parse_fragment(struct apply_state *state,
unsigned long oldlines, newlines;
unsigned long leading, trailing;
+ /* do not complain a symbolic link being an incomplete line */
+ if (patch->ws_rule & WS_INCOMPLETE_LINE) {
+ /*
+ * We want to figure out if the postimage is a
+ * symbolic link when applying the patch normally, or
+ * if the preimage is a symbolic link when applying
+ * the patch in reverse. A normal patch only has
+ * old_mode without new_mode. If it changes the
+ * filemode, new_mode has value, which is different
+ * from old_mode.
+ */
+ unsigned mode = (state->apply_in_reverse
+ ? patch->old_mode
+ : patch->new_mode
+ ? patch->new_mode
+ : patch->old_mode);
+ if (mode && S_ISLNK(mode))
+ patch->ws_rule &= ~WS_INCOMPLETE_LINE;
+ }
+
offset = parse_fragment_header(line, len, fragment);
if (offset < 0)
return -1;