From: Elijah Newren Date: Mon, 20 Sep 2010 08:28:54 +0000 (-0600) Subject: merge-recursive: New function to assist resolving renames in-core only X-Git-Tag: v1.7.4-rc0~101^2~18 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=2ff739f9d2fd2f34e7a7bfb9b5f2d1d2b2ec5326;p=git.git merge-recursive: New function to assist resolving renames in-core only 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 Signed-off-by: Junio C Hamano --- diff --git a/merge-recursive.c b/merge-recursive.c index 6ea4e3d2d..2ba05a5b5 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -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; @@ -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) {