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
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
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
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
_("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
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
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
/* 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