merge-recursive: Structure process_df_entry() to handle more cases

Modify process_df_entry() (mostly just indentation level changes) to
get it ready for handling more D/F conflict type cases.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Elijah Newren 2010-09-20 02:28:56 -06:00 committed by Junio C Hamano
parent 384c166807
commit 9c0bbb50f0

View File

@ -1336,10 +1336,16 @@ static int process_entry(struct merge_options *o,
} }
/* /*
* Per entry merge function for D/F conflicts, to be called only after * Per entry merge function for D/F (and/or rename) conflicts. In the
* all files below dir have been processed. We do this because in the * cases we can cleanly resolve D/F conflicts, process_entry() can
* cases we can cleanly resolve D/F conflicts, process_entry() can clean * clean out all the files below the directory for us. All D/F
* out all the files below the directory for us. * conflict cases must be handled here at the end to make sure any
* directories that can be cleaned out, are.
*
* Some rename conflicts may also be handled here that don't necessarily
* involve D/F conflicts, since the code to handle them is generic enough
* to handle those rename conflicts with or without D/F conflicts also
* being involved.
*/ */
static int process_df_entry(struct merge_options *o, static int process_df_entry(struct merge_options *o,
const char *path, struct stage_data *entry) const char *path, struct stage_data *entry)
@ -1351,17 +1357,18 @@ static int process_df_entry(struct merge_options *o,
unsigned char *o_sha = stage_sha(entry->stages[1].sha, o_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 *a_sha = stage_sha(entry->stages[2].sha, a_mode);
unsigned char *b_sha = stage_sha(entry->stages[3].sha, b_mode); unsigned char *b_sha = stage_sha(entry->stages[3].sha, b_mode);
struct stat st;
entry->processed = 1;
if (entry->rename_df_conflict_info) {
die("Not yet implemented.");
} else if (!o_sha && !!a_sha != !!b_sha) {
/* directory -> (directory, file) */
const char *add_branch; const char *add_branch;
const char *other_branch; const char *other_branch;
unsigned mode; unsigned mode;
const unsigned char *sha; const unsigned char *sha;
const char *conf; const char *conf;
struct stat st;
if (!((!o_sha && a_sha && !b_sha) || (!o_sha && !a_sha && b_sha)))
return 1; /* we don't handle non D-F cases */
entry->processed = 1;
if (a_sha) { if (a_sha) {
add_branch = o->branch1; add_branch = o->branch1;
@ -1388,6 +1395,10 @@ static int process_df_entry(struct merge_options *o,
output(o, 2, "Adding %s", path); output(o, 2, "Adding %s", path);
update_file(o, 1, sha, mode, path); update_file(o, 1, sha, mode, path);
} }
} else {
entry->processed = 0;
return 1; /* not handled; assume clean until processed */
}
return clean_merge; return clean_merge;
} }