Skip to content

Commit 1a07e59

Browse files
pcloudsgitster
authored andcommitted
Update messages in preparation for i18n
Many messages will be marked for translation in the following commits. This commit updates some of them to be more consistent and reduce diff noise in those commits. Changes are - keep the first letter of die(), error() and warning() in lowercase - no full stop in die(), error() or warning() if it's single sentence messages - indentation - some messages are turned to BUG(), or prefixed with "BUG:" and will not be marked for i18n - some messages are improved to give more information - some messages are broken down by sentence to be i18n friendly (on the same token, combine multiple warning() into one big string) - the trailing \n is converted to printf_ln if possible, or deleted if not redundant - errno_errno() is used instead of explicit strerror() Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e333175 commit 1a07e59

30 files changed

+154
-146
lines changed

archive-zip.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ static int write_zip_entry(struct archiver_args *args,
309309
if (is_utf8(path))
310310
flags |= ZIP_UTF8;
311311
else
312-
warning("Path is not valid UTF-8: %s", path);
312+
warning("path is not valid UTF-8: %s", path);
313313
}
314314

315315
if (pathlen > 0xffff) {

builtin/blame.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ static void parse_color_fields(const char *s)
408408
}
409409

410410
if (next == EXPECT_COLOR)
411-
die (_("must end with a color"));
411+
die(_("must end with a color"));
412412

413413
colorfield[colorfield_nr].hop = TIME_MAX;
414414
string_list_clear(&l, 0);

builtin/checkout.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,12 +1191,12 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
11911191
if (opts.track != BRANCH_TRACK_UNSPECIFIED && !opts.new_branch) {
11921192
const char *argv0 = argv[0];
11931193
if (!argc || !strcmp(argv0, "--"))
1194-
die (_("--track needs a branch name"));
1194+
die(_("--track needs a branch name"));
11951195
skip_prefix(argv0, "refs/", &argv0);
11961196
skip_prefix(argv0, "remotes/", &argv0);
11971197
argv0 = strchr(argv0, '/');
11981198
if (!argv0 || !argv0[1])
1199-
die (_("Missing branch name; try -b"));
1199+
die(_("missing branch name; try -b"));
12001200
opts.new_branch = argv0 + 1;
12011201
}
12021202

builtin/commit.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1647,9 +1647,9 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
16471647
unlink(git_path_squash_msg());
16481648

16491649
if (commit_index_files())
1650-
die (_("Repository has been updated, but unable to write\n"
1651-
"new_index file. Check that disk is not full and quota is\n"
1652-
"not exceeded, and then \"git reset HEAD\" to recover."));
1650+
die(_("repository has been updated, but unable to write\n"
1651+
"new_index file. Check that disk is not full and quota is\n"
1652+
"not exceeded, and then \"git reset HEAD\" to recover."));
16531653

16541654
rerere(0);
16551655
run_command_v_opt(argv_gc_auto, RUN_GIT_CMD);

builtin/config.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ static int option_parse_type(const struct option *opt, const char *arg,
110110
* --int' and '--type=bool
111111
* --type=int'.
112112
*/
113-
error("only one type at a time.");
113+
error("only one type at a time");
114114
usage_with_options(builtin_config_usage,
115115
builtin_config_options);
116116
}
@@ -160,7 +160,11 @@ static struct option builtin_config_options[] = {
160160
static void check_argc(int argc, int min, int max) {
161161
if (argc >= min && argc <= max)
162162
return;
163-
error("wrong number of arguments");
163+
if (min == max)
164+
error("wrong number of arguments, should be %d", min);
165+
else
166+
error("wrong number of arguments, should be from %d to %d",
167+
min, max);
164168
usage_with_options(builtin_config_usage, builtin_config_options);
165169
}
166170

@@ -595,7 +599,7 @@ int cmd_config(int argc, const char **argv, const char *prefix)
595599

596600
if (use_global_config + use_system_config + use_local_config +
597601
!!given_config_source.file + !!given_config_source.blob > 1) {
598-
error("only one config file at a time.");
602+
error("only one config file at a time");
599603
usage_with_options(builtin_config_usage, builtin_config_options);
600604
}
601605

@@ -664,7 +668,7 @@ int cmd_config(int argc, const char **argv, const char *prefix)
664668
}
665669

666670
if (HAS_MULTI_BITS(actions)) {
667-
error("only one action at a time.");
671+
error("only one action at a time");
668672
usage_with_options(builtin_config_usage, builtin_config_options);
669673
}
670674
if (actions == 0)
@@ -684,7 +688,7 @@ int cmd_config(int argc, const char **argv, const char *prefix)
684688
if (show_origin && !(actions &
685689
(ACTION_GET|ACTION_GET_ALL|ACTION_GET_REGEXP|ACTION_LIST))) {
686690
error("--show-origin is only applicable to --get, --get-all, "
687-
"--get-regexp, and --list.");
691+
"--get-regexp, and --list");
688692
usage_with_options(builtin_config_usage, builtin_config_options);
689693
}
690694

@@ -819,7 +823,7 @@ int cmd_config(int argc, const char **argv, const char *prefix)
819823
if (ret < 0)
820824
return ret;
821825
if (ret == 0)
822-
die("No such section!");
826+
die("no such section: %s", argv[0]);
823827
}
824828
else if (actions == ACTION_REMOVE_SECTION) {
825829
int ret;
@@ -830,7 +834,7 @@ int cmd_config(int argc, const char **argv, const char *prefix)
830834
if (ret < 0)
831835
return ret;
832836
if (ret == 0)
833-
die("No such section!");
837+
die("no such section: %s", argv[0]);
834838
}
835839
else if (actions == ACTION_GET_COLOR) {
836840
check_argc(argc, 1, 2);

builtin/fast-export.c

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ static void export_blob(const struct object_id *oid)
240240
} else {
241241
buf = read_object_file(oid, &type, &size);
242242
if (!buf)
243-
die ("Could not read blob %s", oid_to_hex(oid));
243+
die("could not read blob %s", oid_to_hex(oid));
244244
if (check_object_signature(oid, buf, size, type_name(type)) < 0)
245245
die("sha1 mismatch in blob %s", oid_to_hex(oid));
246246
object = parse_object_buffer(oid, type, size, buf, &eaten);
@@ -253,7 +253,7 @@ static void export_blob(const struct object_id *oid)
253253

254254
printf("blob\nmark :%"PRIu32"\ndata %lu\n", last_idnum, size);
255255
if (size && fwrite(buf, size, 1, stdout) != 1)
256-
die_errno ("Could not write blob '%s'", oid_to_hex(oid));
256+
die_errno("could not write blob '%s'", oid_to_hex(oid));
257257
printf("\n");
258258

259259
show_progress();
@@ -560,14 +560,14 @@ static void handle_commit(struct commit *commit, struct rev_info *rev,
560560
commit_buffer = get_commit_buffer(commit, NULL);
561561
author = strstr(commit_buffer, "\nauthor ");
562562
if (!author)
563-
die ("Could not find author in commit %s",
564-
oid_to_hex(&commit->object.oid));
563+
die("could not find author in commit %s",
564+
oid_to_hex(&commit->object.oid));
565565
author++;
566566
author_end = strchrnul(author, '\n');
567567
committer = strstr(author_end, "\ncommitter ");
568568
if (!committer)
569-
die ("Could not find committer in commit %s",
570-
oid_to_hex(&commit->object.oid));
569+
die("could not find committer in commit %s",
570+
oid_to_hex(&commit->object.oid));
571571
committer++;
572572
committer_end = strchrnul(committer, '\n');
573573
message = strstr(committer_end, "\n\n");
@@ -688,7 +688,7 @@ static void handle_tag(const char *name, struct tag *tag)
688688

689689
buf = read_object_file(&tag->object.oid, &type, &size);
690690
if (!buf)
691-
die ("Could not read tag %s", oid_to_hex(&tag->object.oid));
691+
die("could not read tag %s", oid_to_hex(&tag->object.oid));
692692
message = memmem(buf, size, "\n\n", 2);
693693
if (message) {
694694
message += 2;
@@ -725,18 +725,18 @@ static void handle_tag(const char *name, struct tag *tag)
725725
if (signature)
726726
switch(signed_tag_mode) {
727727
case ABORT:
728-
die ("Encountered signed tag %s; use "
729-
"--signed-tags=<mode> to handle it.",
730-
oid_to_hex(&tag->object.oid));
728+
die("encountered signed tag %s; use "
729+
"--signed-tags=<mode> to handle it",
730+
oid_to_hex(&tag->object.oid));
731731
case WARN:
732-
warning ("Exporting signed tag %s",
733-
oid_to_hex(&tag->object.oid));
732+
warning("exporting signed tag %s",
733+
oid_to_hex(&tag->object.oid));
734734
/* fallthru */
735735
case VERBATIM:
736736
break;
737737
case WARN_STRIP:
738-
warning ("Stripping signature from tag %s",
739-
oid_to_hex(&tag->object.oid));
738+
warning("stripping signature from tag %s",
739+
oid_to_hex(&tag->object.oid));
740740
/* fallthru */
741741
case STRIP:
742742
message_size = signature + 1 - message;
@@ -750,18 +750,18 @@ static void handle_tag(const char *name, struct tag *tag)
750750
if (!tagged_mark) {
751751
switch(tag_of_filtered_mode) {
752752
case ABORT:
753-
die ("Tag %s tags unexported object; use "
754-
"--tag-of-filtered-object=<mode> to handle it.",
755-
oid_to_hex(&tag->object.oid));
753+
die("tag %s tags unexported object; use "
754+
"--tag-of-filtered-object=<mode> to handle it",
755+
oid_to_hex(&tag->object.oid));
756756
case DROP:
757757
/* Ignore this tag altogether */
758758
free(buf);
759759
return;
760760
case REWRITE:
761761
if (tagged->type != OBJ_COMMIT) {
762-
die ("Tag %s tags unexported %s!",
763-
oid_to_hex(&tag->object.oid),
764-
type_name(tagged->type));
762+
die("tag %s tags unexported %s!",
763+
oid_to_hex(&tag->object.oid),
764+
type_name(tagged->type));
765765
}
766766
p = (struct commit *)tagged;
767767
for (;;) {
@@ -772,7 +772,7 @@ static void handle_tag(const char *name, struct tag *tag)
772772
if (!(p->object.flags & TREESAME))
773773
break;
774774
if (!p->parents)
775-
die ("Can't find replacement commit for tag %s\n",
775+
die("can't find replacement commit for tag %s",
776776
oid_to_hex(&tag->object.oid));
777777
p = p->parents->item;
778778
}

builtin/fmt-merge-msg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ int fmt_merge_msg(struct strbuf *in, struct strbuf *out,
623623
i++;
624624
p[len] = 0;
625625
if (handle_line(p, &merge_parents))
626-
die ("Error in line %d: %.*s", i, len, p);
626+
die("error in line %d: %.*s", i, len, p);
627627
}
628628

629629
if (opts->add_title && srcs.nr)

builtin/grep.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -959,7 +959,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
959959
}
960960

961961
if (!opt.pattern_list)
962-
die(_("no pattern given."));
962+
die(_("no pattern given"));
963963

964964
/*
965965
* We have to find "--" in a separate pass, because its presence
@@ -1085,27 +1085,27 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
10851085
}
10861086

10871087
if (recurse_submodules && (!use_index || untracked))
1088-
die(_("option not supported with --recurse-submodules."));
1088+
die(_("option not supported with --recurse-submodules"));
10891089

10901090
if (!show_in_pager && !opt.status_only)
10911091
setup_pager();
10921092

10931093
if (!use_index && (untracked || cached))
1094-
die(_("--cached or --untracked cannot be used with --no-index."));
1094+
die(_("--cached or --untracked cannot be used with --no-index"));
10951095

10961096
if (!use_index || untracked) {
10971097
int use_exclude = (opt_exclude < 0) ? use_index : !!opt_exclude;
10981098
hit = grep_directory(&opt, &pathspec, use_exclude, use_index);
10991099
} else if (0 <= opt_exclude) {
1100-
die(_("--[no-]exclude-standard cannot be used for tracked contents."));
1100+
die(_("--[no-]exclude-standard cannot be used for tracked contents"));
11011101
} else if (!list.nr) {
11021102
if (!cached)
11031103
setup_work_tree();
11041104

11051105
hit = grep_cache(&opt, the_repository, &pathspec, cached);
11061106
} else {
11071107
if (cached)
1108-
die(_("both --cached and trees are given."));
1108+
die(_("both --cached and trees are given"));
11091109

11101110
hit = grep_objects(&opt, &pathspec, &list);
11111111
}

builtin/log.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1606,14 +1606,14 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
16061606
numbered = 0;
16071607

16081608
if (numbered && keep_subject)
1609-
die (_("-n and -k are mutually exclusive."));
1609+
die(_("-n and -k are mutually exclusive"));
16101610
if (keep_subject && subject_prefix)
1611-
die (_("--subject-prefix/--rfc and -k are mutually exclusive."));
1611+
die(_("--subject-prefix/--rfc and -k are mutually exclusive"));
16121612
rev.preserve_subject = keep_subject;
16131613

16141614
argc = setup_revisions(argc, argv, &rev, &s_r_opt);
16151615
if (argc > 1)
1616-
die (_("unrecognized argument: %s"), argv[1]);
1616+
die(_("unrecognized argument: %s"), argv[1]);
16171617

16181618
if (rev.diffopt.output_format & DIFF_FORMAT_NAME)
16191619
die(_("--name-only does not make sense"));

builtin/merge.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,
693693
exit(128);
694694
if (write_locked_index(&the_index, &lock,
695695
COMMIT_LOCK | SKIP_IF_UNCHANGED))
696-
die (_("unable to write %s"), get_index_file());
696+
die(_("unable to write %s"), get_index_file());
697697
return clean ? 0 : 1;
698698
} else {
699699
return try_merge_command(strategy, xopts_nr, xopts,

0 commit comments

Comments
 (0)