@@ -110,7 +110,7 @@ static int option_parse_type(const struct option *opt, const char *arg,
110
110
* --int' and '--type=bool
111
111
* --type=int'.
112
112
*/
113
- error ("only one type at a time." );
113
+ error (_ ( "only one type at a time" ) );
114
114
usage_builtin_config ();
115
115
}
116
116
* to_type = new_type ;
@@ -164,7 +164,11 @@ static NORETURN void usage_builtin_config(void)
164
164
static void check_argc (int argc , int min , int max ) {
165
165
if (argc >= min && argc <= max )
166
166
return ;
167
- error ("wrong number of arguments" );
167
+ if (min == max )
168
+ error (_ ("wrong number of arguments, should be %d" ), min );
169
+ else
170
+ error (_ ("wrong number of arguments, should be from %d to %d" ),
171
+ min , max );
168
172
usage_builtin_config ();
169
173
}
170
174
@@ -297,7 +301,7 @@ static int get_value(const char *key_, const char *regex_)
297
301
298
302
key_regexp = (regex_t * )xmalloc (sizeof (regex_t ));
299
303
if (regcomp (key_regexp , key , REG_EXTENDED )) {
300
- error ("invalid key pattern: %s" , key_ );
304
+ error (_ ( "invalid key pattern: %s" ) , key_ );
301
305
FREE_AND_NULL (key_regexp );
302
306
ret = CONFIG_INVALID_PATTERN ;
303
307
goto free_strings ;
@@ -317,7 +321,7 @@ static int get_value(const char *key_, const char *regex_)
317
321
318
322
regexp = (regex_t * )xmalloc (sizeof (regex_t ));
319
323
if (regcomp (regexp , regex_ , REG_EXTENDED )) {
320
- error ("invalid pattern: %s" , regex_ );
324
+ error (_ ( "invalid pattern: %s" ) , regex_ );
321
325
FREE_AND_NULL (regexp );
322
326
ret = CONFIG_INVALID_PATTERN ;
323
327
goto free_strings ;
@@ -390,7 +394,7 @@ static char *normalize_value(const char *key, const char *value)
390
394
if (type == TYPE_COLOR ) {
391
395
char v [COLOR_MAXLEN ];
392
396
if (git_config_color (v , key , value ))
393
- die ("cannot parse color '%s'" , value );
397
+ die (_ ( "cannot parse color '%s'" ) , value );
394
398
395
399
/*
396
400
* The contents of `v` now contain an ANSI escape
@@ -485,13 +489,13 @@ static int get_colorbool(const char *var, int print)
485
489
static void check_write (void )
486
490
{
487
491
if (!given_config_source .file && !startup_info -> have_repository )
488
- die ("not in a git directory" );
492
+ die (_ ( "not in a git directory" ) );
489
493
490
494
if (given_config_source .use_stdin )
491
- die ("writing to stdin is not supported" );
495
+ die (_ ( "writing to stdin is not supported" ) );
492
496
493
497
if (given_config_source .blob )
494
- die ("writing config blobs is not supported" );
498
+ die (_ ( "writing config blobs is not supported" ) );
495
499
}
496
500
497
501
struct urlmatch_current_candidate_value {
@@ -599,7 +603,7 @@ int cmd_config(int argc, const char **argv, const char *prefix)
599
603
600
604
if (use_global_config + use_system_config + use_local_config +
601
605
!!given_config_source .file + !!given_config_source .blob > 1 ) {
602
- error ("only one config file at a time." );
606
+ error (_ ( "only one config file at a time" ) );
603
607
usage_builtin_config ();
604
608
}
605
609
@@ -626,7 +630,7 @@ int cmd_config(int argc, const char **argv, const char *prefix)
626
630
* location; error out even if XDG_CONFIG_HOME
627
631
* is set and points at a sane location.
628
632
*/
629
- die ("$HOME not set" );
633
+ die (_ ( "$HOME not set" ) );
630
634
631
635
if (access_or_warn (user_config , R_OK , 0 ) &&
632
636
xdg_config && !access_or_warn (xdg_config , R_OK , 0 )) {
@@ -663,12 +667,12 @@ int cmd_config(int argc, const char **argv, const char *prefix)
663
667
}
664
668
665
669
if ((actions & (ACTION_GET_COLOR |ACTION_GET_COLORBOOL )) && type ) {
666
- error ("--get-color and variable type are incoherent" );
670
+ error (_ ( "--get-color and variable type are incoherent" ) );
667
671
usage_builtin_config ();
668
672
}
669
673
670
674
if (HAS_MULTI_BITS (actions )) {
671
- error ("only one action at a time." );
675
+ error (_ ( "only one action at a time" ) );
672
676
usage_builtin_config ();
673
677
}
674
678
if (actions == 0 )
@@ -681,19 +685,19 @@ int cmd_config(int argc, const char **argv, const char *prefix)
681
685
}
682
686
if (omit_values &&
683
687
!(actions == ACTION_LIST || actions == ACTION_GET_REGEXP )) {
684
- error ("--name-only is only applicable to --list or --get-regexp" );
688
+ error (_ ( "--name-only is only applicable to --list or --get-regexp" ) );
685
689
usage_builtin_config ();
686
690
}
687
691
688
692
if (show_origin && !(actions &
689
693
(ACTION_GET |ACTION_GET_ALL |ACTION_GET_REGEXP |ACTION_LIST ))) {
690
- error ("--show-origin is only applicable to --get, --get-all, "
691
- "--get-regexp, and --list." );
694
+ error (_ ( "--show-origin is only applicable to --get, --get-all, "
695
+ "--get-regexp, and --list" ) );
692
696
usage_builtin_config ();
693
697
}
694
698
695
699
if (default_value && !(actions & ACTION_GET )) {
696
- error ("--default is only applicable to --get" );
700
+ error (_ ( "--default is only applicable to --get" ) );
697
701
usage_builtin_config ();
698
702
}
699
703
@@ -706,22 +710,22 @@ int cmd_config(int argc, const char **argv, const char *prefix)
706
710
& given_config_source ,
707
711
& config_options ) < 0 ) {
708
712
if (given_config_source .file )
709
- die_errno ("unable to read config file '%s'" ,
713
+ die_errno (_ ( "unable to read config file '%s'" ) ,
710
714
given_config_source .file );
711
715
else
712
- die ("error processing config file(s)" );
716
+ die (_ ( "error processing config file(s)" ) );
713
717
}
714
718
}
715
719
else if (actions == ACTION_EDIT ) {
716
720
char * config_file ;
717
721
718
722
check_argc (argc , 0 , 0 );
719
723
if (!given_config_source .file && nongit )
720
- die ("not in a git directory" );
724
+ die (_ ( "not in a git directory" ) );
721
725
if (given_config_source .use_stdin )
722
- die ("editing stdin is not supported" );
726
+ die (_ ( "editing stdin is not supported" ) );
723
727
if (given_config_source .blob )
724
- die ("editing blobs is not supported" );
728
+ die (_ ( "editing blobs is not supported" ) );
725
729
git_config (git_default_config , NULL );
726
730
config_file = given_config_source .file ?
727
731
xstrdup (given_config_source .file ) :
@@ -822,7 +826,7 @@ int cmd_config(int argc, const char **argv, const char *prefix)
822
826
if (ret < 0 )
823
827
return ret ;
824
828
if (ret == 0 )
825
- die ("No such section!" );
829
+ die (_ ( "no such section: %s" ), argv [ 0 ] );
826
830
}
827
831
else if (actions == ACTION_REMOVE_SECTION ) {
828
832
int ret ;
@@ -833,7 +837,7 @@ int cmd_config(int argc, const char **argv, const char *prefix)
833
837
if (ret < 0 )
834
838
return ret ;
835
839
if (ret == 0 )
836
- die ("No such section!" );
840
+ die (_ ( "no such section: %s" ), argv [ 0 ] );
837
841
}
838
842
else if (actions == ACTION_GET_COLOR ) {
839
843
check_argc (argc , 1 , 2 );
0 commit comments