merge-recursive: clarify the rename_dir/RENAME_DIR meaning
We had an enum of rename types which included RENAME_DIR; this name felt misleading since it was not about an entire directory but was a status for each individual file add that occurred within a renamed directory. Since this type is for signifying that the files in question were being renamed due to directory rename detection, rename this enum value to RENAME_VIA_DIR. Make a similar change to the conflict_rename_dir() function, and add a comment to the top of that function explaining its purpose (it may not be quite as obvious as for the other conflict_rename_*() functions). Acked-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Elijah Newren committed
Jun 9, 2018 at 21:16 UTC
5455c33839c6c5d248007ad2b49e8a225e9f47fa
1 file changed
+17
-11
merge-recursive.c
+17
-11
@@ -181,7 +181,7 @@ static int oid_eq(const struct object_id *a, const struct object_id *b)
181
182
enum rename_type {
183
RENAME_NORMAL = 0,
184
- RENAME_DIR,
184
+ RENAME_VIA_DIR,
185
RENAME_DELETE,
186
RENAME_ONE_FILE_TO_ONE,
187
RENAME_ONE_FILE_TO_TWO,
@@ -1410,11 +1410,17 @@ static int merge_file_one(struct merge_options *o,
1410
return merge_file_1(o, &one, &a, &b, path, branch1, branch2, mfi);
1411
}
1412
1413
-static int conflict_rename_dir(struct merge_options *o,
1414
- struct diff_filepair *pair,
1415
- const char *rename_branch,
1416
- const char *other_branch)
1413
+static int conflict_rename_via_dir(struct merge_options *o,
1414
+ struct diff_filepair *pair,
1415
+ const char *rename_branch,
1416
+ const char *other_branch)
1417
{
1418
+ /*
1419
+ * Handle file adds that need to be renamed due to directory rename
1420
+ * detection. This differs from handle_rename_normal, because
1421
+ * there is no content merge to do; just move the file into the
1422
+ * desired final location.
1423
+ */
1424
const struct diff_filespec *dest = pair->two;
1425
1426
if (!o->call_depth && would_lose_untracked(dest->path)) {
@@ -2692,7 +2698,7 @@ static int process_renames(struct merge_options *o,
2698
2699
if (oid_eq(&src_other.oid, &null_oid) &&
2700
ren1->add_turned_into_rename) {
2695
- setup_rename_conflict_info(RENAME_DIR,
2701
+ setup_rename_conflict_info(RENAME_VIA_DIR,
2702
ren1->pair,
2703
NULL,
2704
branch1,
@@ -3138,12 +3144,12 @@ static int process_entry(struct merge_options *o,
3144
b_oid, b_mode,
3145
conflict_info);
3146
break;
3141
- case RENAME_DIR:
3147
+ case RENAME_VIA_DIR:
3148
clean_merge = 1;
3143
- if (conflict_rename_dir(o,
3144
- conflict_info->pair1,
3145
- conflict_info->branch1,
3146
- conflict_info->branch2))
3149
+ if (conflict_rename_via_dir(o,
3150
+ conflict_info->pair1,
3151
+ conflict_info->branch1,
3152
+ conflict_info->branch2))
3153
clean_merge = -1;
3154
break;
3155
case RENAME_DELETE: