Skip to content

Commit e2d563d

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

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

merge-recursive.c

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1357,19 +1357,19 @@ static int merge_mode_and_contents(struct merge_options *opt,
13571357
}
13581358

13591359
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)
13621361
{
13631362
/*
13641363
* Handle file adds that need to be renamed due to directory rename
13651364
* detection. This differs from handle_rename_normal, because
13661365
* there is no content merge to do; just move the file into the
13671366
* desired final location.
13681367
*/
1369-
const struct diff_filespec *dest = pair->two;
1368+
const struct rename *ren = ci->ren1;
1369+
const struct diff_filespec *dest = ren->pair->two;
13701370

13711371
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);
13731373

13741374
output(opt, 1, _("Error: Refusing to lose untracked file at %s; "
13751375
"writing to %s instead."),
@@ -1383,8 +1383,8 @@ static int handle_rename_via_dir(struct merge_options *opt,
13831383
return -1;
13841384
free(alt_path);
13851385
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);
13881388
}
13891389

13901390
/* Update dest->path both in index and in worktree */
@@ -1476,12 +1476,14 @@ static int handle_change_delete(struct merge_options *opt,
14761476
}
14771477

14781478
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)
14821480
{
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);
14851487

14861488
if (handle_change_delete(opt,
14871489
opt->call_depth ? orig->path : dest->path,
@@ -3184,8 +3186,7 @@ static int process_entry(struct merge_options *opt,
31843186
break;
31853187
case RENAME_VIA_DIR:
31863188
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))
31893190
clean_merge = -1;
31903191
break;
31913192
case RENAME_ADD:
@@ -3199,9 +3200,7 @@ static int process_entry(struct merge_options *opt,
31993200
break;
32003201
case RENAME_DELETE:
32013202
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))
32053204
clean_merge = -1;
32063205
break;
32073206
case RENAME_ONE_FILE_TO_TWO:

0 commit comments

Comments
 (0)