Skip to content

Commit d957355

Browse files
newrengitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0270a07 commit d957355

File tree

1 file changed

+34
-32
lines changed

1 file changed

+34
-32
lines changed

merge-recursive.c

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1274,14 +1274,14 @@ static int merge_submodule(struct merge_options *o,
12741274
return 0;
12751275
}
12761276

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)
12851285
{
12861286
result->merge = 0;
12871287
result->clean = 1;
@@ -1609,8 +1609,8 @@ static int handle_rename_rename_1to2(struct merge_options *o,
16091609
struct merge_file_info mfi;
16101610
struct diff_filespec other;
16111611
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))
16141614
return -1;
16151615

16161616
/*
@@ -1676,10 +1676,10 @@ static int handle_rename_rename_2to1(struct merge_options *o,
16761676

16771677
path_side_1_desc = xstrfmt("%s (was %s)", path, a->path);
16781678
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))
16831683
return -1;
16841684
free(path_side_1_desc);
16851685
free(path_side_2_desc);
@@ -2723,9 +2723,9 @@ static int process_renames(struct merge_options *o,
27232723
b.mode = dst_other.mode;
27242724
b.path = one.path;
27252725

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)) {
27292729
clean_merge = -1;
27302730
goto cleanup_and_return;
27312731
}
@@ -2975,13 +2975,13 @@ static int handle_modify_delete(struct merge_options *o,
29752975
_("modify"), _("modified"));
29762976
}
29772977

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)
29852985
{
29862986
const char *reason = _("content");
29872987
const char *path1 = NULL, *path2 = NULL;
@@ -3021,8 +3021,8 @@ static int merge_content(struct merge_options *o,
30213021
S_ISGITLINK(pair1->two->mode)))
30223022
df_conflict_remains = 1;
30233023
}
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))
30263026
return -1;
30273027

30283028
/*
@@ -3113,9 +3113,9 @@ static int handle_rename_normal(struct merge_options *o,
31133113
struct rename_conflict_info *ci)
31143114
{
31153115
/* 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);
31193119
}
31203120

31213121
/* Per entry merge function */
@@ -3239,9 +3239,11 @@ static int process_entry(struct merge_options *o,
32393239
/* Case C: Added in both (check for same permissions) and */
32403240
/* case D: Modified in both, but differently. */
32413241
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);
32453247
} else if (!o_oid && !a_oid && !b_oid) {
32463248
/*
32473249
* this entry was deleted altogether. a_mode == 0 means

0 commit comments

Comments
 (0)