summaryrefslogtreecommitdiff
path: root/merge-recursive.c
diff options
context:
space:
mode:
authorElijah Newren <newren@gmail.com>2011-08-12 05:20:01 (GMT)
committerJunio C Hamano <gitster@pobox.com>2011-08-14 21:19:36 (GMT)
commited0148a520ec2ec88f0574c2e107aba0a46936e1 (patch)
tree3566f61d08552b0022f7e75bc6bf548f17d93c6a /merge-recursive.c
parent86d4b528d8a4752cc689279fb6d38c8697a507bb (diff)
downloadgit-ed0148a520ec2ec88f0574c2e107aba0a46936e1.zip
git-ed0148a520ec2ec88f0574c2e107aba0a46936e1.tar.gz
git-ed0148a520ec2ec88f0574c2e107aba0a46936e1.tar.bz2
merge-recursive: Allow make_room_for_path() to remove D/F entries
If there were several files conflicting below a directory corresponding to a D/F conflict, and the file of that D/F conflict is in the way, we want it to be removed. Since files of D/F conflicts are handled last, they can be reinstated later and possibly with a new unique name. 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.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/merge-recursive.c b/merge-recursive.c
index a30e5a4..5d6fc0d 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -410,7 +410,6 @@ static void record_df_conflict_files(struct merge_options *o,
len > last_len &&
memcmp(path, last_file, last_len) == 0 &&
path[last_len] == '/') {
- output(o, 3, "Removing %s to make room for subdirectory; may re-add later.", last_file);
string_list_insert(&o->df_conflict_file_set, last_file);
}
@@ -650,11 +649,30 @@ static int would_lose_untracked(const char *path)
return !was_tracked(path) && file_exists(path);
}
-static int make_room_for_path(const char *path)
+static int make_room_for_path(struct merge_options *o, const char *path)
{
- int status;
+ int status, i;
const char *msg = "failed to create path '%s'%s";
+ /* Unlink any D/F conflict files that are in the way */
+ for (i = 0; i < o->df_conflict_file_set.nr; i++) {
+ const char *df_path = o->df_conflict_file_set.items[i].string;
+ size_t pathlen = strlen(path);
+ size_t df_pathlen = strlen(df_path);
+ if (df_pathlen < pathlen &&
+ path[df_pathlen] == '/' &&
+ strncmp(path, df_path, df_pathlen) == 0) {
+ output(o, 3,
+ "Removing %s to make room for subdirectory\n",
+ df_path);
+ unlink(df_path);
+ unsorted_string_list_delete_item(&o->df_conflict_file_set,
+ i, 0);
+ break;
+ }
+ }
+
+ /* Make sure leading directories are created */
status = safe_create_leading_directories_const(path);
if (status) {
if (status == -3) {
@@ -722,7 +740,7 @@ static void update_file_flags(struct merge_options *o,
}
}
- if (make_room_for_path(path) < 0) {
+ if (make_room_for_path(o, path) < 0) {
update_wd = 0;
free(buf);
goto update_index;