Skip to content

Commit a97e407

Browse files
raalkmlJunio C Hamano
authored andcommitted
Keep rename/rename conflicts of intermediate merges while doing recursive merge
This patch leaves the base name in the resulting intermediate tree, to propagate the conflict from intermediate merges up to the top-level merge. Signed-off-by: Alex Riesen <[email protected]> Acked-by: Linus Torvalds <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4f01748 commit a97e407

File tree

1 file changed

+31
-6
lines changed

1 file changed

+31
-6
lines changed

merge-recursive.c

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,16 @@ static struct tree *git_write_tree(void)
278278
{
279279
struct tree *result = NULL;
280280

281-
if (unmerged_index())
281+
if (unmerged_index()) {
282+
int i;
283+
output(0, "There are unmerged index entries:");
284+
for (i = 0; i < active_nr; i++) {
285+
struct cache_entry *ce = active_cache[i];
286+
if (ce_stage(ce))
287+
output(0, "%d %.*s", ce_stage(ce), ce_namelen(ce), ce->name);
288+
}
282289
return NULL;
290+
}
283291

284292
if (!active_cache_tree)
285293
active_cache_tree = cache_tree();
@@ -735,8 +743,19 @@ static void conflict_rename_rename(struct rename *ren1,
735743
ren2_dst, branch1, dst_name2);
736744
remove_file(0, ren2_dst, 0);
737745
}
738-
update_stages(dst_name1, NULL, ren1->pair->two, NULL, 1);
739-
update_stages(dst_name2, NULL, NULL, ren2->pair->two, 1);
746+
if (index_only) {
747+
remove_file_from_cache(dst_name1);
748+
remove_file_from_cache(dst_name2);
749+
/*
750+
* Uncomment to leave the conflicting names in the resulting tree
751+
*
752+
* update_file(0, ren1->pair->two->sha1, ren1->pair->two->mode, dst_name1);
753+
* update_file(0, ren2->pair->two->sha1, ren2->pair->two->mode, dst_name2);
754+
*/
755+
} else {
756+
update_stages(dst_name1, NULL, ren1->pair->two, NULL, 1);
757+
update_stages(dst_name2, NULL, NULL, ren2->pair->two, 1);
758+
}
740759
while (delp--)
741760
free(del[delp]);
742761
}
@@ -852,10 +871,16 @@ static int process_renames(struct path_list *a_renames,
852871
if (strcmp(ren1_dst, ren2_dst) != 0) {
853872
clean_merge = 0;
854873
output(1, "CONFLICT (rename/rename): "
855-
"Rename %s->%s in branch %s "
856-
"rename %s->%s in %s",
874+
"Rename \"%s\"->\"%s\" in branch \"%s\" "
875+
"rename \"%s\"->\"%s\" in \"%s\"%s",
857876
src, ren1_dst, branch1,
858-
src, ren2_dst, branch2);
877+
src, ren2_dst, branch2,
878+
index_only ? " (left unresolved)": "");
879+
if (index_only) {
880+
remove_file_from_cache(src);
881+
update_file(0, ren1->pair->one->sha1,
882+
ren1->pair->one->mode, src);
883+
}
859884
conflict_rename_rename(ren1, branch1, ren2, branch2);
860885
} else {
861886
struct merge_file_info mfi;

0 commit comments

Comments
 (0)