merge_file previously required diff_filespec arguments, but all callers only had sha1s and modes. Rename merge_file to merge_file_1 and introduce a new merge_file convenience function which takes the sha1s and modes and creates the temporary diff_filespec variables needed to call merge_file_1. Signed-off-by: Elijah Newren <newren@xxxxxxxxx> --- merge-recursive.c | 74 +++++++++++++++++++++++++++------------------------- 1 files changed, 38 insertions(+), 36 deletions(-) diff --git a/merge-recursive.c b/merge-recursive.c index 5a70a87..3a364fa 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -831,12 +831,12 @@ static int merge_3way(struct merge_options *o, return merge_status; } -static struct merge_file_info merge_file(struct merge_options *o, - const struct diff_filespec *one, - const struct diff_filespec *a, - const struct diff_filespec *b, - const char *branch1, - const char *branch2) +static struct merge_file_info merge_file_1(struct merge_options *o, + const struct diff_filespec *one, + const struct diff_filespec *a, + const struct diff_filespec *b, + const char *branch1, + const char *branch2) { struct merge_file_info result; result.merge = 0; @@ -905,6 +905,26 @@ static struct merge_file_info merge_file(struct merge_options *o, return result; } +static struct merge_file_info merge_file(struct merge_options *o, + const char *path, + const unsigned char *o_sha, int o_mode, + const unsigned char *a_sha, int a_mode, + const unsigned char *b_sha, int b_mode, + const char *branch1, + const char *branch2) +{ + struct diff_filespec one, a, b; + + one.path = a.path = b.path = (char*)path; + hashcpy(one.sha1, o_sha); + one.mode = o_mode; + hashcpy(a.sha1, a_sha); + a.mode = a_mode; + hashcpy(b.sha1, b_sha); + b.mode = b_mode; + return merge_file_1(o, &one, &a, &b, branch1, branch2); +} + static void conflict_rename_delete(struct merge_options *o, struct diff_filepair *pair, const char *rename_branch, @@ -1002,16 +1022,10 @@ static void conflict_rename_rename_2to1(struct merge_options *o, /* Two files were renamed to the same thing. */ if (o->call_depth) { struct merge_file_info mfi; - struct diff_filespec one, a, b; - - one.path = a.path = b.path = path; - hashcpy(one.sha1, null_sha1); - one.mode = 0; - hashcpy(a.sha1, ren1->pair->two->sha1); - a.mode = ren1->pair->two->mode; - hashcpy(b.sha1, ren2->pair->two->sha1); - b.mode = ren2->pair->two->mode; - mfi = merge_file(o, &one, &a, &b, branch1, branch2); + mfi = merge_file(o, path, null_sha1, 0, + ren1->pair->two->sha1, ren1->pair->two->mode, + ren2->pair->two->sha1, ren2->pair->two->mode, + branch1, branch2); output(o, 1, "Adding merged %s", path); update_file(o, 0, mfi.sha, mfi.mode, path); } else { @@ -1198,24 +1212,12 @@ static int process_renames(struct merge_options *o, ren1_dst, branch2); if (o->call_depth) { struct merge_file_info mfi; - struct diff_filespec one, a, b; - - one.path = a.path = b.path = - (char *)ren1_dst; - hashcpy(one.sha1, null_sha1); - one.mode = 0; - hashcpy(a.sha1, ren1->pair->two->sha1); - a.mode = ren1->pair->two->mode; - hashcpy(b.sha1, dst_other.sha1); - b.mode = dst_other.mode; - mfi = merge_file(o, &one, &a, &b, - branch1, - branch2); + mfi = merge_file(o, ren1_dst, null_sha1, 0, + ren1->pair->two->sha1, ren1->pair->two->mode, + dst_other.sha1, dst_other.mode, + branch1, branch2); output(o, 1, "Adding merged %s", ren1_dst); - update_file(o, 0, - mfi.sha, - mfi.mode, - ren1_dst); + update_file(o, 0, mfi.sha, mfi.mode, ren1_dst); try_merge = 0; } else { char *new_path = unique_path(o, ren1_dst, branch2); @@ -1388,13 +1390,13 @@ static int merge_content(struct merge_options *o, if (dir_in_way(path, !o->call_depth)) df_conflict_remains = 1; } - mfi = merge_file(o, &one, &a, &b, - side1 ? side1:o->branch1, side2 ? side2:o->branch2); + mfi = merge_file_1(o, &one, &a, &b, + side1 ? side1:o->branch1, side2 ? side2:o->branch2); free(side1); free(side2); if (mfi.clean && !df_conflict_remains && - sha_eq(mfi.sha, a_sha) && mfi.mode == a.mode && + sha_eq(mfi.sha, a_sha) && mfi.mode == a_mode && was_tracked(path)) { output(o, 3, "Skipped %s (merged same as existing)", path); add_cacheinfo(mfi.mode, mfi.sha, path, -- 1.7.6.rc0.62.g2d69f -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html