@@ -54,7 +54,7 @@ static int show_reference(const char *refname, const struct object_id *oid,
5454 enum object_type obj_type , repl_type ;
5555
5656 if (get_oid (refname , & object ))
57- return error ("failed to resolve '%s' as a valid ref" , refname );
57+ return error (_ ( "failed to resolve '%s' as a valid ref" ) , refname );
5858
5959 obj_type = oid_object_info (the_repository , & object ,
6060 NULL );
@@ -83,8 +83,8 @@ static int list_replace_refs(const char *pattern, const char *format)
8383 else if (!strcmp (format , "long" ))
8484 data .format = REPLACE_FORMAT_LONG ;
8585 else
86- return error ("invalid replace format '%s'\n"
87- "valid formats are 'short', 'medium' and 'long'" ,
86+ return error (_ ( "invalid replace format '%s'\n"
87+ "valid formats are 'short', 'medium' and 'long'" ) ,
8888 format );
8989
9090 for_each_replace_ref (the_repository , show_reference , (void * )& data );
@@ -118,7 +118,7 @@ static int for_each_replace_name(const char **argv, each_replace_name_fn fn)
118118 full_hex = ref .buf + base_len ;
119119
120120 if (read_ref (ref .buf , & oid )) {
121- error ("replace ref '%s' not found" , full_hex );
121+ error (_ ( "replace ref '%s' not found" ) , full_hex );
122122 had_error = 1 ;
123123 continue ;
124124 }
@@ -134,7 +134,7 @@ static int delete_replace_ref(const char *name, const char *ref,
134134{
135135 if (delete_ref (NULL , ref , oid , 0 ))
136136 return 1 ;
137- printf_ln ("Deleted replace ref '%s'" , name );
137+ printf_ln (_ ( "Deleted replace ref '%s'" ) , name );
138138 return 0 ;
139139}
140140
@@ -146,12 +146,12 @@ static int check_ref_valid(struct object_id *object,
146146 strbuf_reset (ref );
147147 strbuf_addf (ref , "%s%s" , git_replace_ref_base , oid_to_hex (object ));
148148 if (check_refname_format (ref -> buf , 0 ))
149- return error ("'%s' is not a valid ref name" , ref -> buf );
149+ return error (_ ( "'%s' is not a valid ref name" ) , ref -> buf );
150150
151151 if (read_ref (ref -> buf , prev ))
152152 oidclr (prev );
153153 else if (!force )
154- return error ("replace ref '%s' already exists" , ref -> buf );
154+ return error (_ ( "replace ref '%s' already exists" ) , ref -> buf );
155155 return 0 ;
156156}
157157
@@ -171,10 +171,10 @@ static int replace_object_oid(const char *object_ref,
171171 obj_type = oid_object_info (the_repository , object , NULL );
172172 repl_type = oid_object_info (the_repository , repl , NULL );
173173 if (!force && obj_type != repl_type )
174- return error ("Objects must be of the same type.\n"
175- "'%s' points to a replaced object of type '%s'\n"
176- "while '%s' points to a replacement object of "
177- "type '%s'." ,
174+ return error (_ ( "Objects must be of the same type.\n"
175+ "'%s' points to a replaced object of type '%s'\n"
176+ "while '%s' points to a replacement object of "
177+ "type '%s'." ) ,
178178 object_ref , type_name (obj_type ),
179179 replace_ref , type_name (repl_type ));
180180
@@ -200,10 +200,10 @@ static int replace_object(const char *object_ref, const char *replace_ref, int f
200200 struct object_id object , repl ;
201201
202202 if (get_oid (object_ref , & object ))
203- return error ("failed to resolve '%s' as a valid ref" ,
203+ return error (_ ( "failed to resolve '%s' as a valid ref" ) ,
204204 object_ref );
205205 if (get_oid (replace_ref , & repl ))
206- return error ("failed to resolve '%s' as a valid ref" ,
206+ return error (_ ( "failed to resolve '%s' as a valid ref" ) ,
207207 replace_ref );
208208
209209 return replace_object_oid (object_ref , & object , replace_ref , & repl , force );
@@ -222,7 +222,7 @@ static int export_object(const struct object_id *oid, enum object_type type,
222222
223223 fd = open (filename , O_WRONLY | O_CREAT | O_TRUNC , 0666 );
224224 if (fd < 0 )
225- return error_errno ("unable to open %s for writing" , filename );
225+ return error_errno (_ ( "unable to open %s for writing" ) , filename );
226226
227227 argv_array_push (& cmd .args , "--no-replace-objects" );
228228 argv_array_push (& cmd .args , "cat-file" );
@@ -235,7 +235,7 @@ static int export_object(const struct object_id *oid, enum object_type type,
235235 cmd .out = fd ;
236236
237237 if (run_command (& cmd ))
238- return error ("cat-file reported failure" );
238+ return error (_ ( "cat-file reported failure" ) );
239239 return 0 ;
240240}
241241
@@ -251,7 +251,7 @@ static int import_object(struct object_id *oid, enum object_type type,
251251
252252 fd = open (filename , O_RDONLY );
253253 if (fd < 0 )
254- return error_errno ("unable to open %s for reading" , filename );
254+ return error_errno (_ ( "unable to open %s for reading" ) , filename );
255255
256256 if (!raw && type == OBJ_TREE ) {
257257 const char * argv [] = { "mktree" , NULL };
@@ -265,11 +265,11 @@ static int import_object(struct object_id *oid, enum object_type type,
265265
266266 if (start_command (& cmd )) {
267267 close (fd );
268- return error ("unable to spawn mktree" );
268+ return error (_ ( "unable to spawn mktree" ) );
269269 }
270270
271271 if (strbuf_read (& result , cmd .out , 41 ) < 0 ) {
272- error_errno ("unable to read from mktree" );
272+ error_errno (_ ( "unable to read from mktree" ) );
273273 close (fd );
274274 close (cmd .out );
275275 return -1 ;
@@ -278,11 +278,11 @@ static int import_object(struct object_id *oid, enum object_type type,
278278
279279 if (finish_command (& cmd )) {
280280 strbuf_release (& result );
281- return error ("mktree reported failure" );
281+ return error (_ ( "mktree reported failure" ) );
282282 }
283283 if (get_oid_hex (result .buf , oid ) < 0 ) {
284284 strbuf_release (& result );
285- return error ("mktree did not return an object name" );
285+ return error (_ ( "mktree did not return an object name" ) );
286286 }
287287
288288 strbuf_release (& result );
@@ -291,12 +291,12 @@ static int import_object(struct object_id *oid, enum object_type type,
291291 int flags = HASH_FORMAT_CHECK | HASH_WRITE_OBJECT ;
292292
293293 if (fstat (fd , & st ) < 0 ) {
294- error_errno ("unable to fstat %s" , filename );
294+ error_errno (_ ( "unable to fstat %s" ) , filename );
295295 close (fd );
296296 return -1 ;
297297 }
298298 if (index_fd (oid , fd , & st , type , NULL , flags ) < 0 )
299- return error ("unable to write object to database" );
299+ return error (_ ( "unable to write object to database" ) );
300300 /* index_fd close()s fd for us */
301301 }
302302
@@ -315,11 +315,11 @@ static int edit_and_replace(const char *object_ref, int force, int raw)
315315 struct strbuf ref = STRBUF_INIT ;
316316
317317 if (get_oid (object_ref , & old_oid ) < 0 )
318- return error ("not a valid object name: '%s'" , object_ref );
318+ return error (_ ( "not a valid object name: '%s'" ) , object_ref );
319319
320320 type = oid_object_info (the_repository , & old_oid , NULL );
321321 if (type < 0 )
322- return error ("unable to get object type for %s" ,
322+ return error (_ ( "unable to get object type for %s" ) ,
323323 oid_to_hex (& old_oid ));
324324
325325 if (check_ref_valid (& old_oid , & prev , & ref , force )) {
@@ -335,7 +335,7 @@ static int edit_and_replace(const char *object_ref, int force, int raw)
335335 }
336336 if (launch_editor (tmpfile , NULL , NULL ) < 0 ) {
337337 free (tmpfile );
338- return error ("editing object file failed" );
338+ return error (_ ( "editing object file failed" ) );
339339 }
340340 if (import_object (& new_oid , type , raw , tmpfile )) {
341341 free (tmpfile );
@@ -344,7 +344,7 @@ static int edit_and_replace(const char *object_ref, int force, int raw)
344344 free (tmpfile );
345345
346346 if (!oidcmp (& old_oid , & new_oid ))
347- return error ("new object is the same as the old one: '%s'" , oid_to_hex (& old_oid ));
347+ return error (_ ( "new object is the same as the old one: '%s'" ) , oid_to_hex (& old_oid ));
348348
349349 return replace_object_oid (object_ref , & old_oid , "replacement" , & new_oid , force );
350350}
@@ -476,10 +476,10 @@ static int create_graft(int argc, const char **argv, int force, int gentle)
476476
477477 if (!oidcmp (& old_oid , & new_oid )) {
478478 if (gentle ) {
479- warning ("graft for '%s' unnecessary" , oid_to_hex (& old_oid ));
479+ warning (_ ( "graft for '%s' unnecessary" ) , oid_to_hex (& old_oid ));
480480 return 0 ;
481481 }
482- return error ("new commit is the same as the old one: '%s'" , oid_to_hex (& old_oid ));
482+ return error (_ ( "new commit is the same as the old one: '%s'" ) , oid_to_hex (& old_oid ));
483483 }
484484
485485 return replace_object_oid (old_ref , & old_oid , "replacement" , & new_oid , force );
@@ -553,55 +553,55 @@ int cmd_replace(int argc, const char **argv, const char *prefix)
553553 cmdmode = argc ? MODE_REPLACE : MODE_LIST ;
554554
555555 if (format && cmdmode != MODE_LIST )
556- usage_msg_opt ("--format cannot be used when not listing" ,
556+ usage_msg_opt (_ ( "--format cannot be used when not listing" ) ,
557557 git_replace_usage , options );
558558
559559 if (force &&
560560 cmdmode != MODE_REPLACE &&
561561 cmdmode != MODE_EDIT &&
562562 cmdmode != MODE_GRAFT &&
563563 cmdmode != MODE_CONVERT_GRAFT_FILE )
564- usage_msg_opt ("-f only makes sense when writing a replacement" ,
564+ usage_msg_opt (_ ( "-f only makes sense when writing a replacement" ) ,
565565 git_replace_usage , options );
566566
567567 if (raw && cmdmode != MODE_EDIT )
568- usage_msg_opt ("--raw only makes sense with --edit" ,
568+ usage_msg_opt (_ ( "--raw only makes sense with --edit" ) ,
569569 git_replace_usage , options );
570570
571571 switch (cmdmode ) {
572572 case MODE_DELETE :
573573 if (argc < 1 )
574- usage_msg_opt ("-d needs at least one argument" ,
574+ usage_msg_opt (_ ( "-d needs at least one argument" ) ,
575575 git_replace_usage , options );
576576 return for_each_replace_name (argv , delete_replace_ref );
577577
578578 case MODE_REPLACE :
579579 if (argc != 2 )
580- usage_msg_opt ("bad number of arguments" ,
580+ usage_msg_opt (_ ( "bad number of arguments" ) ,
581581 git_replace_usage , options );
582582 return replace_object (argv [0 ], argv [1 ], force );
583583
584584 case MODE_EDIT :
585585 if (argc != 1 )
586- usage_msg_opt ("-e needs exactly one argument" ,
586+ usage_msg_opt (_ ( "-e needs exactly one argument" ) ,
587587 git_replace_usage , options );
588588 return edit_and_replace (argv [0 ], force , raw );
589589
590590 case MODE_GRAFT :
591591 if (argc < 1 )
592- usage_msg_opt ("-g needs at least one argument" ,
592+ usage_msg_opt (_ ( "-g needs at least one argument" ) ,
593593 git_replace_usage , options );
594594 return create_graft (argc , argv , force , 0 );
595595
596596 case MODE_CONVERT_GRAFT_FILE :
597597 if (argc != 0 )
598- usage_msg_opt ("--convert-graft-file takes no argument" ,
598+ usage_msg_opt (_ ( "--convert-graft-file takes no argument" ) ,
599599 git_replace_usage , options );
600600 return !!convert_graft_file (force );
601601
602602 case MODE_LIST :
603603 if (argc > 1 )
604- usage_msg_opt ("only one pattern can be given with -l" ,
604+ usage_msg_opt (_ ( "only one pattern can be given with -l" ) ,
605605 git_replace_usage , options );
606606 return list_replace_refs (argv [0 ], format );
607607
0 commit comments