summaryrefslogtreecommitdiff
path: root/merge-recursive.c
diff options
context:
space:
mode:
authorElijah Newren <newren@gmail.com>2010-09-20 02:29:07 -0600
committerJunio C Hamano <gitster@pobox.com>2010-09-29 17:37:05 -0700
commit4ab9a157d06956ce5a1060a28404cbade3039fa2 (patch)
tree0f3d2f973c2aac4f780d10ba13c030498b62e508 /merge-recursive.c
parent2adc7dcc111636ed16601dc7516ced1c5cfda088 (diff)
downloadgit-4ab9a157d06956ce5a1060a28404cbade3039fa2.tar.gz
merge_content(): Check whether D/F conflicts are still present
If all the paths below some directory involved in a D/F conflict were not removed during the rest of the merge, then the contents of the file whose path conflicted needs to be recorded in file with an alternative filename. 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.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/merge-recursive.c b/merge-recursive.c
index 85d69eb567..a3f986d874 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -1193,6 +1193,8 @@ static int merge_content(struct merge_options *o,
const char *reason = "content";
struct merge_file_info mfi;
struct diff_filespec one, a, b;
+ struct stat st;
+ unsigned df_conflict_remains = 0;
if (!o_sha) {
reason = "add/add";
@@ -1207,7 +1209,13 @@ static int merge_content(struct merge_options *o,
b.mode = b_mode;
mfi = merge_file(o, &one, &a, &b, o->branch1, o->branch2);
- if (mfi.clean && sha_eq(mfi.sha, a_sha) && mfi.mode == a.mode)
+ if (df_rename_conflict_branch &&
+ lstat(path, &st) == 0 && S_ISDIR(st.st_mode)) {
+ df_conflict_remains = 1;
+ }
+
+ if (mfi.clean && !df_conflict_remains &&
+ sha_eq(mfi.sha, a_sha) && mfi.mode == a.mode)
output(o, 3, "Skipped %s (merged same as existing)", path);
else
output(o, 2, "Auto-merging %s", path);
@@ -1219,7 +1227,17 @@ static int merge_content(struct merge_options *o,
reason, path);
}
- update_file(o, mfi.clean, mfi.sha, mfi.mode, path);
+ if (df_conflict_remains) {
+ const char *new_path;
+ update_file_flags(o, mfi.sha, mfi.mode, path,
+ o->call_depth || mfi.clean, 0);
+ new_path = unique_path(o, path, df_rename_conflict_branch);
+ mfi.clean = 0;
+ output(o, 1, "Adding as %s instead", new_path);
+ update_file_flags(o, mfi.sha, mfi.mode, new_path, 0, 1);
+ } else {
+ update_file(o, mfi.clean, mfi.sha, mfi.mode, path);
+ }
return mfi.clean;
}