From: Junio C Hamano Date: Fri, 4 Jan 2019 21:33:31 +0000 (-0800) Subject: Merge branch 'nd/i18n' X-Git-Tag: v2.21.0-rc0~135 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/3813a89faee3ecb111aa206f68b46618ec853e4e Merge branch 'nd/i18n' More _("i18n") markings. * nd/i18n: fsck: mark strings for translation fsck: reduce word legos to help i18n parse-options.c: mark more strings for translation parse-options.c: turn some die() to BUG() parse-options: replace opterror() with optname() repack: mark more strings for translation remote.c: mark messages for translation remote.c: turn some error() or die() to BUG() reflog: mark strings for translation read-cache.c: add missing colon separators read-cache.c: mark more strings for translation read-cache.c: turn die("internal error") to BUG() attr.c: mark more string for translation archive.c: mark more strings for translation alias.c: mark split_cmdline_strerror() strings for translation git.c: mark more strings for translation --- 3813a89faee3ecb111aa206f68b46618ec853e4e diff --cc builtin/fsck.c index 3c3e0f06e7,dcf72859a6..a281d7cd12 --- a/builtin/fsck.c +++ b/builtin/fsck.c @@@ -610,29 -607,28 +633,30 @@@ static int fsck_head_link(const char *h int null_is_error = 0; if (verbose) - fprintf(stderr, "Checking %s link\n", head_ref_name); - fprintf_ln(stderr, _("Checking HEAD link")); ++ fprintf_ln(stderr, _("Checking %s link"), head_ref_name); - head_points_at = resolve_ref_unsafe("HEAD", 0, &head_oid, NULL); - if (!head_points_at) { + *head_points_at = resolve_ref_unsafe(head_ref_name, 0, head_oid, NULL); + if (!*head_points_at) { errors_found |= ERROR_REFS; - return error("Invalid %s", head_ref_name); - return error(_("invalid HEAD")); ++ return error(_("invalid %s"), head_ref_name); } - if (!strcmp(head_points_at, "HEAD")) + if (!strcmp(*head_points_at, head_ref_name)) /* detached HEAD */ null_is_error = 1; - else if (!starts_with(head_points_at, "refs/heads/")) { + else if (!starts_with(*head_points_at, "refs/heads/")) { errors_found |= ERROR_REFS; - return error("%s points to something strange (%s)", - return error(_("HEAD points to something strange (%s)"), - head_points_at); ++ return error(_("%s points to something strange (%s)"), + head_ref_name, *head_points_at); } - if (is_null_oid(&head_oid)) { + if (is_null_oid(head_oid)) { if (null_is_error) { errors_found |= ERROR_REFS; - return error("%s: detached HEAD points at nothing", - return error(_("HEAD: detached HEAD points at nothing")); ++ return error(_("%s: detached HEAD points at nothing"), + head_ref_name); } - fprintf(stderr, "notice: %s points to an unborn branch (%s)\n", - head_ref_name, *head_points_at + 11); - fprintf_ln(stderr, _("notice: HEAD points to an unborn branch (%s)"), - head_points_at + 11); ++ fprintf_ln(stderr, ++ _("notice: %s points to an unborn branch (%s)"), ++ head_ref_name, *head_points_at + 11); } return 0; } diff --cc builtin/repack.c index 45583683ee,721f947218..2a1c7b21c5 --- a/builtin/repack.c +++ b/builtin/repack.c @@@ -235,8 -235,8 +235,8 @@@ static void repack_promisor_objects(con while (strbuf_getline_lf(&line, out) != EOF) { char *promisor_name; int fd; - if (line.len != 40) - die(_("repack: Expecting 40 character sha1 lines only from pack-objects.")); + if (line.len != the_hash_algo->hexsz) - die("repack: Expecting full hex object ID lines only from pack-objects."); ++ die(_("repack: Expecting full hex object ID lines only from pack-objects.")); string_list_append(names, line.buf); /* @@@ -407,8 -407,8 +407,8 @@@ int cmd_repack(int argc, const char **a out = xfdopen(cmd.out, "r"); while (strbuf_getline_lf(&line, out) != EOF) { - if (line.len != 40) - die(_("repack: Expecting 40 character sha1 lines only from pack-objects")); + if (line.len != the_hash_algo->hexsz) - die("repack: Expecting full hex object ID lines only from pack-objects."); ++ die(_("repack: Expecting full hex object ID lines only from pack-objects.")); string_list_append(&names, line.buf); } fclose(out); diff --cc parse-options.h index a650a7d220,2e146aa6fa..81380c22b6 --- a/parse-options.h +++ b/parse-options.h @@@ -186,25 -189,8 +186,22 @@@ extern NORETURN void usage_msg_opt(cons const struct option *options); extern int optbug(const struct option *opt, const char *reason); - extern int opterror(const struct option *opt, const char *reason, int flags); - #if defined(__GNUC__) - #define opterror(o,r,f) (opterror((o),(r),(f)), const_error()) - #endif + const char *optname(const struct option *opt, int flags); +/* + * Use these assertions for callbacks that expect to be called with NONEG and + * NOARG respectively, and do not otherwise handle the "unset" and "arg" + * parameters. + */ +#define BUG_ON_OPT_NEG(unset) do { \ + if ((unset)) \ + BUG("option callback does not expect negation"); \ +} while (0) +#define BUG_ON_OPT_ARG(arg) do { \ + if ((arg)) \ + BUG("option callback does not expect an argument"); \ +} while (0) + /*----- incremental advanced APIs -----*/ enum { diff --cc read-cache.c index bd45dc3e24,8d99ae376c..68534a9d48 --- a/read-cache.c +++ b/read-cache.c @@@ -1491,17 -1492,11 +1492,17 @@@ int refresh_index(struct index_state *i istate->cache_nr); trace_performance_enter(); - modified_fmt = (in_porcelain ? "M\t%s\n" : "%s: needs update\n"); - deleted_fmt = (in_porcelain ? "D\t%s\n" : "%s: needs update\n"); - typechange_fmt = (in_porcelain ? "T\t%s\n" : "%s needs update\n"); - added_fmt = (in_porcelain ? "A\t%s\n" : "%s needs update\n"); - unmerged_fmt = (in_porcelain ? "U\t%s\n" : "%s: needs merge\n"); + modified_fmt = in_porcelain ? "M\t%s\n" : "%s: needs update\n"; + deleted_fmt = in_porcelain ? "D\t%s\n" : "%s: needs update\n"; + typechange_fmt = in_porcelain ? "T\t%s\n" : "%s: needs update\n"; + added_fmt = in_porcelain ? "A\t%s\n" : "%s: needs update\n"; + unmerged_fmt = in_porcelain ? "U\t%s\n" : "%s: needs merge\n"; + /* + * Use the multi-threaded preload_index() to refresh most of the + * cache entries quickly then in the single threaded loop below, + * we only have to do the special cases that are left. + */ + preload_index(istate, pathspec, 0); for (i = 0; i < istate->cache_nr; i++) { struct cache_entry *ce, *new_entry; int cache_errno = 0; diff --cc ref-filter.c index 5de616befe,0681359100..75281c73f2 --- a/ref-filter.c +++ b/ref-filter.c @@@ -2320,13 -2300,13 +2320,15 @@@ int parse_opt_merge_filter(const struc struct object_id oid; int no_merged = starts_with(opt->long_name, "no"); + BUG_ON_OPT_NEG(unset); + if (rf->merge) { if (no_merged) { - return opterror(opt, "is incompatible with --merged", 0); + return error(_("option `%s' is incompatible with --merged"), + opt->long_name); } else { - return opterror(opt, "is incompatible with --no-merged", 0); + return error(_("option `%s' is incompatible with --no-merged"), + opt->long_name); } } diff --cc t/t1450-fsck.sh index e20e8fa830,15ca98b2a9..2e5e979336 --- a/t/t1450-fsck.sh +++ b/t/t1450-fsck.sh @@@ -98,44 -98,9 +98,44 @@@ test_expect_success 'HEAD link pointin # avoid corrupt/broken HEAD from interfering with repo discovery test_must_fail env GIT_DIR=.git git fsck 2>out && cat out && - grep "HEAD points to something strange" out + test_i18ngrep "HEAD points to something strange" out ' +test_expect_success 'HEAD link pointing at a funny object (from different wt)' ' + test_when_finished "mv .git/SAVED_HEAD .git/HEAD" && + test_when_finished "rm -rf .git/worktrees wt" && + git worktree add wt && + mv .git/HEAD .git/SAVED_HEAD && + echo $ZERO_OID >.git/HEAD && + # avoid corrupt/broken HEAD from interfering with repo discovery + test_must_fail git -C wt fsck 2>out && - grep "main-worktree/HEAD: detached HEAD points" out ++ test_i18ngrep "main-worktree/HEAD: detached HEAD points" out +' + +test_expect_success 'other worktree HEAD link pointing at a funny object' ' + test_when_finished "rm -rf .git/worktrees other" && + git worktree add other && + echo $ZERO_OID >.git/worktrees/other/HEAD && + test_must_fail git fsck 2>out && - grep "worktrees/other/HEAD: detached HEAD points" out ++ test_i18ngrep "worktrees/other/HEAD: detached HEAD points" out +' + +test_expect_success 'other worktree HEAD link pointing at missing object' ' + test_when_finished "rm -rf .git/worktrees other" && + git worktree add other && + echo "Contents missing from repo" | git hash-object --stdin >.git/worktrees/other/HEAD && + test_must_fail git fsck 2>out && - grep "worktrees/other/HEAD: invalid sha1 pointer" out ++ test_i18ngrep "worktrees/other/HEAD: invalid sha1 pointer" out +' + +test_expect_success 'other worktree HEAD link pointing at a funny place' ' + test_when_finished "rm -rf .git/worktrees other" && + git worktree add other && + echo "ref: refs/funny/place" >.git/worktrees/other/HEAD && + test_must_fail git fsck 2>out && - grep "worktrees/other/HEAD points to something strange" out ++ test_i18ngrep "worktrees/other/HEAD points to something strange" out +' + test_expect_success 'email without @ is okay' ' git cat-file commit HEAD >basis && sed "s/@/AT/" basis >okay && diff --cc t/t5616-partial-clone.sh index 336f02a41a,6391437529..9643acb161 --- a/t/t5616-partial-clone.sh +++ b/t/t5616-partial-clone.sh @@@ -281,7 -239,7 +281,7 @@@ test_expect_success 'upon cloning, chec test_must_fail git -c protocol.version=2 clone \ --filter=blob:none $HTTPD_URL/one_time_sed/server repo 2>err && -- grep "did not send all necessary objects" err && ++ test_i18ngrep "did not send all necessary objects" err && # Ensure that the one-time-sed script was used. ! test -e "$HTTPD_ROOT_PATH/one-time-sed" diff --cc t/t5703-upload-pack-ref-in-want.sh index 3f58f05cbb,3f58f05cbb..7053899cb5 --- a/t/t5703-upload-pack-ref-in-want.sh +++ b/t/t5703-upload-pack-ref-in-want.sh @@@ -208,7 -208,7 +208,7 @@@ test_expect_success 'server is initiall cp -r "$LOCAL_PRISTINE" local && inconsistency master 1234567890123456789012345678901234567890 && test_must_fail git -C local fetch 2>err && -- grep "ERR upload-pack: not our ref" err ++ test_i18ngrep "ERR upload-pack: not our ref" err ' test_expect_success 'server is initially ahead - ref in want' ' @@@ -254,7 -254,7 +254,7 @@@ test_expect_success 'server loses a re echo "s/master/raster/" >"$HTTPD_ROOT_PATH/one-time-sed" && test_must_fail git -C local fetch 2>err && -- grep "ERR unknown ref refs/heads/raster" err ++ test_i18ngrep "ERR unknown ref refs/heads/raster" err ' stop_httpd