aboutsummaryrefslogtreecommitdiffstats
path: root/apply.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2020-11-02 13:17:43 -0800
committerJunio C Hamano <gitster@pobox.com>2020-11-02 13:17:43 -0800
commitc23cd78e8127a2f80cc0357994209bc1bb81a4fe (patch)
treeb8f06e459c5ede03d54de4fb27eecb53585799b0 /apply.c
parentMerge branch 'sc/sequencer-gpg-octopus' (diff)
parentapply: when -R, also reverse list of sections (diff)
downloadgit-c23cd78e8127a2f80cc0357994209bc1bb81a4fe.tar.gz
git-c23cd78e8127a2f80cc0357994209bc1bb81a4fe.zip
Merge branch 'jt/apply-reverse-twice'
"git apply -R" did not handle patches that touch the same path twice correctly, which has been corrected. This is most relevant in a patch that changes a path from a regular file to a symbolic link (and vice versa). * jt/apply-reverse-twice: apply: when -R, also reverse list of sections
Diffstat (limited to 'apply.c')
-rw-r--r--apply.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/apply.c b/apply.c
index 76dba93c97..359ceb632c 100644
--- a/apply.c
+++ b/apply.c
@@ -4699,8 +4699,13 @@ static int apply_patch(struct apply_state *state,
reverse_patches(patch);
if (use_patch(state, patch)) {
patch_stats(state, patch);
- *listp = patch;
- listp = &patch->next;
+ if (!list || !state->apply_in_reverse) {
+ *listp = patch;
+ listp = &patch->next;
+ } else {
+ patch->next = list;
+ list = patch;
+ }
if ((patch->new_name &&
ends_with_path_components(patch->new_name,