summaryrefslogtreecommitdiff
path: root/merge-ort.c
diff options
context:
space:
mode:
authorElijah Newren <newren@gmail.com>2021-06-30 17:29:59 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-06-30 21:40:10 (GMT)
commita492d5331cb93d8293e72741b4fb9e1ec4ff294b (patch)
treead292366e125ff2de9be2d2a87afc12828446362 /merge-ort.c
parent806f83287f8d6c0568beed7ca5d603f936d53c40 (diff)
downloadgit-a492d5331cb93d8293e72741b4fb9e1ec4ff294b.zip
git-a492d5331cb93d8293e72741b4fb9e1ec4ff294b.tar.gz
git-a492d5331cb93d8293e72741b4fb9e1ec4ff294b.tar.bz2
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>
Diffstat (limited to 'merge-ort.c')
-rw-r--r--merge-ort.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/merge-ort.c b/merge-ort.c
index 4a9ce2a..8b0f244 100644
--- a/merge-ort.c
+++ b/merge-ort.c
@@ -3002,7 +3002,7 @@ static void process_entry(struct merge_options *opt,
* above.
*/
if (ci->match_mask) {
- ci->merged.clean = 1;
+ ci->merged.clean = !ci->df_conflict && !ci->path_conflict;
if (ci->match_mask == 6) {
/* stages[1] == stages[2] */
ci->merged.result.mode = ci->stages[1].mode;
@@ -3014,6 +3014,8 @@ static void process_entry(struct merge_options *opt,
ci->merged.result.mode = ci->stages[side].mode;
ci->merged.is_null = !ci->merged.result.mode;
+ if (ci->merged.is_null)
+ ci->merged.clean = 1;
oidcpy(&ci->merged.result.oid, &ci->stages[side].oid);
assert(othermask == 2 || othermask == 4);
@@ -3186,6 +3188,7 @@ static void process_entry(struct merge_options *opt,
path)) {
ci->merged.is_null = 1;
ci->merged.clean = 1;
+ assert(!ci->df_conflict && !ci->path_conflict);
} else if (ci->path_conflict &&
oideq(&ci->stages[0].oid, &ci->stages[side].oid)) {
/*
@@ -3212,6 +3215,7 @@ static void process_entry(struct merge_options *opt,
ci->merged.is_null = 1;
ci->merged.result.mode = 0;
oidcpy(&ci->merged.result.oid, null_oid());
+ assert(!ci->df_conflict);
ci->merged.clean = !ci->path_conflict;
}