@@ -171,23 +171,6 @@ static int git_merge_trees(int index_only,
171171 int rc ;
172172 struct tree_desc t [3 ];
173173 struct unpack_trees_options opts ;
174- struct unpack_trees_error_msgs msgs = {
175- /* would_overwrite */
176- "Your local changes to '%s' would be overwritten by merge. Aborting." ,
177- /* not_uptodate_file */
178- "Your local changes to '%s' would be overwritten by merge. Aborting." ,
179- /* not_uptodate_dir */
180- "Updating '%s' would lose untracked files in it. Aborting." ,
181- /* would_lose_untracked */
182- "Untracked working tree file '%s' would be %s by merge. Aborting" ,
183- /* bind_overlap -- will not happen here */
184- NULL ,
185- };
186- if (advice_commit_before_merge ) {
187- msgs .would_overwrite = msgs .not_uptodate_file =
188- "Your local changes to '%s' would be overwritten by merge. Aborting.\n"
189- "Please, commit your changes or stash them before you can merge." ;
190- }
191174
192175 memset (& opts , 0 , sizeof (opts ));
193176 if (index_only )
@@ -199,7 +182,7 @@ static int git_merge_trees(int index_only,
199182 opts .fn = threeway_merge ;
200183 opts .src_index = & the_index ;
201184 opts .dst_index = & the_index ;
202- opts .msgs = msgs ;
185+ opts .msgs = get_porcelain_error_msgs () ;
203186
204187 init_tree_desc_from_tree (t + 0 , common );
205188 init_tree_desc_from_tree (t + 1 , head );
@@ -1186,6 +1169,28 @@ static int process_entry(struct merge_options *o,
11861169 return clean_merge ;
11871170}
11881171
1172+ struct unpack_trees_error_msgs get_porcelain_error_msgs (void )
1173+ {
1174+ struct unpack_trees_error_msgs msgs = {
1175+ /* would_overwrite */
1176+ "Your local changes to '%s' would be overwritten by merge. Aborting." ,
1177+ /* not_uptodate_file */
1178+ "Your local changes to '%s' would be overwritten by merge. Aborting." ,
1179+ /* not_uptodate_dir */
1180+ "Updating '%s' would lose untracked files in it. Aborting." ,
1181+ /* would_lose_untracked */
1182+ "Untracked working tree file '%s' would be %s by merge. Aborting" ,
1183+ /* bind_overlap -- will not happen here */
1184+ NULL ,
1185+ };
1186+ if (advice_commit_before_merge ) {
1187+ msgs .would_overwrite = msgs .not_uptodate_file =
1188+ "Your local changes to '%s' would be overwritten by merge. Aborting.\n"
1189+ "Please, commit your changes or stash them before you can merge." ;
1190+ }
1191+ return msgs ;
1192+ }
1193+
11891194int merge_trees (struct merge_options * o ,
11901195 struct tree * head ,
11911196 struct tree * merge ,
0 commit comments