@@ -182,7 +182,7 @@ static int oid_eq(const struct object_id *a, const struct object_id *b)
182182
183183enum rename_type {
184184 RENAME_NORMAL = 0 ,
185- RENAME_DIR ,
185+ RENAME_VIA_DIR ,
186186 RENAME_DELETE ,
187187 RENAME_ONE_FILE_TO_ONE ,
188188 RENAME_ONE_FILE_TO_TWO ,
@@ -312,8 +312,8 @@ static void output_commit_title(struct merge_options *o, struct commit *commit)
312312}
313313
314314static 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 )
317317{
318318 struct cache_entry * ce ;
319319 int ret ;
@@ -420,8 +420,8 @@ struct tree *write_tree_from_memory(struct merge_options *o)
420420}
421421
422422static 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 )
425425{
426426 struct path_hashmap_entry * entry ;
427427 int baselen = base -> len ;
@@ -542,7 +542,7 @@ static void record_df_conflict_files(struct merge_options *o,
542542 struct string_list * entries )
543543{
544544 /* 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
546546 * removed to make room for the corresponding directory if needed.
547547 * The files underneath the directories of such D/F conflicts will
548548 * 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)
916916 */
917917 if (would_lose_untracked (path ))
918918 return err (o , _ ("refusing to lose untracked file at '%s'" ),
919- path );
919+ path );
920920
921921 /* Successful unlink is good.. */
922922 if (!unlink (path ))
@@ -995,16 +995,16 @@ static int update_file_flags(struct merge_options *o,
995995 unlink (path );
996996 if (symlink (lnk , path ))
997997 ret = err (o , _ ("failed to symlink '%s': %s" ),
998- path , strerror (errno ));
998+ path , strerror (errno ));
999999 free (lnk );
10001000 } else
10011001 ret = err (o ,
10021002 _ ("do not know what to do with %06o %s '%s'" ),
10031003 mode , oid_to_hex (oid ), path );
1004- free_buf :
1004+ free_buf :
10051005 free (buf );
10061006 }
1007- update_index :
1007+ update_index :
10081008 if (!ret && update_cache )
10091009 if (add_cacheinfo (o , mode , oid , path , 0 , update_wd ,
10101010 ADD_CACHE_OK_TO_ADD ))
@@ -1093,7 +1093,7 @@ static int merge_3way(struct merge_options *o,
10931093}
10941094
10951095static 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 )
10971097{
10981098 int i , j ;
10991099 struct object_array merges = OBJECT_ARRAY_INIT ;
@@ -1111,7 +1111,7 @@ static int find_first_merges(struct object_array *result, const char *path,
11111111
11121112 /* get all revisions that merge commit a */
11131113 xsnprintf (merged_revision , sizeof (merged_revision ), "^%s" ,
1114- oid_to_hex (& a -> object .oid ));
1114+ oid_to_hex (& a -> object .oid ));
11151115 init_revisions (& revs , NULL );
11161116 rev_opts .submodule = path ;
11171117 /* FIXME: can't handle linked worktrees in submodules yet */
@@ -1253,12 +1253,12 @@ static int merge_submodule(struct merge_options *o,
12531253 output (o , 2 , _ ("Found a possible merge resolution for the submodule:\n" ));
12541254 print_commit ((struct commit * ) merges .objects [0 ].item );
12551255 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 );
12621262 break ;
12631263
12641264 default :
@@ -1335,10 +1335,10 @@ static int merge_file_1(struct merge_options *o,
13351335 result -> clean = (merge_status == 0 );
13361336 } else if (S_ISGITLINK (a -> mode )) {
13371337 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 );
13421342 } else if (S_ISLNK (a -> mode )) {
13431343 switch (o -> recursive_variant ) {
13441344 case MERGE_RECURSIVE_NORMAL :
@@ -1413,11 +1413,17 @@ static int merge_file_one(struct merge_options *o,
14131413 return merge_file_1 (o , & one , & a , & b , path , branch1 , branch2 , mfi );
14141414}
14151415
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 )
14201420{
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+ */
14211427 const struct diff_filespec * dest = pair -> two ;
14221428
14231429 if (!o -> call_depth && would_lose_untracked (dest -> path )) {
@@ -1446,13 +1452,13 @@ static int conflict_rename_dir(struct merge_options *o,
14461452}
14471453
14481454static 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 )
14561462{
14571463 char * alt_path = NULL ;
14581464 const char * update_path = path ;
@@ -1473,6 +1479,21 @@ static int handle_change_delete(struct merge_options *o,
14731479 if (!ret )
14741480 ret = update_file (o , 0 , o_oid , o_mode , update_path );
14751481 } 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+ */
14761497 if (!alt_path ) {
14771498 if (!old_path ) {
14781499 output (o , 1 , _ ("CONFLICT (%s/delete): %s deleted in %s "
@@ -1512,10 +1533,10 @@ static int handle_change_delete(struct merge_options *o,
15121533 return ret ;
15131534}
15141535
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 )
15191540{
15201541 const struct diff_filespec * orig = pair -> one ;
15211542 const struct diff_filespec * dest = pair -> two ;
@@ -1617,8 +1638,8 @@ static int handle_file(struct merge_options *o,
16171638 return ret ;
16181639}
16191640
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 )
16221643{
16231644 /* One file was renamed in both branches, but to different names. */
16241645 struct diff_filespec * one = ci -> pair1 -> one ;
@@ -1679,8 +1700,8 @@ static int conflict_rename_rename_1to2(struct merge_options *o,
16791700 return 0 ;
16801701}
16811702
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 )
16841705{
16851706 /* Two files, a & b, were renamed to the same thing, c. */
16861707 struct diff_filespec * a = ci -> pair1 -> one ;
@@ -2422,7 +2443,7 @@ static void apply_directory_rename_modifications(struct merge_options *o,
24222443 * "NOTE" in update_stages(), doing so will modify the current
24232444 * in-memory index which will break calls to would_lose_untracked()
24242445 * 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
24262447 * explicitly rather than relying on unpack_trees() to have done it.
24272448 */
24282449 get_tree_entry (& tree -> object .oid ,
@@ -2695,7 +2716,7 @@ static int process_renames(struct merge_options *o,
26952716
26962717 if (oid_eq (& src_other .oid , & null_oid ) &&
26972718 ren1 -> add_turned_into_rename ) {
2698- setup_rename_conflict_info (RENAME_DIR ,
2719+ setup_rename_conflict_info (RENAME_VIA_DIR ,
26992720 ren1 -> pair ,
27002721 NULL ,
27012722 branch1 ,
@@ -2826,12 +2847,12 @@ static void initial_cleanup_rename(struct diff_queue_struct *pairs,
28262847 free (pairs );
28272848}
28282849
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 )
28352856{
28362857 struct diff_queue_struct * head_pairs , * merge_pairs ;
28372858 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)
29072928}
29082929
29092930static 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 )
29112933{
29122934 void * buf ;
29132935 enum object_type type ;
@@ -2960,10 +2982,10 @@ static int blob_unchanged(struct merge_options *opt,
29602982}
29612983
29622984static 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 )
29672989{
29682990 const char * modify_branch , * delete_branch ;
29692991 struct object_id * changed_oid ;
@@ -3101,12 +3123,12 @@ static int merge_content(struct merge_options *o,
31013123 return !is_dirty && mfi .clean ;
31023124}
31033125
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 )
31103132{
31113133 /* Merge the content and write it out */
31123134 return merge_content (o , path , was_dirty (o , path ),
@@ -3133,37 +3155,37 @@ static int process_entry(struct merge_options *o,
31333155 switch (conflict_info -> rename_type ) {
31343156 case RENAME_NORMAL :
31353157 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 );
31423164 break ;
3143- case RENAME_DIR :
3165+ case RENAME_VIA_DIR :
31443166 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 ))
31493171 clean_merge = -1 ;
31503172 break ;
31513173 case RENAME_DELETE :
31523174 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 ))
31573179 clean_merge = -1 ;
31583180 break ;
31593181 case RENAME_ONE_FILE_TO_TWO :
31603182 clean_merge = 0 ;
3161- if (conflict_rename_rename_1to2 (o , conflict_info ))
3183+ if (handle_rename_rename_1to2 (o , conflict_info ))
31623184 clean_merge = -1 ;
31633185 break ;
31643186 case RENAME_TWO_FILES_TO_ONE :
31653187 clean_merge = 0 ;
3166- if (conflict_rename_rename_2to1 (o , conflict_info ))
3188+ if (handle_rename_rename_2to1 (o , conflict_info ))
31673189 clean_merge = -1 ;
31683190 break ;
31693191 default :
@@ -3303,8 +3325,8 @@ int merge_trees(struct merge_options *o,
33033325 get_files_dirs (o , merge );
33043326
33053327 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 );
33083330 record_df_conflict_files (o , entries );
33093331 if (clean < 0 )
33103332 goto cleanup ;
@@ -3328,7 +3350,7 @@ int merge_trees(struct merge_options *o,
33283350 entries -> items [i ].string );
33293351 }
33303352
3331- cleanup :
3353+ cleanup :
33323354 final_cleanup_renames (& re_info );
33333355
33343356 string_list_clear (entries , 1 );
@@ -3496,14 +3518,14 @@ int merge_recursive_generic(struct merge_options *o,
34963518 struct commit * base ;
34973519 if (!(base = get_ref (base_list [i ], oid_to_hex (base_list [i ]))))
34983520 return err (o , _ ("Could not parse object '%s'" ),
3499- oid_to_hex (base_list [i ]));
3521+ oid_to_hex (base_list [i ]));
35003522 commit_list_insert (base , & ca );
35013523 }
35023524 }
35033525
35043526 hold_locked_index (& lock , LOCK_DIE_ON_ERROR );
35053527 clean = merge_recursive (o , head_commit , next_commit , ca ,
3506- result );
3528+ result );
35073529 if (clean < 0 ) {
35083530 rollback_lock_file (& lock );
35093531 return clean ;
0 commit comments