summaryrefslogtreecommitdiff
path: root/merge-recursive.c
diff options
context:
space:
mode:
authorElijah Newren <newren@gmail.com>2011-08-11 23:20:14 -0600
committerJunio C Hamano <gitster@pobox.com>2011-08-14 14:19:38 -0700
commita99b7f2256ebd2d1db59c578f3da003e36f259c4 (patch)
treee109f90e74a5a95b38f965e28a41044ac07536f4 /merge-recursive.c
parentc52ff85d97c698c902870305a010e2303e297b87 (diff)
downloadgit-a99b7f2256ebd2d1db59c578f3da003e36f259c4.tar.gz
merge-recursive: Small cleanups for conflict_rename_rename_1to2
Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'merge-recursive.c')
-rw-r--r--merge-recursive.c60
1 files changed, 27 insertions, 33 deletions
diff --git a/merge-recursive.c b/merge-recursive.c
index f64cfc582a..8020d4b513 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -964,58 +964,55 @@ static void conflict_rename_delete(struct merge_options *o,
}
static void conflict_rename_rename_1to2(struct merge_options *o,
- struct diff_filepair *pair1,
- const char *branch1,
- struct diff_filepair *pair2,
- const char *branch2)
+ struct rename_conflict_info *ci)
{
/* One file was renamed in both branches, but to different names. */
+ struct diff_filespec *one = ci->pair1->one;
+ struct diff_filespec *a = ci->pair1->two;
+ struct diff_filespec *b = ci->pair2->two;
+ const char *dst_name_a = a->path;
+ const char *dst_name_b = b->path;
char *del[2];
int delp = 0;
- const char *src = pair1->one->path;
- const char *ren1_dst = pair1->two->path;
- const char *ren2_dst = pair2->two->path;
- const char *dst_name1 = ren1_dst;
- const char *dst_name2 = ren2_dst;
output(o, 1, "CONFLICT (rename/rename): "
"Rename \"%s\"->\"%s\" in branch \"%s\" "
"rename \"%s\"->\"%s\" in \"%s\"%s",
- src, pair1->two->path, branch1,
- src, pair2->two->path, branch2,
+ one->path, a->path, ci->branch1,
+ one->path, b->path, ci->branch2,
o->call_depth ? " (left unresolved)" : "");
- if (dir_in_way(ren1_dst, !o->call_depth)) {
- dst_name1 = del[delp++] = unique_path(o, ren1_dst, branch1);
+ if (dir_in_way(a->path, !o->call_depth)) {
+ dst_name_a = del[delp++] = unique_path(o, a->path, ci->branch1);
output(o, 1, "%s is a directory in %s adding as %s instead",
- ren1_dst, branch2, dst_name1);
+ a->path, ci->branch2, dst_name_a);
}
- if (dir_in_way(ren2_dst, !o->call_depth)) {
- dst_name2 = del[delp++] = unique_path(o, ren2_dst, branch2);
+ if (dir_in_way(b->path, !o->call_depth)) {
+ dst_name_b = del[delp++] = unique_path(o, b->path, ci->branch2);
output(o, 1, "%s is a directory in %s adding as %s instead",
- ren2_dst, branch1, dst_name2);
+ b->path, ci->branch1, dst_name_b);
}
if (o->call_depth) {
struct merge_file_info mfi;
- mfi = merge_file(o, src,
- pair1->one->sha1, pair1->one->mode,
- pair1->two->sha1, pair1->two->mode,
- pair2->two->sha1, pair2->two->mode,
- branch1, branch2);
+ mfi = merge_file(o, one->path,
+ one->sha1, one->mode,
+ a->sha1, a->mode,
+ b->sha1, b->mode,
+ ci->branch1, ci->branch2);
/*
* FIXME: For rename/add-source conflicts (if we could detect
* such), this is wrong. We should instead find a unique
* pathname and then either rename the add-source file to that
* unique path, or use that unique path instead of src here.
*/
- update_file(o, 0, mfi.sha, mfi.mode, src);
- remove_file_from_cache(ren1_dst);
- remove_file_from_cache(ren2_dst);
+ update_file(o, 0, mfi.sha, mfi.mode, one->path);
+ remove_file_from_cache(a->path);
+ remove_file_from_cache(b->path);
} else {
- update_stages(ren1_dst, NULL, pair1->two, NULL);
- update_stages(ren2_dst, NULL, NULL, pair2->two);
+ update_stages(a->path, NULL, a, NULL);
+ update_stages(b->path, NULL, NULL, b);
- update_file(o, 0, pair1->two->sha1, pair1->two->mode, dst_name1);
- update_file(o, 0, pair2->two->sha1, pair2->two->mode, dst_name2);
+ update_file(o, 0, a->sha1, a->mode, dst_name_a);
+ update_file(o, 0, b->sha1, b->mode, dst_name_b);
}
while (delp--)
free(del[delp]);
@@ -1503,10 +1500,7 @@ static int process_entry(struct merge_options *o,
break;
case RENAME_ONE_FILE_TO_TWO:
clean_merge = 0;
- conflict_rename_rename_1to2(o, conflict_info->pair1,
- conflict_info->branch1,
- conflict_info->pair2,
- conflict_info->branch2);
+ conflict_rename_rename_1to2(o, conflict_info);
break;
default:
entry->processed = 0;