- char *new_path1 = unique_path(o, ren1->pair->two->path, branch1);
- char *new_path2 = unique_path(o, ren2->pair->two->path, branch2);
- output(o, 1, "Renaming %s to %s and %s to %s instead",
- ren1->pair->one->path, new_path1,
- ren2->pair->one->path, new_path2);
- remove_file(o, 0, ren1->pair->two->path, 0);
- update_file(o, 0, ren1->pair->two->sha1, ren1->pair->two->mode, new_path1);
- update_file(o, 0, ren2->pair->two->sha1, ren2->pair->two->mode, new_path2);
- free(new_path2);
- free(new_path1);
+ if (o->call_depth) {
+ struct merge_file_info mfi;
+ struct diff_filespec one, a, b;
+
+ one.path = a.path = b.path = path;
+ hashcpy(one.sha1, null_sha1);
+ one.mode = 0;
+ hashcpy(a.sha1, ren1->pair->two->sha1);
+ a.mode = ren1->pair->two->mode;
+ hashcpy(b.sha1, ren2->pair->two->sha1);
+ b.mode = ren2->pair->two->mode;
+ mfi = merge_file(o, &one, &a, &b, branch1, branch2);
+ output(o, 1, "Adding merged %s", path);
+ update_file(o, 0, mfi.sha, mfi.mode, path);
+ } else {
+ char *new_path1 = unique_path(o, path, branch1);
+ char *new_path2 = unique_path(o, path, branch2);
+ output(o, 1, "Renaming %s to %s and %s to %s instead",
+ ren1->pair->one->path, new_path1,
+ ren2->pair->one->path, new_path2);
+ remove_file(o, 0, path, 0);
+ update_file(o, 0, ren1->pair->two->sha1, ren1->pair->two->mode,
+ new_path1);
+ update_file(o, 0, ren2->pair->two->sha1, ren2->pair->two->mode,
+ new_path2);
+ free(new_path2);
+ free(new_path1);
+ }