handle_delete_modify(): Check whether D/F conflicts are still present
If all the paths below some directory involved in a D/F conflict were not removed during the rest of the merge, then the contents of the file whose path conflicted needs to be recorded in file with an alternative filename. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
4ab9a157d0
commit
84a08a47b9
@ -1164,25 +1164,29 @@ error_return:
|
|||||||
|
|
||||||
static void handle_delete_modify(struct merge_options *o,
|
static void handle_delete_modify(struct merge_options *o,
|
||||||
const char *path,
|
const char *path,
|
||||||
|
const char *new_path,
|
||||||
unsigned char *a_sha, int a_mode,
|
unsigned char *a_sha, int a_mode,
|
||||||
unsigned char *b_sha, int b_mode)
|
unsigned char *b_sha, int b_mode)
|
||||||
{
|
{
|
||||||
if (!a_sha) {
|
if (!a_sha) {
|
||||||
output(o, 1, "CONFLICT (delete/modify): %s deleted in %s "
|
output(o, 1, "CONFLICT (delete/modify): %s deleted in %s "
|
||||||
"and modified in %s. Version %s of %s left in tree.",
|
"and modified in %s. Version %s of %s left in tree%s%s.",
|
||||||
path, o->branch1,
|
path, o->branch1,
|
||||||
o->branch2, o->branch2, path);
|
o->branch2, o->branch2, path,
|
||||||
update_file(o, 0, b_sha, b_mode, path);
|
path == new_path ? "" : " at ",
|
||||||
|
path == new_path ? "" : new_path);
|
||||||
|
update_file(o, 0, b_sha, b_mode, new_path);
|
||||||
} else {
|
} else {
|
||||||
output(o, 1, "CONFLICT (delete/modify): %s deleted in %s "
|
output(o, 1, "CONFLICT (delete/modify): %s deleted in %s "
|
||||||
"and modified in %s. Version %s of %s left in tree.",
|
"and modified in %s. Version %s of %s left in tree%s%s.",
|
||||||
path, o->branch2,
|
path, o->branch2,
|
||||||
o->branch1, o->branch1, path);
|
o->branch1, o->branch1, path,
|
||||||
update_file(o, 0, a_sha, a_mode, path);
|
path == new_path ? "" : " at ",
|
||||||
|
path == new_path ? "" : new_path);
|
||||||
|
update_file(o, 0, a_sha, a_mode, new_path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int merge_content(struct merge_options *o,
|
static int merge_content(struct merge_options *o,
|
||||||
const char *path,
|
const char *path,
|
||||||
unsigned char *o_sha, int o_mode,
|
unsigned char *o_sha, int o_mode,
|
||||||
@ -1281,7 +1285,7 @@ static int process_entry(struct merge_options *o,
|
|||||||
} else {
|
} else {
|
||||||
/* Deleted in one and changed in the other */
|
/* Deleted in one and changed in the other */
|
||||||
clean_merge = 0;
|
clean_merge = 0;
|
||||||
handle_delete_modify(o, path,
|
handle_delete_modify(o, path, path,
|
||||||
a_sha, a_mode, b_sha, b_mode);
|
a_sha, a_mode, b_sha, b_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1398,8 +1402,11 @@ static int process_df_entry(struct merge_options *o,
|
|||||||
}
|
}
|
||||||
} else if (o_sha && (!a_sha || !b_sha)) {
|
} else if (o_sha && (!a_sha || !b_sha)) {
|
||||||
/* Modify/delete; deleted side may have put a directory in the way */
|
/* Modify/delete; deleted side may have put a directory in the way */
|
||||||
|
const char *new_path = path;
|
||||||
|
if (lstat(path, &st) == 0 && S_ISDIR(st.st_mode))
|
||||||
|
new_path = unique_path(o, path, a_sha ? o->branch1 : o->branch2);
|
||||||
clean_merge = 0;
|
clean_merge = 0;
|
||||||
handle_delete_modify(o, path,
|
handle_delete_modify(o, path, new_path,
|
||||||
a_sha, a_mode, b_sha, b_mode);
|
a_sha, a_mode, b_sha, b_mode);
|
||||||
} else if (!o_sha && !!a_sha != !!b_sha) {
|
} else if (!o_sha && !!a_sha != !!b_sha) {
|
||||||
/* directory -> (directory, file) */
|
/* directory -> (directory, file) */
|
||||||
|
@ -71,7 +71,7 @@ test_expect_success 'setup modify/delete + directory/file conflict' '
|
|||||||
git commit -m deleted
|
git commit -m deleted
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_failure 'modify/delete + directory/file conflict' '
|
test_expect_success 'modify/delete + directory/file conflict' '
|
||||||
git checkout delete^0 &&
|
git checkout delete^0 &&
|
||||||
test_must_fail git merge modify &&
|
test_must_fail git merge modify &&
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user