merge-recursive: cleanup handle_rename_* function signatures
Instead of passing various bits and pieces of 'ci', just pass it directly. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Elijah Newren committed
Apr 5, 2019 at 08:00 UTC
e2d563dfa9951683a118e728dee99bd07a90e52d
1 file changed
+15
-16
merge-recursive.c
+15
-16
@@ -1357,8 +1357,7 @@ static int merge_mode_and_contents(struct merge_options *opt,
1357
}
1358
1359
static int handle_rename_via_dir(struct merge_options *opt,
1360
- struct diff_filepair *pair,
1361
- const char *rename_branch)
1360
+ struct rename_conflict_info *ci)
1361
{
1362
/*
1363
* Handle file adds that need to be renamed due to directory rename
@@ -1366,10 +1365,11 @@ static int handle_rename_via_dir(struct merge_options *opt,
1365
* there is no content merge to do; just move the file into the
1366
* desired final location.
1367
*/
1369
- const struct diff_filespec *dest = pair->two;
1368
+ const struct rename *ren = ci->ren1;
1369
+ const struct diff_filespec *dest = ren->pair->two;
1370
1371
if (!opt->call_depth && would_lose_untracked(opt, dest->path)) {
1372
- char *alt_path = unique_path(opt, dest->path, rename_branch);
1372
+ char *alt_path = unique_path(opt, dest->path, ren->branch);
1373
1374
output(opt, 1, _("Error: Refusing to lose untracked file at %s; "
1375
"writing to %s instead."),
@@ -1383,8 +1383,8 @@ static int handle_rename_via_dir(struct merge_options *opt,
1383
return -1;
1384
free(alt_path);
1385
return update_stages(opt, dest->path, NULL,
1386
- rename_branch == opt->branch1 ? dest : NULL,
1387
- rename_branch == opt->branch1 ? NULL : dest);
1386
+ ren->branch == opt->branch1 ? dest : NULL,
1387
+ ren->branch == opt->branch1 ? NULL : dest);
1388
}
1389
1390
/* Update dest->path both in index and in worktree */
@@ -1476,12 +1476,14 @@ static int handle_change_delete(struct merge_options *opt,
1476
}
1477
1478
static int handle_rename_delete(struct merge_options *opt,
1479
- struct diff_filepair *pair,
1480
- const char *rename_branch,
1481
- const char *delete_branch)
1479
+ struct rename_conflict_info *ci)
1480
{
1483
- const struct diff_filespec *orig = pair->one;
1484
- const struct diff_filespec *dest = pair->two;
1481
+ const struct rename *ren = ci->ren1;
1482
+ const struct diff_filespec *orig = ren->pair->one;
1483
+ const struct diff_filespec *dest = ren->pair->two;
1484
+ const char *rename_branch = ren->branch;
1485
+ const char *delete_branch = (opt->branch1 == ren->branch ?
1486
+ opt->branch2 : opt->branch1);
1487
1488
if (handle_change_delete(opt,
1489
opt->call_depth ? orig->path : dest->path,
@@ -3184,8 +3186,7 @@ static int process_entry(struct merge_options *opt,
3186
break;
3187
case RENAME_VIA_DIR:
3188
clean_merge = 1;
3187
- if (handle_rename_via_dir(opt, ci->ren1->pair,
3188
- ci->ren1->branch))
3189
+ if (handle_rename_via_dir(opt, ci))
3190
clean_merge = -1;
3191
break;
3192
case RENAME_ADD:
@@ -3199,9 +3200,7 @@ static int process_entry(struct merge_options *opt,
3200
break;
3201
case RENAME_DELETE:
3202
clean_merge = 0;
3202
- if (handle_rename_delete(opt, ci->ren1->pair,
3203
- ci->ren1->branch,
3204
- ci->ren1->branch == opt->branch1 ? opt->branch2 : opt->branch1))
3203
+ if (handle_rename_delete(opt, ci))
3204
clean_merge = -1;
3205
break;
3206
case RENAME_ONE_FILE_TO_TWO: