summaryrefslogtreecommitdiff
path: root/merge-recursive.c
diff options
context:
space:
mode:
authorElijah Newren <newren@gmail.com>2011-08-11 23:20:21 -0600
committerJunio C Hamano <gitster@pobox.com>2011-08-14 14:19:39 -0700
commit1ac91b32b5f153a91c10fb236a3769541be60ae9 (patch)
treec8816fc69aaa2ca17eaf25d56ac3c004113e4200 /merge-recursive.c
parente03acb8bc1f03827210235dd72578b8b26f19c51 (diff)
downloadgit-1ac91b32b5f153a91c10fb236a3769541be60ae9.tar.gz
merge-recursive: add handling for rename/rename/add-dest/add-dest
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@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'merge-recursive.c')
-rw-r--r--merge-recursive.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/merge-recursive.c b/merge-recursive.c
index f29aaf7fc6..2059f25620 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -1071,6 +1071,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)
{
@@ -1116,8 +1129,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);