diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2018-07-21 09:49:19 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-07-23 11:19:09 -0700 |
commit | 1a07e59c3e269418f3f5d186d166bf5ab5db6667 (patch) | |
tree | af7144a561d023b0d095c6c5463d00fe05248be6 /builtin | |
parent | Second batch for 2.19 cycle (diff) | |
download | tgif-1a07e59c3e269418f3f5d186d166bf5ab5db6667.tar.xz |
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 <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/blame.c | 2 | ||||
-rw-r--r-- | builtin/checkout.c | 4 | ||||
-rw-r--r-- | builtin/commit.c | 6 | ||||
-rw-r--r-- | builtin/config.c | 18 | ||||
-rw-r--r-- | builtin/fast-export.c | 42 | ||||
-rw-r--r-- | builtin/fmt-merge-msg.c | 2 | ||||
-rw-r--r-- | builtin/grep.c | 10 | ||||
-rw-r--r-- | builtin/log.c | 6 | ||||
-rw-r--r-- | builtin/merge.c | 2 | ||||
-rw-r--r-- | builtin/pack-objects.c | 25 | ||||
-rw-r--r-- | builtin/replace.c | 26 | ||||
-rw-r--r-- | builtin/rm.c | 2 |
12 files changed, 77 insertions, 68 deletions
diff --git a/builtin/blame.c b/builtin/blame.c index 5a0388aaef..b77ba6ae82 100644 --- a/builtin/blame.c +++ b/builtin/blame.c @@ -408,7 +408,7 @@ static void parse_color_fields(const char *s) } if (next == EXPECT_COLOR) - die (_("must end with a color")); + die(_("must end with a color")); colorfield[colorfield_nr].hop = TIME_MAX; string_list_clear(&l, 0); diff --git a/builtin/checkout.c b/builtin/checkout.c index 4c41d8b4c8..626868637a 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -1191,12 +1191,12 @@ int cmd_checkout(int argc, const char **argv, const char *prefix) if (opts.track != BRANCH_TRACK_UNSPECIFIED && !opts.new_branch) { const char *argv0 = argv[0]; if (!argc || !strcmp(argv0, "--")) - die (_("--track needs a branch name")); + die(_("--track needs a branch name")); skip_prefix(argv0, "refs/", &argv0); skip_prefix(argv0, "remotes/", &argv0); argv0 = strchr(argv0, '/'); if (!argv0 || !argv0[1]) - die (_("Missing branch name; try -b")); + die(_("missing branch name; try -b")); opts.new_branch = argv0 + 1; } diff --git a/builtin/commit.c b/builtin/commit.c index 9bcbb0c25c..d3276a10b2 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -1647,9 +1647,9 @@ int cmd_commit(int argc, const char **argv, const char *prefix) unlink(git_path_squash_msg()); if (commit_index_files()) - die (_("Repository has been updated, but unable to write\n" - "new_index file. Check that disk is not full and quota is\n" - "not exceeded, and then \"git reset HEAD\" to recover.")); + die(_("repository has been updated, but unable to write\n" + "new_index file. Check that disk is not full and quota is\n" + "not exceeded, and then \"git reset HEAD\" to recover.")); rerere(0); run_command_v_opt(argv_gc_auto, RUN_GIT_CMD); diff --git a/builtin/config.c b/builtin/config.c index b29d26dede..a09ead5bc8 100644 --- a/builtin/config.c +++ b/builtin/config.c @@ -110,7 +110,7 @@ static int option_parse_type(const struct option *opt, const char *arg, * --int' and '--type=bool * --type=int'. */ - error("only one type at a time."); + error("only one type at a time"); usage_with_options(builtin_config_usage, builtin_config_options); } @@ -160,7 +160,11 @@ static struct option builtin_config_options[] = { static void check_argc(int argc, int min, int max) { if (argc >= min && argc <= max) return; - error("wrong number of arguments"); + if (min == max) + error("wrong number of arguments, should be %d", min); + else + error("wrong number of arguments, should be from %d to %d", + min, max); usage_with_options(builtin_config_usage, builtin_config_options); } @@ -595,7 +599,7 @@ int cmd_config(int argc, const char **argv, const char *prefix) if (use_global_config + use_system_config + use_local_config + !!given_config_source.file + !!given_config_source.blob > 1) { - error("only one config file at a time."); + error("only one config file at a time"); usage_with_options(builtin_config_usage, builtin_config_options); } @@ -664,7 +668,7 @@ int cmd_config(int argc, const char **argv, const char *prefix) } if (HAS_MULTI_BITS(actions)) { - error("only one action at a time."); + error("only one action at a time"); usage_with_options(builtin_config_usage, builtin_config_options); } if (actions == 0) @@ -684,7 +688,7 @@ int cmd_config(int argc, const char **argv, const char *prefix) if (show_origin && !(actions & (ACTION_GET|ACTION_GET_ALL|ACTION_GET_REGEXP|ACTION_LIST))) { error("--show-origin is only applicable to --get, --get-all, " - "--get-regexp, and --list."); + "--get-regexp, and --list"); usage_with_options(builtin_config_usage, builtin_config_options); } @@ -819,7 +823,7 @@ int cmd_config(int argc, const char **argv, const char *prefix) if (ret < 0) return ret; if (ret == 0) - die("No such section!"); + die("no such section: %s", argv[0]); } else if (actions == ACTION_REMOVE_SECTION) { int ret; @@ -830,7 +834,7 @@ int cmd_config(int argc, const char **argv, const char *prefix) if (ret < 0) return ret; if (ret == 0) - die("No such section!"); + die("no such section: %s", argv[0]); } else if (actions == ACTION_GET_COLOR) { check_argc(argc, 1, 2); diff --git a/builtin/fast-export.c b/builtin/fast-export.c index 73d12c1020..83c482581b 100644 --- a/builtin/fast-export.c +++ b/builtin/fast-export.c @@ -240,7 +240,7 @@ static void export_blob(const struct object_id *oid) } else { buf = read_object_file(oid, &type, &size); if (!buf) - die ("Could not read blob %s", oid_to_hex(oid)); + die("could not read blob %s", oid_to_hex(oid)); if (check_object_signature(oid, buf, size, type_name(type)) < 0) die("sha1 mismatch in blob %s", oid_to_hex(oid)); object = parse_object_buffer(oid, type, size, buf, &eaten); @@ -253,7 +253,7 @@ static void export_blob(const struct object_id *oid) printf("blob\nmark :%"PRIu32"\ndata %lu\n", last_idnum, size); if (size && fwrite(buf, size, 1, stdout) != 1) - die_errno ("Could not write blob '%s'", oid_to_hex(oid)); + die_errno("could not write blob '%s'", oid_to_hex(oid)); printf("\n"); show_progress(); @@ -560,14 +560,14 @@ static void handle_commit(struct commit *commit, struct rev_info *rev, commit_buffer = get_commit_buffer(commit, NULL); author = strstr(commit_buffer, "\nauthor "); if (!author) - die ("Could not find author in commit %s", - oid_to_hex(&commit->object.oid)); + die("could not find author in commit %s", + oid_to_hex(&commit->object.oid)); author++; author_end = strchrnul(author, '\n'); committer = strstr(author_end, "\ncommitter "); if (!committer) - die ("Could not find committer in commit %s", - oid_to_hex(&commit->object.oid)); + die("could not find committer in commit %s", + oid_to_hex(&commit->object.oid)); committer++; committer_end = strchrnul(committer, '\n'); message = strstr(committer_end, "\n\n"); @@ -688,7 +688,7 @@ static void handle_tag(const char *name, struct tag *tag) buf = read_object_file(&tag->object.oid, &type, &size); if (!buf) - die ("Could not read tag %s", oid_to_hex(&tag->object.oid)); + die("could not read tag %s", oid_to_hex(&tag->object.oid)); message = memmem(buf, size, "\n\n", 2); if (message) { message += 2; @@ -725,18 +725,18 @@ static void handle_tag(const char *name, struct tag *tag) if (signature) switch(signed_tag_mode) { case ABORT: - die ("Encountered signed tag %s; use " - "--signed-tags=<mode> to handle it.", - oid_to_hex(&tag->object.oid)); + die("encountered signed tag %s; use " + "--signed-tags=<mode> to handle it", + oid_to_hex(&tag->object.oid)); case WARN: - warning ("Exporting signed tag %s", - oid_to_hex(&tag->object.oid)); + warning("exporting signed tag %s", + oid_to_hex(&tag->object.oid)); /* fallthru */ case VERBATIM: break; case WARN_STRIP: - warning ("Stripping signature from tag %s", - oid_to_hex(&tag->object.oid)); + warning("stripping signature from tag %s", + oid_to_hex(&tag->object.oid)); /* fallthru */ case STRIP: message_size = signature + 1 - message; @@ -750,18 +750,18 @@ static void handle_tag(const char *name, struct tag *tag) if (!tagged_mark) { switch(tag_of_filtered_mode) { case ABORT: - die ("Tag %s tags unexported object; use " - "--tag-of-filtered-object=<mode> to handle it.", - oid_to_hex(&tag->object.oid)); + die("tag %s tags unexported object; use " + "--tag-of-filtered-object=<mode> to handle it", + oid_to_hex(&tag->object.oid)); case DROP: /* Ignore this tag altogether */ free(buf); return; case REWRITE: if (tagged->type != OBJ_COMMIT) { - die ("Tag %s tags unexported %s!", - oid_to_hex(&tag->object.oid), - type_name(tagged->type)); + die("tag %s tags unexported %s!", + oid_to_hex(&tag->object.oid), + type_name(tagged->type)); } p = (struct commit *)tagged; for (;;) { @@ -772,7 +772,7 @@ static void handle_tag(const char *name, struct tag *tag) if (!(p->object.flags & TREESAME)) break; if (!p->parents) - die ("Can't find replacement commit for tag %s\n", + die("can't find replacement commit for tag %s", oid_to_hex(&tag->object.oid)); p = p->parents->item; } diff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c index bd680be687..a08f239e00 100644 --- a/builtin/fmt-merge-msg.c +++ b/builtin/fmt-merge-msg.c @@ -623,7 +623,7 @@ int fmt_merge_msg(struct strbuf *in, struct strbuf *out, i++; p[len] = 0; if (handle_line(p, &merge_parents)) - die ("Error in line %d: %.*s", i, len, p); + die("error in line %d: %.*s", i, len, p); } if (opts->add_title && srcs.nr) diff --git a/builtin/grep.c b/builtin/grep.c index ee753a403e..9774920999 100644 --- a/builtin/grep.c +++ b/builtin/grep.c @@ -959,7 +959,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix) } if (!opt.pattern_list) - die(_("no pattern given.")); + die(_("no pattern given")); /* * We have to find "--" in a separate pass, because its presence @@ -1085,19 +1085,19 @@ int cmd_grep(int argc, const char **argv, const char *prefix) } if (recurse_submodules && (!use_index || untracked)) - die(_("option not supported with --recurse-submodules.")); + die(_("option not supported with --recurse-submodules")); if (!show_in_pager && !opt.status_only) setup_pager(); if (!use_index && (untracked || cached)) - die(_("--cached or --untracked cannot be used with --no-index.")); + die(_("--cached or --untracked cannot be used with --no-index")); if (!use_index || untracked) { int use_exclude = (opt_exclude < 0) ? use_index : !!opt_exclude; hit = grep_directory(&opt, &pathspec, use_exclude, use_index); } else if (0 <= opt_exclude) { - die(_("--[no-]exclude-standard cannot be used for tracked contents.")); + die(_("--[no-]exclude-standard cannot be used for tracked contents")); } else if (!list.nr) { if (!cached) setup_work_tree(); @@ -1105,7 +1105,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix) hit = grep_cache(&opt, the_repository, &pathspec, cached); } else { if (cached) - die(_("both --cached and trees are given.")); + die(_("both --cached and trees are given")); hit = grep_objects(&opt, &pathspec, &list); } diff --git a/builtin/log.c b/builtin/log.c index 0583f7f383..99d4c6996e 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -1606,14 +1606,14 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix) numbered = 0; if (numbered && keep_subject) - die (_("-n and -k are mutually exclusive.")); + die(_("-n and -k are mutually exclusive")); if (keep_subject && subject_prefix) - die (_("--subject-prefix/--rfc and -k are mutually exclusive.")); + die(_("--subject-prefix/--rfc and -k are mutually exclusive")); rev.preserve_subject = keep_subject; argc = setup_revisions(argc, argv, &rev, &s_r_opt); if (argc > 1) - die (_("unrecognized argument: %s"), argv[1]); + die(_("unrecognized argument: %s"), argv[1]); if (rev.diffopt.output_format & DIFF_FORMAT_NAME) die(_("--name-only does not make sense")); diff --git a/builtin/merge.c b/builtin/merge.c index 4a4c09496c..f553f89a48 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -693,7 +693,7 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common, exit(128); if (write_locked_index(&the_index, &lock, COMMIT_LOCK | SKIP_IF_UNCHANGED)) - die (_("unable to write %s"), get_index_file()); + die(_("unable to write %s"), get_index_file()); return clean ? 0 : 1; } else { return try_merge_command(strategy, xopts_nr, xopts, diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index 71056d8294..f3443d672b 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -148,8 +148,13 @@ static void *get_delta(struct object_entry *entry) oid_to_hex(&DELTA(entry)->idx.oid)); delta_buf = diff_delta(base_buf, base_size, buf, size, &delta_size, 0); + /* + * We succesfully computed this delta once but dropped it for + * memory reasons. Something is very wrong if this time we + * recompute and create a different delta. + */ if (!delta_buf || delta_size != DELTA_SIZE(entry)) - die("delta size changed"); + BUG("delta size changed"); free(buf); free(base_buf); return delta_buf; @@ -2341,8 +2346,8 @@ static void ll_find_deltas(struct object_entry **list, unsigned list_size, return; } if (progress > pack_to_stdout) - fprintf(stderr, "Delta compression using up to %d threads.\n", - delta_search_threads); + fprintf_ln(stderr, "Delta compression using up to %d threads", + delta_search_threads); p = xcalloc(delta_search_threads, sizeof(*p)); /* Partition the work amongst work threads. */ @@ -2638,7 +2643,7 @@ static void read_object_list_from_stdin(void) if (feof(stdin)) break; if (!ferror(stdin)) - die("fgets returned NULL, not EOF, not error!"); + die("BUG: fgets returned NULL, not EOF, not error!"); if (errno != EINTR) die_errno("fgets"); clearerr(stdin); @@ -3263,7 +3268,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix) if (!pack_to_stdout && !pack_size_limit) pack_size_limit = pack_size_limit_cfg; if (pack_to_stdout && pack_size_limit) - die("--max-pack-size cannot be used to build a pack for transfer."); + die("--max-pack-size cannot be used to build a pack for transfer"); if (pack_size_limit && pack_size_limit < 1024*1024) { warning("minimum pack size limit is 1 MiB"); pack_size_limit = 1024*1024; @@ -3273,13 +3278,13 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix) die("--thin cannot be used to build an indexable pack."); if (keep_unreachable && unpack_unreachable) - die("--keep-unreachable and --unpack-unreachable are incompatible."); + die("--keep-unreachable and --unpack-unreachable are incompatible"); if (!rev_list_all || !rev_list_reflog || !rev_list_index) unpack_unreachable_expiration = 0; if (filter_options.choice) { if (!pack_to_stdout) - die("cannot use --filter without --stdout."); + die("cannot use --filter without --stdout"); use_bitmap_index = 0; } @@ -3353,8 +3358,8 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix) prepare_pack(window, depth); write_pack_file(); if (progress) - fprintf(stderr, "Total %"PRIu32" (delta %"PRIu32")," - " reused %"PRIu32" (delta %"PRIu32")\n", - written, written_delta, reused, reused_delta); + fprintf_ln(stderr, "Total %"PRIu32" (delta %"PRIu32")," + " reused %"PRIu32" (delta %"PRIu32")", + written, written_delta, reused, reused_delta); return 0; } diff --git a/builtin/replace.c b/builtin/replace.c index 6da2411e14..5926ad11de 100644 --- a/builtin/replace.c +++ b/builtin/replace.c @@ -54,7 +54,7 @@ static int show_reference(const char *refname, const struct object_id *oid, enum object_type obj_type, repl_type; if (get_oid(refname, &object)) - return error("Failed to resolve '%s' as a valid ref.", refname); + return error("failed to resolve '%s' as a valid ref", refname); obj_type = oid_object_info(the_repository, &object, NULL); @@ -84,7 +84,7 @@ static int list_replace_refs(const char *pattern, const char *format) data.format = REPLACE_FORMAT_LONG; else return error("invalid replace format '%s'\n" - "valid formats are 'short', 'medium' and 'long'\n", + "valid formats are 'short', 'medium' and 'long'", format); for_each_replace_ref(the_repository, show_reference, (void *)&data); @@ -108,7 +108,7 @@ static int for_each_replace_name(const char **argv, each_replace_name_fn fn) for (p = argv; *p; p++) { if (get_oid(*p, &oid)) { - error("Failed to resolve '%s' as a valid ref.", *p); + error("failed to resolve '%s' as a valid ref", *p); had_error = 1; continue; } @@ -118,7 +118,7 @@ static int for_each_replace_name(const char **argv, each_replace_name_fn fn) full_hex = ref.buf + base_len; if (read_ref(ref.buf, &oid)) { - error("replace ref '%s' not found.", full_hex); + error("replace ref '%s' not found", full_hex); had_error = 1; continue; } @@ -134,7 +134,7 @@ static int delete_replace_ref(const char *name, const char *ref, { if (delete_ref(NULL, ref, oid, 0)) return 1; - printf("Deleted replace ref '%s'\n", name); + printf_ln("Deleted replace ref '%s'", name); return 0; } @@ -146,7 +146,7 @@ static int check_ref_valid(struct object_id *object, strbuf_reset(ref); strbuf_addf(ref, "%s%s", git_replace_ref_base, oid_to_hex(object)); if (check_refname_format(ref->buf, 0)) - return error("'%s' is not a valid ref name.", ref->buf); + return error("'%s' is not a valid ref name", ref->buf); if (read_ref(ref->buf, prev)) oidclr(prev); @@ -200,10 +200,10 @@ static int replace_object(const char *object_ref, const char *replace_ref, int f struct object_id object, repl; if (get_oid(object_ref, &object)) - return error("Failed to resolve '%s' as a valid ref.", + return error("failed to resolve '%s' as a valid ref", object_ref); if (get_oid(replace_ref, &repl)) - return error("Failed to resolve '%s' as a valid ref.", + return error("failed to resolve '%s' as a valid ref", replace_ref); return replace_object_oid(object_ref, &object, replace_ref, &repl, force); @@ -315,7 +315,7 @@ static int edit_and_replace(const char *object_ref, int force, int raw) struct strbuf ref = STRBUF_INIT; if (get_oid(object_ref, &old_oid) < 0) - return error("Not a valid object name: '%s'", object_ref); + return error("not a valid object name: '%s'", object_ref); type = oid_object_info(the_repository, &old_oid, NULL); if (type < 0) @@ -368,7 +368,7 @@ static int replace_parents(struct strbuf *buf, int argc, const char **argv) struct object_id oid; if (get_oid(argv[i], &oid) < 0) { strbuf_release(&new_parents); - return error(_("Not a valid object name: '%s'"), + return error(_("not a valid object name: '%s'"), argv[i]); } if (!lookup_commit_reference(&oid)) { @@ -412,7 +412,7 @@ static int check_one_mergetag(struct commit *commit, for (i = 1; i < mergetag_data->argc; i++) { struct object_id oid; if (get_oid(mergetag_data->argv[i], &oid) < 0) - return error(_("Not a valid object name: '%s'"), + return error(_("not a valid object name: '%s'"), mergetag_data->argv[i]); if (!oidcmp(&tag->tagged->oid, &oid)) return 0; /* found */ @@ -442,7 +442,7 @@ static int create_graft(int argc, const char **argv, int force, int gentle) unsigned long size; if (get_oid(old_ref, &old_oid) < 0) - return error(_("Not a valid object name: '%s'"), old_ref); + return error(_("not a valid object name: '%s'"), old_ref); commit = lookup_commit_reference(&old_oid); if (!commit) return error(_("could not parse %s"), old_ref); @@ -457,7 +457,7 @@ static int create_graft(int argc, const char **argv, int force, int gentle) } if (remove_signature(&buf)) { - warning(_("the original commit '%s' has a gpg signature."), old_ref); + warning(_("the original commit '%s' has a gpg signature"), old_ref); warning(_("the signature will be removed in the replacement commit!")); } diff --git a/builtin/rm.c b/builtin/rm.c index 65b448ef8e..f4d3f000b6 100644 --- a/builtin/rm.c +++ b/builtin/rm.c @@ -285,7 +285,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix) list.entry[list.nr].is_submodule = S_ISGITLINK(ce->ce_mode); if (list.entry[list.nr++].is_submodule && !is_staging_gitmodules_ok(&the_index)) - die (_("Please stage your changes to .gitmodules or stash them to proceed")); + die(_("please stage your changes to .gitmodules or stash them to proceed")); } if (pathspec.nr) { |