Each side of the rename in rename/rename(1to2) could potentially also be involved in a rename/add conflict. Ensure stages for such conflicts are also recorded. Signed-off-by: Elijah Newren <newren@xxxxxxxxx> Signed-off-by: Junio C Hamano <gitster@xxxxxxxxx> --- No changes since v1. merge-recursive.c | 21 +++++++++++++++++++-- t/t6042-merge-rename-corner-cases.sh | 2 +- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/merge-recursive.c b/merge-recursive.c index c89a5ce..8ddd520 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -1073,6 +1073,19 @@ static void conflict_rename_delete(struct merge_options *o, "rename", "renamed"); } +static struct diff_filespec *filespec_from_entry(struct diff_filespec *target, + struct stage_data *entry, + int stage) +{ + unsigned char *sha = entry->stages[stage].sha; + unsigned mode = entry->stages[stage].mode; + if (mode == 0 || is_null_sha1(sha)) + return NULL; + hashcpy(target->sha1, sha); + target->mode = mode; + return target; +} + static void conflict_rename_rename_1to2(struct merge_options *o, struct rename_conflict_info *ci) { @@ -1118,8 +1131,12 @@ static void conflict_rename_rename_1to2(struct merge_options *o, remove_file_from_cache(a->path); remove_file_from_cache(b->path); } else { - update_stages(a->path, NULL, a, NULL); - update_stages(b->path, NULL, NULL, b); + struct diff_filespec other; + update_stages(a->path, NULL, + a, filespec_from_entry(&other, ci->dst_entry1, 3)); + + update_stages(b->path, NULL, + filespec_from_entry(&other, ci->dst_entry2, 2), b); update_file(o, 0, a->sha1, a->mode, dst_name_a); update_file(o, 0, b->sha1, b->mode, dst_name_b); diff --git a/t/t6042-merge-rename-corner-cases.sh b/t/t6042-merge-rename-corner-cases.sh index 3be5059..6875919 100755 --- a/t/t6042-merge-rename-corner-cases.sh +++ b/t/t6042-merge-rename-corner-cases.sh @@ -551,7 +551,7 @@ test_expect_success 'setup rename/rename(1to2)/add-dest conflict' ' git commit -m two ' -test_expect_failure 'rename/rename/add-dest merge still knows about conflicting file versions' ' +test_expect_success 'rename/rename/add-dest merge still knows about conflicting file versions' ' git checkout C^0 && test_must_fail git merge -s recursive B^0 && -- 1.7.6.100.gac5c1 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html