summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--merge-recursive.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/merge-recursive.c b/merge-recursive.c
index 3096594..0e25956 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -1018,9 +1018,9 @@ static int process_renames(struct path_list *a_renames,
return clean_merge;
}
-static unsigned char *has_sha(const unsigned char *sha)
+static unsigned char *stage_sha(const unsigned char *sha, unsigned mode)
{
- return is_null_sha1(sha) ? NULL: (unsigned char *)sha;
+ return (is_null_sha1(sha) || mode == 0) ? NULL: (unsigned char *)sha;
}
/* Per entry merge function */
@@ -1033,12 +1033,12 @@ static int process_entry(const char *path, struct stage_data *entry,
print_index_entry("\tpath: ", entry);
*/
int clean_merge = 1;
- unsigned char *o_sha = has_sha(entry->stages[1].sha);
- unsigned char *a_sha = has_sha(entry->stages[2].sha);
- unsigned char *b_sha = has_sha(entry->stages[3].sha);
unsigned o_mode = entry->stages[1].mode;
unsigned a_mode = entry->stages[2].mode;
unsigned b_mode = entry->stages[3].mode;
+ unsigned char *o_sha = stage_sha(entry->stages[1].sha, o_mode);
+ unsigned char *a_sha = stage_sha(entry->stages[2].sha, a_mode);
+ unsigned char *b_sha = stage_sha(entry->stages[3].sha, b_mode);
if (o_sha && (!a_sha || !b_sha)) {
/* Case A: Deleted in one */
@@ -1139,6 +1139,12 @@ static int process_entry(const char *path, struct stage_data *entry,
update_file_flags(mfi.sha, mfi.mode, path,
0 /* update_cache */, 1 /* update_working_directory */);
}
+ } else if (!o_sha && !a_sha && !b_sha) {
+ /*
+ * this entry was deleted altogether. a_mode == 0 means
+ * we had that path and want to actively remove it.
+ */
+ remove_file(1, path, !a_mode);
} else
die("Fatal merge failure, shouldn't happen.");