merge-recursive: rename merge_file_1() and merge_content()

Summary: merge_file_1() -> merge_mode_and_contents() merge_content() -> handle_content_merge() merge_file_1() is a very unhelpful name. Rename it to merge_mode_and_contents() to reflect what it does. merge_content() calls merge_mode_and_contents() to do the main part of its work, but most of this function was about higher level stuff, e.g. printing out conflict messages, updating skip_worktree bits, checking for ability to avoid updating the working tree or for D/F conflicts being in the way, etc. Since there are several handle_*() functions for similar levels of checking and handling in merge-recursive.c (e.g. handle_change_delete(), handle_rename_rename_2to1()), let's rename this function to handle_content_merge(). Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Elijah Newren committed Sep 19, 2018 at 09:14 UTC d95735567550e87c8e58a92126c45f1a3875603a
1 file changed +34 -32
merge-recursive.c
+34 -32
@@ -1274,14 +1274,14 @@ static int merge_submodule(struct merge_options *o,
1274 return 0;
1275 }
1276
1277 -static int merge_file_1(struct merge_options *o,
1278 - const struct diff_filespec *one,
1279 - const struct diff_filespec *a,
1280 - const struct diff_filespec *b,
1281 - const char *filename,
1282 - const char *branch1,
1283 - const char *branch2,
1284 - struct merge_file_info *result)
1277 +static int merge_mode_and_contents(struct merge_options *o,
1278 + const struct diff_filespec *one,
1279 + const struct diff_filespec *a,
1280 + const struct diff_filespec *b,
1281 + const char *filename,
1282 + const char *branch1,
1283 + const char *branch2,
1284 + struct merge_file_info *result)
1285 {
1286 result->merge = 0;
1287 result->clean = 1;
@@ -1609,8 +1609,8 @@ static int handle_rename_rename_1to2(struct merge_options *o,
1609 struct merge_file_info mfi;
1610 struct diff_filespec other;
1611 struct diff_filespec *add;
1612 - if (merge_file_1(o, one, a, b, one->path,
1613 - ci->branch1, ci->branch2, &mfi))
1612 + if (merge_mode_and_contents(o, one, a, b, one->path,
1613 + ci->branch1, ci->branch2, &mfi))
1614 return -1;
1615
1616 /*
@@ -1676,10 +1676,10 @@ static int handle_rename_rename_2to1(struct merge_options *o,
1676
1677 path_side_1_desc = xstrfmt("%s (was %s)", path, a->path);
1678 path_side_2_desc = xstrfmt("%s (was %s)", path, b->path);
1679 - if (merge_file_1(o, a, c1, &ci->ren1_other, path_side_1_desc,
1680 - o->branch1, o->branch2, &mfi_c1) ||
1681 - merge_file_1(o, b, &ci->ren2_other, c2, path_side_2_desc,
1682 - o->branch1, o->branch2, &mfi_c2))
1679 + if (merge_mode_and_contents(o, a, c1, &ci->ren1_other, path_side_1_desc,
1680 + o->branch1, o->branch2, &mfi_c1) ||
1681 + merge_mode_and_contents(o, b, &ci->ren2_other, c2, path_side_2_desc,
1682 + o->branch1, o->branch2, &mfi_c2))
1683 return -1;
1684 free(path_side_1_desc);
1685 free(path_side_2_desc);
@@ -2723,9 +2723,9 @@ static int process_renames(struct merge_options *o,
2723 b.mode = dst_other.mode;
2724 b.path = one.path;
2725
2726 - if (merge_file_1(o, &one, &a, &b, ren1_dst,
2727 - branch1, branch2,
2728 - &mfi)) {
2726 + if (merge_mode_and_contents(o, &one, &a, &b, ren1_dst,
2727 + branch1, branch2,
2728 + &mfi)) {
2729 clean_merge = -1;
2730 goto cleanup_and_return;
2731 }
@@ -2975,13 +2975,13 @@ static int handle_modify_delete(struct merge_options *o,
2975 _("modify"), _("modified"));
2976 }
2977
2978 -static int merge_content(struct merge_options *o,
2979 - const char *path,
2980 - int is_dirty,
2981 - struct object_id *o_oid, int o_mode,
2982 - struct object_id *a_oid, int a_mode,
2983 - struct object_id *b_oid, int b_mode,
2984 - struct rename_conflict_info *rename_conflict_info)
2978 +static int handle_content_merge(struct merge_options *o,
2979 + const char *path,
2980 + int is_dirty,
2981 + struct object_id *o_oid, int o_mode,
2982 + struct object_id *a_oid, int a_mode,
2983 + struct object_id *b_oid, int b_mode,
2984 + struct rename_conflict_info *rename_conflict_info)
2985 {
2986 const char *reason = _("content");
2987 const char *path1 = NULL, *path2 = NULL;
@@ -3021,8 +3021,8 @@ static int merge_content(struct merge_options *o,
3021 S_ISGITLINK(pair1->two->mode)))
3022 df_conflict_remains = 1;
3023 }
3024 - if (merge_file_1(o, &one, &a, &b, path,
3025 - o->branch1, o->branch2, &mfi))
3024 + if (merge_mode_and_contents(o, &one, &a, &b, path,
3025 + o->branch1, o->branch2, &mfi))
3026 return -1;
3027
3028 /*
@@ -3113,9 +3113,9 @@ static int handle_rename_normal(struct merge_options *o,
3113 struct rename_conflict_info *ci)
3114 {
3115 /* Merge the content and write it out */
3116 - return merge_content(o, path, was_dirty(o, path),
3117 - o_oid, o_mode, a_oid, a_mode, b_oid, b_mode,
3118 - ci);
3116 + return handle_content_merge(o, path, was_dirty(o, path),
3117 + o_oid, o_mode, a_oid, a_mode, b_oid, b_mode,
3118 + ci);
3119 }
3120
3121 /* Per entry merge function */
@@ -3239,9 +3239,11 @@ static int process_entry(struct merge_options *o,
3239 /* Case C: Added in both (check for same permissions) and */
3240 /* case D: Modified in both, but differently. */
3241 int is_dirty = 0; /* unpack_trees would have bailed if dirty */
3242 - clean_merge = merge_content(o, path, is_dirty,
3243 - o_oid, o_mode, a_oid, a_mode, b_oid, b_mode,
3244 - NULL);
3242 + clean_merge = handle_content_merge(o, path, is_dirty,
3243 + o_oid, o_mode,
3244 + a_oid, a_mode,
3245 + b_oid, b_mode,
3246 + NULL);
3247 } else if (!o_oid && !a_oid && !b_oid) {
3248 /*
3249 * this entry was deleted altogether. a_mode == 0 means