Skip to content

Commit

Permalink
merge-recursive: New function to assist resolving renames in-core only
Browse files Browse the repository at this point in the history
process_renames() and process_entry() have nearly identical code for
doing three-way file merging to resolve content changes.  Since we are
already deferring some of the current rename handling in order to better
handle D/F conflicts, it seems to make sense to defer content merging as
well and remove the (nearly) duplicated code sections for handling this
merging.

To facilitate this process, add a new update_stages_and_entry() function
which will map the higher stage index entries from two files involved in a
rename into the resulting rename destination's index entries, and update
the associated stage_data structure.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Elijah Newren authored and Junio C Hamano committed Sep 30, 2010
1 parent 25c3936 commit 2ff739f
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions merge-recursive.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,11 +417,10 @@ static struct string_list *get_renames(struct merge_options *o,
return renames;
}

static int update_stages(const char *path, struct diff_filespec *o,
static int update_stages_options(const char *path, struct diff_filespec *o,
struct diff_filespec *a, struct diff_filespec *b,
int clear)
int clear, int options)
{
int options = ADD_CACHE_OK_TO_ADD | ADD_CACHE_OK_TO_REPLACE;
if (clear)
if (remove_file_from_cache(path))
return -1;
Expand All @@ -437,6 +436,34 @@ static int update_stages(const char *path, struct diff_filespec *o,
return 0;
}

static int update_stages(const char *path, struct diff_filespec *o,
struct diff_filespec *a, struct diff_filespec *b,
int clear)
{
int options = ADD_CACHE_OK_TO_ADD | ADD_CACHE_OK_TO_REPLACE;
return update_stages_options(path, o, a, b, clear, options);
}

static int update_stages_and_entry(const char *path,
struct stage_data *entry,
struct diff_filespec *o,
struct diff_filespec *a,
struct diff_filespec *b,
int clear)
{
int options;

entry->processed = 0;
entry->stages[1].mode = o->mode;
entry->stages[2].mode = a->mode;
entry->stages[3].mode = b->mode;
hashcpy(entry->stages[1].sha, o->sha1);
hashcpy(entry->stages[2].sha, a->sha1);
hashcpy(entry->stages[3].sha, b->sha1);
options = ADD_CACHE_OK_TO_ADD | ADD_CACHE_SKIP_DFCHECK;
return update_stages_options(path, o, a, b, clear, options);
}

static int remove_file(struct merge_options *o, int clean,
const char *path, int no_wd)
{
Expand Down

0 comments on commit 2ff739f

Please sign in to comment.