@@ -1357,19 +1357,19 @@ static int merge_mode_and_contents(struct merge_options *opt,
1357
1357
}
1358
1358
1359
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 )
1362
1361
{
1363
1362
/*
1364
1363
* Handle file adds that need to be renamed due to directory rename
1365
1364
* detection. This differs from handle_rename_normal, because
1366
1365
* there is no content merge to do; just move the file into the
1367
1366
* desired final location.
1368
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
1370
1371
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
1373
1374
1374
output (opt , 1 , _ ("Error: Refusing to lose untracked file at %s; "
1375
1375
"writing to %s instead." ),
@@ -1383,8 +1383,8 @@ static int handle_rename_via_dir(struct merge_options *opt,
1383
1383
return -1 ;
1384
1384
free (alt_path );
1385
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
1388
}
1389
1389
1390
1390
/* Update dest->path both in index and in worktree */
@@ -1476,12 +1476,14 @@ static int handle_change_delete(struct merge_options *opt,
1476
1476
}
1477
1477
1478
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 )
1482
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 );
1485
1487
1486
1488
if (handle_change_delete (opt ,
1487
1489
opt -> call_depth ? orig -> path : dest -> path ,
@@ -3184,8 +3186,7 @@ static int process_entry(struct merge_options *opt,
3184
3186
break ;
3185
3187
case RENAME_VIA_DIR :
3186
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 ))
3189
3190
clean_merge = -1 ;
3190
3191
break ;
3191
3192
case RENAME_ADD :
@@ -3199,9 +3200,7 @@ static int process_entry(struct merge_options *opt,
3199
3200
break ;
3200
3201
case RENAME_DELETE :
3201
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 ))
3205
3204
clean_merge = -1 ;
3206
3205
break ;
3207
3206
case RENAME_ONE_FILE_TO_TWO :
0 commit comments