@@ -1048,18 +1048,17 @@ static void print_commit(struct commit *commit)
1048
1048
strbuf_release (& sb );
1049
1049
}
1050
1050
1051
- #define MERGE_WARNING (path , msg ) \
1052
- warning("Failed to merge submodule %s (%s)", path, msg);
1053
-
1054
- static int merge_submodule (struct object_id * result , const char * path ,
1051
+ static int merge_submodule (struct merge_options * o ,
1052
+ struct object_id * result , const char * path ,
1055
1053
const struct object_id * base , const struct object_id * a ,
1056
- const struct object_id * b , int search )
1054
+ const struct object_id * b )
1057
1055
{
1058
1056
struct commit * commit_base , * commit_a , * commit_b ;
1059
1057
int parent_count ;
1060
1058
struct object_array merges ;
1061
1059
1062
1060
int i ;
1061
+ int search = !o -> call_depth ;
1063
1062
1064
1063
/* store a in result in case we fail */
1065
1064
oidcpy (result , a );
@@ -1073,21 +1072,21 @@ static int merge_submodule(struct object_id *result, const char *path,
1073
1072
return 0 ;
1074
1073
1075
1074
if (add_submodule_odb (path )) {
1076
- MERGE_WARNING ( path , " not checked out" );
1075
+ output ( o , 1 , _ ( "Failed to merge submodule %s ( not checked out)" ), path );
1077
1076
return 0 ;
1078
1077
}
1079
1078
1080
1079
if (!(commit_base = lookup_commit_reference (base )) ||
1081
1080
!(commit_a = lookup_commit_reference (a )) ||
1082
1081
!(commit_b = lookup_commit_reference (b ))) {
1083
- MERGE_WARNING ( path , " commits not present" );
1082
+ output ( o , 1 , _ ( "Failed to merge submodule %s ( commits not present)" ), path );
1084
1083
return 0 ;
1085
1084
}
1086
1085
1087
1086
/* check whether both changes are forward */
1088
1087
if (!in_merge_bases (commit_base , commit_a ) ||
1089
1088
!in_merge_bases (commit_base , commit_b )) {
1090
- MERGE_WARNING ( path , " commits don't follow merge-base" );
1089
+ output ( o , 1 , _ ( "Failed to merge submodule %s ( commits don't follow merge-base)" ), path );
1091
1090
return 0 ;
1092
1091
}
1093
1092
@@ -1116,25 +1115,24 @@ static int merge_submodule(struct object_id *result, const char *path,
1116
1115
parent_count = find_first_merges (& merges , path , commit_a , commit_b );
1117
1116
switch (parent_count ) {
1118
1117
case 0 :
1119
- MERGE_WARNING ( path , " merge following commits not found" );
1118
+ output ( o , 1 , _ ( "Failed to merge submodule %s (merge following commits not found)" ), path );
1120
1119
break ;
1121
1120
1122
1121
case 1 :
1123
- MERGE_WARNING (path , "not fast-forward" );
1124
- fprintf (stderr , "Found a possible merge resolution "
1125
- "for the submodule:\n" );
1122
+ output (o , 1 , _ ("Failed to merge submodule %s (not fast-forward)" ), path );
1123
+ output (o , 2 , _ ("Found a possible merge resolution for the submodule:\n" ));
1126
1124
print_commit ((struct commit * ) merges .objects [0 ].item );
1127
- fprintf ( stderr ,
1125
+ output ( o , 2 , _ (
1128
1126
"If this is correct simply add it to the index "
1129
1127
"for example\n"
1130
1128
"by using:\n\n"
1131
1129
" git update-index --cacheinfo 160000 %s \"%s\"\n\n"
1132
- "which will accept this suggestion.\n" ,
1130
+ "which will accept this suggestion.\n" ) ,
1133
1131
oid_to_hex (& merges .objects [0 ].item -> oid ), path );
1134
1132
break ;
1135
1133
1136
1134
default :
1137
- MERGE_WARNING ( path , " multiple merges found" );
1135
+ output ( o , 1 , _ ( "Failed to merge submodule %s ( multiple merges found)" ), path );
1138
1136
for (i = 0 ; i < merges .nr ; i ++ )
1139
1137
print_commit ((struct commit * ) merges .objects [i ].item );
1140
1138
}
@@ -1205,12 +1203,11 @@ static int merge_file_1(struct merge_options *o,
1205
1203
return ret ;
1206
1204
result -> clean = (merge_status == 0 );
1207
1205
} else if (S_ISGITLINK (a -> mode )) {
1208
- result -> clean = merge_submodule (& result -> oid ,
1206
+ result -> clean = merge_submodule (o , & result -> oid ,
1209
1207
one -> path ,
1210
1208
& one -> oid ,
1211
1209
& a -> oid ,
1212
- & b -> oid ,
1213
- !o -> call_depth );
1210
+ & b -> oid );
1214
1211
} else if (S_ISLNK (a -> mode )) {
1215
1212
switch (o -> recursive_variant ) {
1216
1213
case MERGE_RECURSIVE_NORMAL :
0 commit comments