diff options
| author | Junio C Hamano <gitster@pobox.com> | 2024-02-26 18:10:24 -0800 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2024-02-26 18:10:24 -0800 |
| commit | cf47fb7ec7e183a1a1e521a540862fba3c2a89eb (patch) | |
| tree | becb14d7e876deff37756a158850463bd4b53fec /apply.c | |
| parent | b4385bf016d0d4b8e9bea6564e2d727082067f69 (diff) | |
| parent | 45b625142d8ca2218af1fb2b37216e58953e775d (diff) | |
| download | git-cf47fb7ec7e183a1a1e521a540862fba3c2a89eb.tar.xz | |
Merge branch 'cp/apply-core-filemode'
"git apply" on a filesystem without filemode support have learned
to take a hint from what is in the index for the path, even when
not working with the "--index" or "--cached" option, when checking
the executable bit match what is required by the preimage in the
patch.
* cp/apply-core-filemode:
apply: code simplification
apply: correctly reverse patch's pre- and post-image mode bits
apply: ignore working tree filemode when !core.filemode
Diffstat (limited to 'apply.c')
| -rw-r--r-- | apply.c | 16 |
1 files changed, 13 insertions, 3 deletions
@@ -2219,7 +2219,8 @@ static void reverse_patches(struct patch *p) struct fragment *frag = p->fragments; SWAP(p->new_name, p->old_name); - SWAP(p->new_mode, p->old_mode); + if (p->new_mode) + SWAP(p->new_mode, p->old_mode); SWAP(p->is_new, p->is_delete); SWAP(p->lines_added, p->lines_deleted); SWAP(p->old_oid_prefix, p->new_oid_prefix); @@ -3777,8 +3778,17 @@ static int check_preimage(struct apply_state *state, return error_errno("%s", old_name); } - if (!state->cached && !previous) - st_mode = ce_mode_from_stat(*ce, st->st_mode); + if (!state->cached && !previous) { + if (*ce && !(*ce)->ce_mode) + BUG("ce_mode == 0 for path '%s'", old_name); + + if (trust_executable_bit) + st_mode = ce_mode_from_stat(*ce, st->st_mode); + else if (*ce) + st_mode = (*ce)->ce_mode; + else + st_mode = patch->old_mode; + } if (patch->is_new < 0) patch->is_new = 0; |
