Skip to content

Commit a769bfc

Browse files
pcloudsgitster
authored andcommitted
config.c: mark more strings for translation
Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4f5b532 commit a769bfc

File tree

2 files changed

+37
-37
lines changed

2 files changed

+37
-37
lines changed

config.c

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,12 @@ static long config_buf_ftell(struct config_source *conf)
116116
}
117117

118118
#define MAX_INCLUDE_DEPTH 10
119-
static const char include_depth_advice[] =
119+
static const char include_depth_advice[] = N_(
120120
"exceeded maximum include depth (%d) while including\n"
121121
" %s\n"
122122
"from\n"
123123
" %s\n"
124-
"Do you have circular includes?";
124+
"Do you have circular includes?");
125125
static int handle_path_include(const char *path, struct config_include_data *inc)
126126
{
127127
int ret = 0;
@@ -133,7 +133,7 @@ static int handle_path_include(const char *path, struct config_include_data *inc
133133

134134
expanded = expand_user_path(path, 0);
135135
if (!expanded)
136-
return error("could not expand include path '%s'", path);
136+
return error(_("could not expand include path '%s'"), path);
137137
path = expanded;
138138

139139
/*
@@ -144,7 +144,7 @@ static int handle_path_include(const char *path, struct config_include_data *inc
144144
char *slash;
145145

146146
if (!cf || !cf->path)
147-
return error("relative config includes must come from files");
147+
return error(_("relative config includes must come from files"));
148148

149149
slash = find_last_dir_sep(cf->path);
150150
if (slash)
@@ -155,7 +155,7 @@ static int handle_path_include(const char *path, struct config_include_data *inc
155155

156156
if (!access_or_die(path, R_OK, 0)) {
157157
if (++inc->depth > MAX_INCLUDE_DEPTH)
158-
die(include_depth_advice, MAX_INCLUDE_DEPTH, path,
158+
die(_(include_depth_advice), MAX_INCLUDE_DEPTH, path,
159159
!cf ? "<unknown>" :
160160
cf->name ? cf->name :
161161
"the command line");
@@ -342,13 +342,13 @@ static int git_config_parse_key_1(const char *key, char **store_key, int *basele
342342

343343
if (last_dot == NULL || last_dot == key) {
344344
if (!quiet)
345-
error("key does not contain a section: %s", key);
345+
error(_("key does not contain a section: %s"), key);
346346
return -CONFIG_NO_SECTION_OR_NAME;
347347
}
348348

349349
if (!last_dot[1]) {
350350
if (!quiet)
351-
error("key does not contain variable name: %s", key);
351+
error(_("key does not contain variable name: %s"), key);
352352
return -CONFIG_NO_SECTION_OR_NAME;
353353
}
354354

@@ -372,13 +372,13 @@ static int git_config_parse_key_1(const char *key, char **store_key, int *basele
372372
if (!iskeychar(c) ||
373373
(i == baselen + 1 && !isalpha(c))) {
374374
if (!quiet)
375-
error("invalid key: %s", key);
375+
error(_("invalid key: %s"), key);
376376
goto out_free_ret_1;
377377
}
378378
c = tolower(c);
379379
} else if (c == '\n') {
380380
if (!quiet)
381-
error("invalid key (newline): %s", key);
381+
error(_("invalid key (newline): %s"), key);
382382
goto out_free_ret_1;
383383
}
384384
if (store_key)
@@ -414,7 +414,7 @@ int git_config_parse_parameter(const char *text,
414414

415415
pair = strbuf_split_str(text, '=', 2);
416416
if (!pair[0])
417-
return error("bogus config parameter: %s", text);
417+
return error(_("bogus config parameter: %s"), text);
418418

419419
if (pair[0]->len && pair[0]->buf[pair[0]->len - 1] == '=') {
420420
strbuf_setlen(pair[0], pair[0]->len - 1);
@@ -426,7 +426,7 @@ int git_config_parse_parameter(const char *text,
426426
strbuf_trim(pair[0]);
427427
if (!pair[0]->len) {
428428
strbuf_list_free(pair);
429-
return error("bogus config parameter: %s", text);
429+
return error(_("bogus config parameter: %s"), text);
430430
}
431431

432432
if (git_config_parse_key(pair[0]->buf, &canonical_name, NULL)) {
@@ -461,7 +461,7 @@ int git_config_from_parameters(config_fn_t fn, void *data)
461461
envw = xstrdup(env);
462462

463463
if (sq_dequote_to_argv(envw, &argv, &nr, &alloc) < 0) {
464-
ret = error("bogus format in %s", CONFIG_DATA_ENVIRONMENT);
464+
ret = error(_("bogus format in %s"), CONFIG_DATA_ENVIRONMENT);
465465
goto out;
466466
}
467467

@@ -1154,7 +1154,7 @@ static int git_default_core_config(const char *var, const char *value)
11541154
else {
11551155
int abbrev = git_config_int(var, value);
11561156
if (abbrev < minimum_abbrev || abbrev > 40)
1157-
return error("abbrev length out of range: %d", abbrev);
1157+
return error(_("abbrev length out of range: %d"), abbrev);
11581158
default_abbrev = abbrev;
11591159
}
11601160
return 0;
@@ -1271,7 +1271,7 @@ static int git_default_core_config(const char *var, const char *value)
12711271
comment_line_char = value[0];
12721272
auto_comment_line_char = 0;
12731273
} else
1274-
return error("core.commentChar should only be one character");
1274+
return error(_("core.commentChar should only be one character"));
12751275
return 0;
12761276
}
12771277

@@ -1384,7 +1384,7 @@ static int git_default_branch_config(const char *var, const char *value)
13841384
else if (!strcmp(value, "always"))
13851385
autorebase = AUTOREBASE_ALWAYS;
13861386
else
1387-
return error("malformed value for %s", var);
1387+
return error(_("malformed value for %s"), var);
13881388
return 0;
13891389
}
13901390

@@ -1410,9 +1410,9 @@ static int git_default_push_config(const char *var, const char *value)
14101410
else if (!strcmp(value, "current"))
14111411
push_default = PUSH_DEFAULT_CURRENT;
14121412
else {
1413-
error("malformed value for %s: %s", var, value);
1414-
return error("must be one of nothing, matching, simple, "
1415-
"upstream or current");
1413+
error(_("malformed value for %s: %s"), var, value);
1414+
return error(_("must be one of nothing, matching, simple, "
1415+
"upstream or current"));
14161416
}
14171417
return 0;
14181418
}
@@ -1589,10 +1589,10 @@ int git_config_from_blob_oid(config_fn_t fn,
15891589

15901590
buf = read_object_file(oid, &type, &size);
15911591
if (!buf)
1592-
return error("unable to load config blob object '%s'", name);
1592+
return error(_("unable to load config blob object '%s'"), name);
15931593
if (type != OBJ_BLOB) {
15941594
free(buf);
1595-
return error("reference '%s' does not point to a blob", name);
1595+
return error(_("reference '%s' does not point to a blob"), name);
15961596
}
15971597

15981598
ret = git_config_from_mem(fn, CONFIG_ORIGIN_BLOB, name, buf, size, data);
@@ -1608,7 +1608,7 @@ static int git_config_from_blob_ref(config_fn_t fn,
16081608
struct object_id oid;
16091609

16101610
if (get_oid(name, &oid) < 0)
1611-
return error("unable to resolve config blob '%s'", name);
1611+
return error(_("unable to resolve config blob '%s'"), name);
16121612
return git_config_from_blob_oid(fn, name, &oid, data);
16131613
}
16141614

@@ -1638,7 +1638,7 @@ unsigned long git_env_ulong(const char *k, unsigned long val)
16381638
{
16391639
const char *v = getenv(k);
16401640
if (v && !git_parse_ulong(v, &val))
1641-
die("failed to parse %s", k);
1641+
die(_("failed to parse %s"), k);
16421642
return val;
16431643
}
16441644

@@ -2372,7 +2372,7 @@ static int store_aux_event(enum config_event_t type,
23722372

23732373
if (type == CONFIG_EVENT_SECTION) {
23742374
if (cf->var.len < 2 || cf->var.buf[cf->var.len - 1] != '.')
2375-
return error("invalid section name '%s'", cf->var.buf);
2375+
return error(_("invalid section name '%s'"), cf->var.buf);
23762376

23772377
/* Is this the section we were looking for? */
23782378
store->is_keys_section =
@@ -2428,7 +2428,7 @@ static int store_aux(const char *key, const char *value, void *cb)
24282428

24292429
static int write_error(const char *filename)
24302430
{
2431-
error("failed to write new configuration file %s", filename);
2431+
error(_("failed to write new configuration file %s"), filename);
24322432

24332433
/* Same error code as "failed to rename". */
24342434
return 4;
@@ -2679,7 +2679,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
26792679
*/
26802680
fd = hold_lock_file_for_update(&lock, config_filename, 0);
26812681
if (fd < 0) {
2682-
error_errno("could not lock config file %s", config_filename);
2682+
error_errno(_("could not lock config file %s"), config_filename);
26832683
ret = CONFIG_NO_LOCK;
26842684
goto out_free;
26852685
}
@@ -2690,7 +2690,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
26902690
in_fd = open(config_filename, O_RDONLY);
26912691
if ( in_fd < 0 ) {
26922692
if ( ENOENT != errno ) {
2693-
error_errno("opening %s", config_filename);
2693+
error_errno(_("opening %s"), config_filename);
26942694
ret = CONFIG_INVALID_FILE; /* same as "invalid config file" */
26952695
goto out_free;
26962696
}
@@ -2725,7 +2725,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
27252725
store.value_regex = (regex_t*)xmalloc(sizeof(regex_t));
27262726
if (regcomp(store.value_regex, value_regex,
27272727
REG_EXTENDED)) {
2728-
error("invalid pattern: %s", value_regex);
2728+
error(_("invalid pattern: %s"), value_regex);
27292729
FREE_AND_NULL(store.value_regex);
27302730
ret = CONFIG_INVALID_PATTERN;
27312731
goto out_free;
@@ -2750,7 +2750,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
27502750
if (git_config_from_file_with_options(store_aux,
27512751
config_filename,
27522752
&store, &opts)) {
2753-
error("invalid config file %s", config_filename);
2753+
error(_("invalid config file %s"), config_filename);
27542754
ret = CONFIG_INVALID_FILE;
27552755
goto out_free;
27562756
}
@@ -2774,7 +2774,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
27742774
if (contents == MAP_FAILED) {
27752775
if (errno == ENODEV && S_ISDIR(st.st_mode))
27762776
errno = EISDIR;
2777-
error_errno("unable to mmap '%s'", config_filename);
2777+
error_errno(_("unable to mmap '%s'"), config_filename);
27782778
ret = CONFIG_INVALID_FILE;
27792779
contents = NULL;
27802780
goto out_free;
@@ -2783,7 +2783,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
27832783
in_fd = -1;
27842784

27852785
if (chmod(get_lock_file_path(&lock), st.st_mode & 07777) < 0) {
2786-
error_errno("chmod on %s failed", get_lock_file_path(&lock));
2786+
error_errno(_("chmod on %s failed"), get_lock_file_path(&lock));
27872787
ret = CONFIG_NO_WRITE;
27882788
goto out_free;
27892789
}
@@ -2868,7 +2868,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
28682868
}
28692869

28702870
if (commit_lock_file(&lock) < 0) {
2871-
error_errno("could not write config file %s", config_filename);
2871+
error_errno(_("could not write config file %s"), config_filename);
28722872
ret = CONFIG_NO_WRITE;
28732873
goto out_free;
28742874
}
@@ -2994,7 +2994,7 @@ static int git_config_copy_or_rename_section_in_file(const char *config_filename
29942994
memset(&store, 0, sizeof(store));
29952995

29962996
if (new_name && !section_name_is_ok(new_name)) {
2997-
ret = error("invalid section name: %s", new_name);
2997+
ret = error(_("invalid section name: %s"), new_name);
29982998
goto out_no_rollback;
29992999
}
30003000

@@ -3003,7 +3003,7 @@ static int git_config_copy_or_rename_section_in_file(const char *config_filename
30033003

30043004
out_fd = hold_lock_file_for_update(&lock, config_filename, 0);
30053005
if (out_fd < 0) {
3006-
ret = error("could not lock config file %s", config_filename);
3006+
ret = error(_("could not lock config file %s"), config_filename);
30073007
goto out;
30083008
}
30093009

@@ -3021,7 +3021,7 @@ static int git_config_copy_or_rename_section_in_file(const char *config_filename
30213021
}
30223022

30233023
if (chmod(get_lock_file_path(&lock), st.st_mode & 07777) < 0) {
3024-
ret = error_errno("chmod on %s failed",
3024+
ret = error_errno(_("chmod on %s failed"),
30253025
get_lock_file_path(&lock));
30263026
goto out;
30273027
}
@@ -3118,7 +3118,7 @@ static int git_config_copy_or_rename_section_in_file(const char *config_filename
31183118
config_file = NULL;
31193119
commit_and_out:
31203120
if (commit_lock_file(&lock) < 0)
3121-
ret = error_errno("could not write config file %s",
3121+
ret = error_errno(_("could not write config file %s"),
31223122
config_filename);
31233123
out:
31243124
if (config_file)
@@ -3161,7 +3161,7 @@ int git_config_copy_section(const char *old_name, const char *new_name)
31613161
#undef config_error_nonbool
31623162
int config_error_nonbool(const char *var)
31633163
{
3164-
return error("missing value for '%s'", var);
3164+
return error(_("missing value for '%s'"), var);
31653165
}
31663166

31673167
int parse_config_key(const char *var,

t/t1305-config-include.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ test_expect_success 'include cycles are detected' '
310310
cycle
311311
EOF
312312
test_must_fail git config --get-all test.value 2>stderr &&
313-
grep "exceeded maximum include depth" stderr
313+
test_i18ngrep "exceeded maximum include depth" stderr
314314
'
315315

316316
test_done

0 commit comments

Comments
 (0)