@@ -182,7 +182,7 @@ static int oid_eq(const struct object_id *a, const struct object_id *b)
182
182
183
183
enum rename_type {
184
184
RENAME_NORMAL = 0 ,
185
- RENAME_DIR ,
185
+ RENAME_VIA_DIR ,
186
186
RENAME_DELETE ,
187
187
RENAME_ONE_FILE_TO_ONE ,
188
188
RENAME_ONE_FILE_TO_TWO ,
@@ -312,8 +312,8 @@ static void output_commit_title(struct merge_options *o, struct commit *commit)
312
312
}
313
313
314
314
static int add_cacheinfo (struct merge_options * o ,
315
- unsigned int mode , const struct object_id * oid ,
316
- const char * path , int stage , int refresh , int options )
315
+ unsigned int mode , const struct object_id * oid ,
316
+ const char * path , int stage , int refresh , int options )
317
317
{
318
318
struct cache_entry * ce ;
319
319
int ret ;
@@ -420,8 +420,8 @@ struct tree *write_tree_from_memory(struct merge_options *o)
420
420
}
421
421
422
422
static int save_files_dirs (const struct object_id * oid ,
423
- struct strbuf * base , const char * path ,
424
- unsigned int mode , int stage , void * context )
423
+ struct strbuf * base , const char * path ,
424
+ unsigned int mode , int stage , void * context )
425
425
{
426
426
struct path_hashmap_entry * entry ;
427
427
int baselen = base -> len ;
@@ -542,7 +542,7 @@ static void record_df_conflict_files(struct merge_options *o,
542
542
struct string_list * entries )
543
543
{
544
544
/* If there is a D/F conflict and the file for such a conflict
545
- * currently exist in the working tree, we want to allow it to be
545
+ * currently exists in the working tree, we want to allow it to be
546
546
* removed to make room for the corresponding directory if needed.
547
547
* The files underneath the directories of such D/F conflicts will
548
548
* be processed before the corresponding file involved in the D/F
@@ -916,7 +916,7 @@ static int make_room_for_path(struct merge_options *o, const char *path)
916
916
*/
917
917
if (would_lose_untracked (path ))
918
918
return err (o , _ ("refusing to lose untracked file at '%s'" ),
919
- path );
919
+ path );
920
920
921
921
/* Successful unlink is good.. */
922
922
if (!unlink (path ))
@@ -995,16 +995,16 @@ static int update_file_flags(struct merge_options *o,
995
995
unlink (path );
996
996
if (symlink (lnk , path ))
997
997
ret = err (o , _ ("failed to symlink '%s': %s" ),
998
- path , strerror (errno ));
998
+ path , strerror (errno ));
999
999
free (lnk );
1000
1000
} else
1001
1001
ret = err (o ,
1002
1002
_ ("do not know what to do with %06o %s '%s'" ),
1003
1003
mode , oid_to_hex (oid ), path );
1004
- free_buf :
1004
+ free_buf :
1005
1005
free (buf );
1006
1006
}
1007
- update_index :
1007
+ update_index :
1008
1008
if (!ret && update_cache )
1009
1009
if (add_cacheinfo (o , mode , oid , path , 0 , update_wd ,
1010
1010
ADD_CACHE_OK_TO_ADD ))
@@ -1093,7 +1093,7 @@ static int merge_3way(struct merge_options *o,
1093
1093
}
1094
1094
1095
1095
static int find_first_merges (struct object_array * result , const char * path ,
1096
- struct commit * a , struct commit * b )
1096
+ struct commit * a , struct commit * b )
1097
1097
{
1098
1098
int i , j ;
1099
1099
struct object_array merges = OBJECT_ARRAY_INIT ;
@@ -1111,7 +1111,7 @@ static int find_first_merges(struct object_array *result, const char *path,
1111
1111
1112
1112
/* get all revisions that merge commit a */
1113
1113
xsnprintf (merged_revision , sizeof (merged_revision ), "^%s" ,
1114
- oid_to_hex (& a -> object .oid ));
1114
+ oid_to_hex (& a -> object .oid ));
1115
1115
init_revisions (& revs , NULL );
1116
1116
rev_opts .submodule = path ;
1117
1117
/* FIXME: can't handle linked worktrees in submodules yet */
@@ -1253,12 +1253,12 @@ static int merge_submodule(struct merge_options *o,
1253
1253
output (o , 2 , _ ("Found a possible merge resolution for the submodule:\n" ));
1254
1254
print_commit ((struct commit * ) merges .objects [0 ].item );
1255
1255
output (o , 2 , _ (
1256
- "If this is correct simply add it to the index "
1257
- "for example\n"
1258
- "by using:\n\n"
1259
- " git update-index --cacheinfo 160000 %s \"%s\"\n\n"
1260
- "which will accept this suggestion.\n" ),
1261
- oid_to_hex (& merges .objects [0 ].item -> oid ), path );
1256
+ "If this is correct simply add it to the index "
1257
+ "for example\n"
1258
+ "by using:\n\n"
1259
+ " git update-index --cacheinfo 160000 %s \"%s\"\n\n"
1260
+ "which will accept this suggestion.\n" ),
1261
+ oid_to_hex (& merges .objects [0 ].item -> oid ), path );
1262
1262
break ;
1263
1263
1264
1264
default :
@@ -1335,10 +1335,10 @@ static int merge_file_1(struct merge_options *o,
1335
1335
result -> clean = (merge_status == 0 );
1336
1336
} else if (S_ISGITLINK (a -> mode )) {
1337
1337
result -> clean = merge_submodule (o , & result -> oid ,
1338
- one -> path ,
1339
- & one -> oid ,
1340
- & a -> oid ,
1341
- & b -> oid );
1338
+ one -> path ,
1339
+ & one -> oid ,
1340
+ & a -> oid ,
1341
+ & b -> oid );
1342
1342
} else if (S_ISLNK (a -> mode )) {
1343
1343
switch (o -> recursive_variant ) {
1344
1344
case MERGE_RECURSIVE_NORMAL :
@@ -1413,11 +1413,17 @@ static int merge_file_one(struct merge_options *o,
1413
1413
return merge_file_1 (o , & one , & a , & b , path , branch1 , branch2 , mfi );
1414
1414
}
1415
1415
1416
- static int conflict_rename_dir (struct merge_options * o ,
1417
- struct diff_filepair * pair ,
1418
- const char * rename_branch ,
1419
- const char * other_branch )
1416
+ static int handle_rename_via_dir (struct merge_options * o ,
1417
+ struct diff_filepair * pair ,
1418
+ const char * rename_branch ,
1419
+ const char * other_branch )
1420
1420
{
1421
+ /*
1422
+ * Handle file adds that need to be renamed due to directory rename
1423
+ * detection. This differs from handle_rename_normal, because
1424
+ * there is no content merge to do; just move the file into the
1425
+ * desired final location.
1426
+ */
1421
1427
const struct diff_filespec * dest = pair -> two ;
1422
1428
1423
1429
if (!o -> call_depth && would_lose_untracked (dest -> path )) {
@@ -1446,13 +1452,13 @@ static int conflict_rename_dir(struct merge_options *o,
1446
1452
}
1447
1453
1448
1454
static int handle_change_delete (struct merge_options * o ,
1449
- const char * path , const char * old_path ,
1450
- const struct object_id * o_oid , int o_mode ,
1451
- const struct object_id * changed_oid ,
1452
- int changed_mode ,
1453
- const char * change_branch ,
1454
- const char * delete_branch ,
1455
- const char * change , const char * change_past )
1455
+ const char * path , const char * old_path ,
1456
+ const struct object_id * o_oid , int o_mode ,
1457
+ const struct object_id * changed_oid ,
1458
+ int changed_mode ,
1459
+ const char * change_branch ,
1460
+ const char * delete_branch ,
1461
+ const char * change , const char * change_past )
1456
1462
{
1457
1463
char * alt_path = NULL ;
1458
1464
const char * update_path = path ;
@@ -1473,6 +1479,21 @@ static int handle_change_delete(struct merge_options *o,
1473
1479
if (!ret )
1474
1480
ret = update_file (o , 0 , o_oid , o_mode , update_path );
1475
1481
} else {
1482
+ /*
1483
+ * Despite the four nearly duplicate messages and argument
1484
+ * lists below and the ugliness of the nested if-statements,
1485
+ * having complete messages makes the job easier for
1486
+ * translators.
1487
+ *
1488
+ * The slight variance among the cases is due to the fact
1489
+ * that:
1490
+ * 1) directory/file conflicts (in effect if
1491
+ * !alt_path) could cause us to need to write the
1492
+ * file to a different path.
1493
+ * 2) renames (in effect if !old_path) could mean that
1494
+ * there are two names for the path that the user
1495
+ * may know the file by.
1496
+ */
1476
1497
if (!alt_path ) {
1477
1498
if (!old_path ) {
1478
1499
output (o , 1 , _ ("CONFLICT (%s/delete): %s deleted in %s "
@@ -1512,10 +1533,10 @@ static int handle_change_delete(struct merge_options *o,
1512
1533
return ret ;
1513
1534
}
1514
1535
1515
- static int conflict_rename_delete (struct merge_options * o ,
1516
- struct diff_filepair * pair ,
1517
- const char * rename_branch ,
1518
- const char * delete_branch )
1536
+ static int handle_rename_delete (struct merge_options * o ,
1537
+ struct diff_filepair * pair ,
1538
+ const char * rename_branch ,
1539
+ const char * delete_branch )
1519
1540
{
1520
1541
const struct diff_filespec * orig = pair -> one ;
1521
1542
const struct diff_filespec * dest = pair -> two ;
@@ -1617,8 +1638,8 @@ static int handle_file(struct merge_options *o,
1617
1638
return ret ;
1618
1639
}
1619
1640
1620
- static int conflict_rename_rename_1to2 (struct merge_options * o ,
1621
- struct rename_conflict_info * ci )
1641
+ static int handle_rename_rename_1to2 (struct merge_options * o ,
1642
+ struct rename_conflict_info * ci )
1622
1643
{
1623
1644
/* One file was renamed in both branches, but to different names. */
1624
1645
struct diff_filespec * one = ci -> pair1 -> one ;
@@ -1679,8 +1700,8 @@ static int conflict_rename_rename_1to2(struct merge_options *o,
1679
1700
return 0 ;
1680
1701
}
1681
1702
1682
- static int conflict_rename_rename_2to1 (struct merge_options * o ,
1683
- struct rename_conflict_info * ci )
1703
+ static int handle_rename_rename_2to1 (struct merge_options * o ,
1704
+ struct rename_conflict_info * ci )
1684
1705
{
1685
1706
/* Two files, a & b, were renamed to the same thing, c. */
1686
1707
struct diff_filespec * a = ci -> pair1 -> one ;
@@ -2422,7 +2443,7 @@ static void apply_directory_rename_modifications(struct merge_options *o,
2422
2443
* "NOTE" in update_stages(), doing so will modify the current
2423
2444
* in-memory index which will break calls to would_lose_untracked()
2424
2445
* that we need to make. Instead, we need to just make sure that
2425
- * the various conflict_rename_ *() functions update the index
2446
+ * the various handle_rename_ *() functions update the index
2426
2447
* explicitly rather than relying on unpack_trees() to have done it.
2427
2448
*/
2428
2449
get_tree_entry (& tree -> object .oid ,
@@ -2695,7 +2716,7 @@ static int process_renames(struct merge_options *o,
2695
2716
2696
2717
if (oid_eq (& src_other .oid , & null_oid ) &&
2697
2718
ren1 -> add_turned_into_rename ) {
2698
- setup_rename_conflict_info (RENAME_DIR ,
2719
+ setup_rename_conflict_info (RENAME_VIA_DIR ,
2699
2720
ren1 -> pair ,
2700
2721
NULL ,
2701
2722
branch1 ,
@@ -2826,12 +2847,12 @@ static void initial_cleanup_rename(struct diff_queue_struct *pairs,
2826
2847
free (pairs );
2827
2848
}
2828
2849
2829
- static int handle_renames (struct merge_options * o ,
2830
- struct tree * common ,
2831
- struct tree * head ,
2832
- struct tree * merge ,
2833
- struct string_list * entries ,
2834
- struct rename_info * ri )
2850
+ static int detect_and_process_renames (struct merge_options * o ,
2851
+ struct tree * common ,
2852
+ struct tree * head ,
2853
+ struct tree * merge ,
2854
+ struct string_list * entries ,
2855
+ struct rename_info * ri )
2835
2856
{
2836
2857
struct diff_queue_struct * head_pairs , * merge_pairs ;
2837
2858
struct hashmap * dir_re_head , * dir_re_merge ;
@@ -2907,7 +2928,8 @@ static struct object_id *stage_oid(const struct object_id *oid, unsigned mode)
2907
2928
}
2908
2929
2909
2930
static int read_oid_strbuf (struct merge_options * o ,
2910
- const struct object_id * oid , struct strbuf * dst )
2931
+ const struct object_id * oid ,
2932
+ struct strbuf * dst )
2911
2933
{
2912
2934
void * buf ;
2913
2935
enum object_type type ;
@@ -2960,10 +2982,10 @@ static int blob_unchanged(struct merge_options *opt,
2960
2982
}
2961
2983
2962
2984
static int handle_modify_delete (struct merge_options * o ,
2963
- const char * path ,
2964
- struct object_id * o_oid , int o_mode ,
2965
- struct object_id * a_oid , int a_mode ,
2966
- struct object_id * b_oid , int b_mode )
2985
+ const char * path ,
2986
+ struct object_id * o_oid , int o_mode ,
2987
+ struct object_id * a_oid , int a_mode ,
2988
+ struct object_id * b_oid , int b_mode )
2967
2989
{
2968
2990
const char * modify_branch , * delete_branch ;
2969
2991
struct object_id * changed_oid ;
@@ -3101,12 +3123,12 @@ static int merge_content(struct merge_options *o,
3101
3123
return !is_dirty && mfi .clean ;
3102
3124
}
3103
3125
3104
- static int conflict_rename_normal (struct merge_options * o ,
3105
- const char * path ,
3106
- struct object_id * o_oid , unsigned int o_mode ,
3107
- struct object_id * a_oid , unsigned int a_mode ,
3108
- struct object_id * b_oid , unsigned int b_mode ,
3109
- struct rename_conflict_info * ci )
3126
+ static int handle_rename_normal (struct merge_options * o ,
3127
+ const char * path ,
3128
+ struct object_id * o_oid , unsigned int o_mode ,
3129
+ struct object_id * a_oid , unsigned int a_mode ,
3130
+ struct object_id * b_oid , unsigned int b_mode ,
3131
+ struct rename_conflict_info * ci )
3110
3132
{
3111
3133
/* Merge the content and write it out */
3112
3134
return merge_content (o , path , was_dirty (o , path ),
@@ -3133,37 +3155,37 @@ static int process_entry(struct merge_options *o,
3133
3155
switch (conflict_info -> rename_type ) {
3134
3156
case RENAME_NORMAL :
3135
3157
case RENAME_ONE_FILE_TO_ONE :
3136
- clean_merge = conflict_rename_normal (o ,
3137
- path ,
3138
- o_oid , o_mode ,
3139
- a_oid , a_mode ,
3140
- b_oid , b_mode ,
3141
- conflict_info );
3158
+ clean_merge = handle_rename_normal (o ,
3159
+ path ,
3160
+ o_oid , o_mode ,
3161
+ a_oid , a_mode ,
3162
+ b_oid , b_mode ,
3163
+ conflict_info );
3142
3164
break ;
3143
- case RENAME_DIR :
3165
+ case RENAME_VIA_DIR :
3144
3166
clean_merge = 1 ;
3145
- if (conflict_rename_dir (o ,
3146
- conflict_info -> pair1 ,
3147
- conflict_info -> branch1 ,
3148
- conflict_info -> branch2 ))
3167
+ if (handle_rename_via_dir (o ,
3168
+ conflict_info -> pair1 ,
3169
+ conflict_info -> branch1 ,
3170
+ conflict_info -> branch2 ))
3149
3171
clean_merge = -1 ;
3150
3172
break ;
3151
3173
case RENAME_DELETE :
3152
3174
clean_merge = 0 ;
3153
- if (conflict_rename_delete (o ,
3154
- conflict_info -> pair1 ,
3155
- conflict_info -> branch1 ,
3156
- conflict_info -> branch2 ))
3175
+ if (handle_rename_delete (o ,
3176
+ conflict_info -> pair1 ,
3177
+ conflict_info -> branch1 ,
3178
+ conflict_info -> branch2 ))
3157
3179
clean_merge = -1 ;
3158
3180
break ;
3159
3181
case RENAME_ONE_FILE_TO_TWO :
3160
3182
clean_merge = 0 ;
3161
- if (conflict_rename_rename_1to2 (o , conflict_info ))
3183
+ if (handle_rename_rename_1to2 (o , conflict_info ))
3162
3184
clean_merge = -1 ;
3163
3185
break ;
3164
3186
case RENAME_TWO_FILES_TO_ONE :
3165
3187
clean_merge = 0 ;
3166
- if (conflict_rename_rename_2to1 (o , conflict_info ))
3188
+ if (handle_rename_rename_2to1 (o , conflict_info ))
3167
3189
clean_merge = -1 ;
3168
3190
break ;
3169
3191
default :
@@ -3303,8 +3325,8 @@ int merge_trees(struct merge_options *o,
3303
3325
get_files_dirs (o , merge );
3304
3326
3305
3327
entries = get_unmerged ();
3306
- clean = handle_renames (o , common , head , merge , entries ,
3307
- & re_info );
3328
+ clean = detect_and_process_renames (o , common , head , merge ,
3329
+ entries , & re_info );
3308
3330
record_df_conflict_files (o , entries );
3309
3331
if (clean < 0 )
3310
3332
goto cleanup ;
@@ -3328,7 +3350,7 @@ int merge_trees(struct merge_options *o,
3328
3350
entries -> items [i ].string );
3329
3351
}
3330
3352
3331
- cleanup :
3353
+ cleanup :
3332
3354
final_cleanup_renames (& re_info );
3333
3355
3334
3356
string_list_clear (entries , 1 );
@@ -3496,14 +3518,14 @@ int merge_recursive_generic(struct merge_options *o,
3496
3518
struct commit * base ;
3497
3519
if (!(base = get_ref (base_list [i ], oid_to_hex (base_list [i ]))))
3498
3520
return err (o , _ ("Could not parse object '%s'" ),
3499
- oid_to_hex (base_list [i ]));
3521
+ oid_to_hex (base_list [i ]));
3500
3522
commit_list_insert (base , & ca );
3501
3523
}
3502
3524
}
3503
3525
3504
3526
hold_locked_index (& lock , LOCK_DIE_ON_ERROR );
3505
3527
clean = merge_recursive (o , head_commit , next_commit , ca ,
3506
- result );
3528
+ result );
3507
3529
if (clean < 0 ) {
3508
3530
rollback_lock_file (& lock );
3509
3531
return clean ;
0 commit comments