Skip to content

Commit a492d53

Browse files
newrengitster
authored andcommitted
merge-ort: ensure we consult df_conflict and path_conflicts
Path conflicts (typically rename path conflicts, e.g. rename/rename(1to2) or rename/add/delete), and directory/file conflicts should obviously result in files not being marked as clean in the merge. We had a codepath where we missed consulting the path_conflict and df_conflict flags, based on match_mask. Granted, it requires an unusual setup to trigger this codepath (directory rename causing rename-to-self is the only case I can think of), but we still need to handle it. To make it clear that we have audited the other codepaths that do not explicitly mention these flags, add some assertions that the flags are not set. Reported-by: Anders Kaseorg <andersk@mit.edu> Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 806f832 commit a492d53

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

merge-ort.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3002,7 +3002,7 @@ static void process_entry(struct merge_options *opt,
30023002
* above.
30033003
*/
30043004
if (ci->match_mask) {
3005-
ci->merged.clean = 1;
3005+
ci->merged.clean = !ci->df_conflict && !ci->path_conflict;
30063006
if (ci->match_mask == 6) {
30073007
/* stages[1] == stages[2] */
30083008
ci->merged.result.mode = ci->stages[1].mode;
@@ -3014,6 +3014,8 @@ static void process_entry(struct merge_options *opt,
30143014

30153015
ci->merged.result.mode = ci->stages[side].mode;
30163016
ci->merged.is_null = !ci->merged.result.mode;
3017+
if (ci->merged.is_null)
3018+
ci->merged.clean = 1;
30173019
oidcpy(&ci->merged.result.oid, &ci->stages[side].oid);
30183020

30193021
assert(othermask == 2 || othermask == 4);
@@ -3186,6 +3188,7 @@ static void process_entry(struct merge_options *opt,
31863188
path)) {
31873189
ci->merged.is_null = 1;
31883190
ci->merged.clean = 1;
3191+
assert(!ci->df_conflict && !ci->path_conflict);
31893192
} else if (ci->path_conflict &&
31903193
oideq(&ci->stages[0].oid, &ci->stages[side].oid)) {
31913194
/*
@@ -3212,6 +3215,7 @@ static void process_entry(struct merge_options *opt,
32123215
ci->merged.is_null = 1;
32133216
ci->merged.result.mode = 0;
32143217
oidcpy(&ci->merged.result.oid, null_oid());
3218+
assert(!ci->df_conflict);
32153219
ci->merged.clean = !ci->path_conflict;
32163220
}
32173221

t/t6423-merge-rename-directories.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5000,7 +5000,7 @@ test_setup_12i () {
50005000
)
50015001
}
50025002

5003-
test_expect_merge_algorithm failure failure '12i: Directory rename causes rename-to-self' '
5003+
test_expect_merge_algorithm failure success '12i: Directory rename causes rename-to-self' '
50045004
test_setup_12i &&
50055005
(
50065006
cd 12i &&
@@ -5058,7 +5058,7 @@ test_setup_12j () {
50585058
)
50595059
}
50605060

5061-
test_expect_merge_algorithm failure failure '12j: Directory rename to root causes rename-to-self' '
5061+
test_expect_merge_algorithm failure success '12j: Directory rename to root causes rename-to-self' '
50625062
test_setup_12j &&
50635063
(
50645064
cd 12j &&
@@ -5116,7 +5116,7 @@ test_setup_12k () {
51165116
)
51175117
}
51185118

5119-
test_expect_merge_algorithm failure failure '12k: Directory rename with sibling causes rename-to-self' '
5119+
test_expect_merge_algorithm failure success '12k: Directory rename with sibling causes rename-to-self' '
51205120
test_setup_12k &&
51215121
(
51225122
cd 12k &&

0 commit comments

Comments
 (0)