@@ -54,7 +54,7 @@ static int show_reference(const char *refname, const struct object_id *oid,
54
54
enum object_type obj_type , repl_type ;
55
55
56
56
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 );
58
58
59
59
obj_type = oid_object_info (the_repository , & object ,
60
60
NULL );
@@ -83,8 +83,8 @@ static int list_replace_refs(const char *pattern, const char *format)
83
83
else if (!strcmp (format , "long" ))
84
84
data .format = REPLACE_FORMAT_LONG ;
85
85
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'" ) ,
88
88
format );
89
89
90
90
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)
118
118
full_hex = ref .buf + base_len ;
119
119
120
120
if (read_ref (ref .buf , & oid )) {
121
- error ("replace ref '%s' not found" , full_hex );
121
+ error (_ ( "replace ref '%s' not found" ) , full_hex );
122
122
had_error = 1 ;
123
123
continue ;
124
124
}
@@ -134,7 +134,7 @@ static int delete_replace_ref(const char *name, const char *ref,
134
134
{
135
135
if (delete_ref (NULL , ref , oid , 0 ))
136
136
return 1 ;
137
- printf_ln ("Deleted replace ref '%s'" , name );
137
+ printf_ln (_ ( "Deleted replace ref '%s'" ) , name );
138
138
return 0 ;
139
139
}
140
140
@@ -146,12 +146,12 @@ static int check_ref_valid(struct object_id *object,
146
146
strbuf_reset (ref );
147
147
strbuf_addf (ref , "%s%s" , git_replace_ref_base , oid_to_hex (object ));
148
148
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 );
150
150
151
151
if (read_ref (ref -> buf , prev ))
152
152
oidclr (prev );
153
153
else if (!force )
154
- return error ("replace ref '%s' already exists" , ref -> buf );
154
+ return error (_ ( "replace ref '%s' already exists" ) , ref -> buf );
155
155
return 0 ;
156
156
}
157
157
@@ -171,10 +171,10 @@ static int replace_object_oid(const char *object_ref,
171
171
obj_type = oid_object_info (the_repository , object , NULL );
172
172
repl_type = oid_object_info (the_repository , repl , NULL );
173
173
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'." ) ,
178
178
object_ref , type_name (obj_type ),
179
179
replace_ref , type_name (repl_type ));
180
180
@@ -200,10 +200,10 @@ static int replace_object(const char *object_ref, const char *replace_ref, int f
200
200
struct object_id object , repl ;
201
201
202
202
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" ) ,
204
204
object_ref );
205
205
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" ) ,
207
207
replace_ref );
208
208
209
209
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,
222
222
223
223
fd = open (filename , O_WRONLY | O_CREAT | O_TRUNC , 0666 );
224
224
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 );
226
226
227
227
argv_array_push (& cmd .args , "--no-replace-objects" );
228
228
argv_array_push (& cmd .args , "cat-file" );
@@ -235,7 +235,7 @@ static int export_object(const struct object_id *oid, enum object_type type,
235
235
cmd .out = fd ;
236
236
237
237
if (run_command (& cmd ))
238
- return error ("cat-file reported failure" );
238
+ return error (_ ( "cat-file reported failure" ) );
239
239
return 0 ;
240
240
}
241
241
@@ -251,7 +251,7 @@ static int import_object(struct object_id *oid, enum object_type type,
251
251
252
252
fd = open (filename , O_RDONLY );
253
253
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 );
255
255
256
256
if (!raw && type == OBJ_TREE ) {
257
257
const char * argv [] = { "mktree" , NULL };
@@ -265,11 +265,11 @@ static int import_object(struct object_id *oid, enum object_type type,
265
265
266
266
if (start_command (& cmd )) {
267
267
close (fd );
268
- return error ("unable to spawn mktree" );
268
+ return error (_ ( "unable to spawn mktree" ) );
269
269
}
270
270
271
271
if (strbuf_read (& result , cmd .out , 41 ) < 0 ) {
272
- error_errno ("unable to read from mktree" );
272
+ error_errno (_ ( "unable to read from mktree" ) );
273
273
close (fd );
274
274
close (cmd .out );
275
275
return -1 ;
@@ -278,11 +278,11 @@ static int import_object(struct object_id *oid, enum object_type type,
278
278
279
279
if (finish_command (& cmd )) {
280
280
strbuf_release (& result );
281
- return error ("mktree reported failure" );
281
+ return error (_ ( "mktree reported failure" ) );
282
282
}
283
283
if (get_oid_hex (result .buf , oid ) < 0 ) {
284
284
strbuf_release (& result );
285
- return error ("mktree did not return an object name" );
285
+ return error (_ ( "mktree did not return an object name" ) );
286
286
}
287
287
288
288
strbuf_release (& result );
@@ -291,12 +291,12 @@ static int import_object(struct object_id *oid, enum object_type type,
291
291
int flags = HASH_FORMAT_CHECK | HASH_WRITE_OBJECT ;
292
292
293
293
if (fstat (fd , & st ) < 0 ) {
294
- error_errno ("unable to fstat %s" , filename );
294
+ error_errno (_ ( "unable to fstat %s" ) , filename );
295
295
close (fd );
296
296
return -1 ;
297
297
}
298
298
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" ) );
300
300
/* index_fd close()s fd for us */
301
301
}
302
302
@@ -315,11 +315,11 @@ static int edit_and_replace(const char *object_ref, int force, int raw)
315
315
struct strbuf ref = STRBUF_INIT ;
316
316
317
317
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 );
319
319
320
320
type = oid_object_info (the_repository , & old_oid , NULL );
321
321
if (type < 0 )
322
- return error ("unable to get object type for %s" ,
322
+ return error (_ ( "unable to get object type for %s" ) ,
323
323
oid_to_hex (& old_oid ));
324
324
325
325
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)
335
335
}
336
336
if (launch_editor (tmpfile , NULL , NULL ) < 0 ) {
337
337
free (tmpfile );
338
- return error ("editing object file failed" );
338
+ return error (_ ( "editing object file failed" ) );
339
339
}
340
340
if (import_object (& new_oid , type , raw , tmpfile )) {
341
341
free (tmpfile );
@@ -344,7 +344,7 @@ static int edit_and_replace(const char *object_ref, int force, int raw)
344
344
free (tmpfile );
345
345
346
346
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 ));
348
348
349
349
return replace_object_oid (object_ref , & old_oid , "replacement" , & new_oid , force );
350
350
}
@@ -476,10 +476,10 @@ static int create_graft(int argc, const char **argv, int force, int gentle)
476
476
477
477
if (!oidcmp (& old_oid , & new_oid )) {
478
478
if (gentle ) {
479
- warning ("graft for '%s' unnecessary" , oid_to_hex (& old_oid ));
479
+ warning (_ ( "graft for '%s' unnecessary" ) , oid_to_hex (& old_oid ));
480
480
return 0 ;
481
481
}
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 ));
483
483
}
484
484
485
485
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)
553
553
cmdmode = argc ? MODE_REPLACE : MODE_LIST ;
554
554
555
555
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" ) ,
557
557
git_replace_usage , options );
558
558
559
559
if (force &&
560
560
cmdmode != MODE_REPLACE &&
561
561
cmdmode != MODE_EDIT &&
562
562
cmdmode != MODE_GRAFT &&
563
563
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" ) ,
565
565
git_replace_usage , options );
566
566
567
567
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" ) ,
569
569
git_replace_usage , options );
570
570
571
571
switch (cmdmode ) {
572
572
case MODE_DELETE :
573
573
if (argc < 1 )
574
- usage_msg_opt ("-d needs at least one argument" ,
574
+ usage_msg_opt (_ ( "-d needs at least one argument" ) ,
575
575
git_replace_usage , options );
576
576
return for_each_replace_name (argv , delete_replace_ref );
577
577
578
578
case MODE_REPLACE :
579
579
if (argc != 2 )
580
- usage_msg_opt ("bad number of arguments" ,
580
+ usage_msg_opt (_ ( "bad number of arguments" ) ,
581
581
git_replace_usage , options );
582
582
return replace_object (argv [0 ], argv [1 ], force );
583
583
584
584
case MODE_EDIT :
585
585
if (argc != 1 )
586
- usage_msg_opt ("-e needs exactly one argument" ,
586
+ usage_msg_opt (_ ( "-e needs exactly one argument" ) ,
587
587
git_replace_usage , options );
588
588
return edit_and_replace (argv [0 ], force , raw );
589
589
590
590
case MODE_GRAFT :
591
591
if (argc < 1 )
592
- usage_msg_opt ("-g needs at least one argument" ,
592
+ usage_msg_opt (_ ( "-g needs at least one argument" ) ,
593
593
git_replace_usage , options );
594
594
return create_graft (argc , argv , force , 0 );
595
595
596
596
case MODE_CONVERT_GRAFT_FILE :
597
597
if (argc != 0 )
598
- usage_msg_opt ("--convert-graft-file takes no argument" ,
598
+ usage_msg_opt (_ ( "--convert-graft-file takes no argument" ) ,
599
599
git_replace_usage , options );
600
600
return !!convert_graft_file (force );
601
601
602
602
case MODE_LIST :
603
603
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" ) ,
605
605
git_replace_usage , options );
606
606
return list_replace_refs (argv [0 ], format );
607
607
0 commit comments