Merge branch 'as/ll-i18n'

Some messages in low level start-up codepath have been i18n-ized.

* as/ll-i18n:
  Mark messages for translations
This commit is contained in:
Junio C Hamano 2018-02-27 10:33:58 -08:00
commit d4053966ea
5 changed files with 54 additions and 54 deletions

32
git.c
View File

@ -5,11 +5,11 @@
#include "run-command.h" #include "run-command.h"
const char git_usage_string[] = const char git_usage_string[] =
"git [--version] [--help] [-C <path>] [-c name=value]\n" N_("git [--version] [--help] [-C <path>] [-c <name>=<value>]\n"
" [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]\n" " [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]\n"
" [-p | --paginate | --no-pager] [--no-replace-objects] [--bare]\n" " [-p | --paginate | --no-pager] [--no-replace-objects] [--bare]\n"
" [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]\n" " [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]\n"
" <command> [<args>]"; " <command> [<args>]");
const char git_more_info_string[] = const char git_more_info_string[] =
N_("'git help -a' and 'git help -g' list available subcommands and some\n" N_("'git help -a' and 'git help -g' list available subcommands and some\n"
@ -92,7 +92,7 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
*envchanged = 1; *envchanged = 1;
} else if (!strcmp(cmd, "--git-dir")) { } else if (!strcmp(cmd, "--git-dir")) {
if (*argc < 2) { if (*argc < 2) {
fprintf(stderr, "No directory given for --git-dir.\n" ); fprintf(stderr, _("no directory given for --git-dir\n" ));
usage(git_usage_string); usage(git_usage_string);
} }
setenv(GIT_DIR_ENVIRONMENT, (*argv)[1], 1); setenv(GIT_DIR_ENVIRONMENT, (*argv)[1], 1);
@ -106,7 +106,7 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
*envchanged = 1; *envchanged = 1;
} else if (!strcmp(cmd, "--namespace")) { } else if (!strcmp(cmd, "--namespace")) {
if (*argc < 2) { if (*argc < 2) {
fprintf(stderr, "No namespace given for --namespace.\n" ); fprintf(stderr, _("no namespace given for --namespace\n" ));
usage(git_usage_string); usage(git_usage_string);
} }
setenv(GIT_NAMESPACE_ENVIRONMENT, (*argv)[1], 1); setenv(GIT_NAMESPACE_ENVIRONMENT, (*argv)[1], 1);
@ -120,7 +120,7 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
*envchanged = 1; *envchanged = 1;
} else if (!strcmp(cmd, "--work-tree")) { } else if (!strcmp(cmd, "--work-tree")) {
if (*argc < 2) { if (*argc < 2) {
fprintf(stderr, "No directory given for --work-tree.\n" ); fprintf(stderr, _("no directory given for --work-tree\n" ));
usage(git_usage_string); usage(git_usage_string);
} }
setenv(GIT_WORK_TREE_ENVIRONMENT, (*argv)[1], 1); setenv(GIT_WORK_TREE_ENVIRONMENT, (*argv)[1], 1);
@ -134,7 +134,7 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
*envchanged = 1; *envchanged = 1;
} else if (!strcmp(cmd, "--super-prefix")) { } else if (!strcmp(cmd, "--super-prefix")) {
if (*argc < 2) { if (*argc < 2) {
fprintf(stderr, "No prefix given for --super-prefix.\n" ); fprintf(stderr, _("no prefix given for --super-prefix\n" ));
usage(git_usage_string); usage(git_usage_string);
} }
setenv(GIT_SUPER_PREFIX_ENVIRONMENT, (*argv)[1], 1); setenv(GIT_SUPER_PREFIX_ENVIRONMENT, (*argv)[1], 1);
@ -156,7 +156,7 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
*envchanged = 1; *envchanged = 1;
} else if (!strcmp(cmd, "-c")) { } else if (!strcmp(cmd, "-c")) {
if (*argc < 2) { if (*argc < 2) {
fprintf(stderr, "-c expects a configuration string\n" ); fprintf(stderr, _("-c expects a configuration string\n" ));
usage(git_usage_string); usage(git_usage_string);
} }
git_config_push_parameter((*argv)[1]); git_config_push_parameter((*argv)[1]);
@ -194,12 +194,12 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
*envchanged = 1; *envchanged = 1;
} else if (!strcmp(cmd, "-C")) { } else if (!strcmp(cmd, "-C")) {
if (*argc < 2) { if (*argc < 2) {
fprintf(stderr, "No directory given for -C.\n" ); fprintf(stderr, _("no directory given for -C\n" ));
usage(git_usage_string); usage(git_usage_string);
} }
if ((*argv)[1][0]) { if ((*argv)[1][0]) {
if (chdir((*argv)[1])) if (chdir((*argv)[1]))
die_errno("Cannot change to '%s'", (*argv)[1]); die_errno("cannot change to '%s'", (*argv)[1]);
if (envchanged) if (envchanged)
*envchanged = 1; *envchanged = 1;
} }
@ -209,7 +209,7 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
list_builtins(); list_builtins();
exit(0); exit(0);
} else { } else {
fprintf(stderr, "Unknown option: %s\n", cmd); fprintf(stderr, _("unknown option: %s\n"), cmd);
usage(git_usage_string); usage(git_usage_string);
} }
@ -247,7 +247,7 @@ static int handle_alias(int *argcp, const char ***argv)
if (ret >= 0) /* normal exit */ if (ret >= 0) /* normal exit */
exit(ret); exit(ret);
die_errno("While expanding alias '%s': '%s'", die_errno("while expanding alias '%s': '%s'",
alias_command, alias_string + 1); alias_command, alias_string + 1);
} }
count = split_cmdline(alias_string, &new_argv); count = split_cmdline(alias_string, &new_argv);
@ -256,8 +256,8 @@ static int handle_alias(int *argcp, const char ***argv)
split_cmdline_strerror(count)); split_cmdline_strerror(count));
option_count = handle_options(&new_argv, &count, &envchanged); option_count = handle_options(&new_argv, &count, &envchanged);
if (envchanged) if (envchanged)
die("alias '%s' changes environment variables\n" die("alias '%s' changes environment variables.\n"
"You can use '!git' in the alias to do this.", "You can use '!git' in the alias to do this",
alias_command); alias_command);
memmove(new_argv - option_count, new_argv, memmove(new_argv - option_count, new_argv,
count * sizeof(char *)); count * sizeof(char *));
@ -684,8 +684,8 @@ int cmd_main(int argc, const char **argv)
if (errno != ENOENT) if (errno != ENOENT)
break; break;
if (was_alias) { if (was_alias) {
fprintf(stderr, "Expansion of alias '%s' failed; " fprintf(stderr, _("expansion of alias '%s' failed; "
"'%s' is not a git command\n", "'%s' is not a git command\n"),
cmd, argv[0]); cmd, argv[0]);
exit(1); exit(1);
} }
@ -696,7 +696,7 @@ int cmd_main(int argc, const char **argv)
break; break;
} }
fprintf(stderr, "Failed to run command '%s': %s\n", fprintf(stderr, _("failed to run command '%s': %s\n"),
cmd, strerror(errno)); cmd, strerror(errno));
return 1; return 1;

62
setup.c
View File

@ -119,7 +119,7 @@ char *prefix_path(const char *prefix, int len, const char *path)
{ {
char *r = prefix_path_gently(prefix, len, NULL, path); char *r = prefix_path_gently(prefix, len, NULL, path);
if (!r) if (!r)
die("'%s' is outside repository", path); die(_("'%s' is outside repository"), path);
return r; return r;
} }
@ -160,7 +160,7 @@ int check_filename(const char *prefix, const char *arg)
free(to_free); free(to_free);
return 0; /* file does not exist */ return 0; /* file does not exist */
} }
die_errno("failed to stat '%s'", arg); die_errno(_("failed to stat '%s'"), arg);
} }
static void NORETURN die_verify_filename(const char *prefix, static void NORETURN die_verify_filename(const char *prefix,
@ -230,7 +230,7 @@ void verify_filename(const char *prefix,
int diagnose_misspelt_rev) int diagnose_misspelt_rev)
{ {
if (*arg == '-') if (*arg == '-')
die("option '%s' must come before non-option arguments", arg); die(_("option '%s' must come before non-option arguments"), arg);
if (looks_like_pathspec(arg) || check_filename(prefix, arg)) if (looks_like_pathspec(arg) || check_filename(prefix, arg))
return; return;
die_verify_filename(prefix, arg, diagnose_misspelt_rev); die_verify_filename(prefix, arg, diagnose_misspelt_rev);
@ -385,14 +385,14 @@ void setup_work_tree(void)
return; return;
if (work_tree_config_is_bogus) if (work_tree_config_is_bogus)
die("unable to set up work tree using invalid config"); die(_("unable to set up work tree using invalid config"));
work_tree = get_git_work_tree(); work_tree = get_git_work_tree();
git_dir = get_git_dir(); git_dir = get_git_dir();
if (!is_absolute_path(git_dir)) if (!is_absolute_path(git_dir))
git_dir = real_path(get_git_dir()); git_dir = real_path(get_git_dir());
if (!work_tree || chdir(work_tree)) if (!work_tree || chdir(work_tree))
die("This operation must be run in a work tree"); die(_("this operation must be run in a work tree"));
/* /*
* Make sure subsequent git processes find correct worktree * Make sure subsequent git processes find correct worktree
@ -530,17 +530,17 @@ void read_gitfile_error_die(int error_code, const char *path, const char *dir)
/* non-fatal; follow return path */ /* non-fatal; follow return path */
break; break;
case READ_GITFILE_ERR_OPEN_FAILED: case READ_GITFILE_ERR_OPEN_FAILED:
die_errno("Error opening '%s'", path); die_errno(_("error opening '%s'"), path);
case READ_GITFILE_ERR_TOO_LARGE: case READ_GITFILE_ERR_TOO_LARGE:
die("Too large to be a .git file: '%s'", path); die(_("too large to be a .git file: '%s'"), path);
case READ_GITFILE_ERR_READ_FAILED: case READ_GITFILE_ERR_READ_FAILED:
die("Error reading %s", path); die(_("error reading %s"), path);
case READ_GITFILE_ERR_INVALID_FORMAT: case READ_GITFILE_ERR_INVALID_FORMAT:
die("Invalid gitfile format: %s", path); die(_("invalid gitfile format: %s"), path);
case READ_GITFILE_ERR_NO_PATH: case READ_GITFILE_ERR_NO_PATH:
die("No path in gitfile: %s", path); die(_("no path in gitfile: %s"), path);
case READ_GITFILE_ERR_NOT_A_REPO: case READ_GITFILE_ERR_NOT_A_REPO:
die("Not a git repository: %s", dir); die(_("not a git repository: %s"), dir);
default: default:
die("BUG: unknown error code"); die("BUG: unknown error code");
} }
@ -639,7 +639,7 @@ static const char *setup_explicit_git_dir(const char *gitdirenv,
int offset; int offset;
if (PATH_MAX - 40 < strlen(gitdirenv)) if (PATH_MAX - 40 < strlen(gitdirenv))
die("'$%s' too big", GIT_DIR_ENVIRONMENT); die(_("'$%s' too big"), GIT_DIR_ENVIRONMENT);
gitfile = (char*)read_gitfile(gitdirenv); gitfile = (char*)read_gitfile(gitdirenv);
if (gitfile) { if (gitfile) {
@ -653,7 +653,7 @@ static const char *setup_explicit_git_dir(const char *gitdirenv,
free(gitfile); free(gitfile);
return NULL; return NULL;
} }
die("Not a git repository: '%s'", gitdirenv); die(_("not a git repository: '%s'"), gitdirenv);
} }
if (check_repository_format_gently(gitdirenv, repo_fmt, nongit_ok)) { if (check_repository_format_gently(gitdirenv, repo_fmt, nongit_ok)) {
@ -682,12 +682,12 @@ static const char *setup_explicit_git_dir(const char *gitdirenv,
else { else {
char *core_worktree; char *core_worktree;
if (chdir(gitdirenv)) if (chdir(gitdirenv))
die_errno("Could not chdir to '%s'", gitdirenv); die_errno(_("cannot chdir to '%s'"), gitdirenv);
if (chdir(git_work_tree_cfg)) if (chdir(git_work_tree_cfg))
die_errno("Could not chdir to '%s'", git_work_tree_cfg); die_errno(_("cannot chdir to '%s'"), git_work_tree_cfg);
core_worktree = xgetcwd(); core_worktree = xgetcwd();
if (chdir(cwd->buf)) if (chdir(cwd->buf))
die_errno("Could not come back to cwd"); die_errno(_("cannot come back to cwd"));
set_git_work_tree(core_worktree); set_git_work_tree(core_worktree);
free(core_worktree); free(core_worktree);
} }
@ -715,7 +715,7 @@ static const char *setup_explicit_git_dir(const char *gitdirenv,
if (offset >= 0) { /* cwd inside worktree? */ if (offset >= 0) { /* cwd inside worktree? */
set_git_dir(real_path(gitdirenv)); set_git_dir(real_path(gitdirenv));
if (chdir(worktree)) if (chdir(worktree))
die_errno("Could not chdir to '%s'", worktree); die_errno(_("cannot chdir to '%s'"), worktree);
strbuf_addch(cwd, '/'); strbuf_addch(cwd, '/');
free(gitfile); free(gitfile);
return cwd->buf + offset; return cwd->buf + offset;
@ -743,7 +743,7 @@ static const char *setup_discovered_git_dir(const char *gitdir,
if (offset != cwd->len && !is_absolute_path(gitdir)) if (offset != cwd->len && !is_absolute_path(gitdir))
gitdir = to_free = real_pathdup(gitdir, 1); gitdir = to_free = real_pathdup(gitdir, 1);
if (chdir(cwd->buf)) if (chdir(cwd->buf))
die_errno("Could not come back to cwd"); die_errno(_("cannot come back to cwd"));
ret = setup_explicit_git_dir(gitdir, cwd, repo_fmt, nongit_ok); ret = setup_explicit_git_dir(gitdir, cwd, repo_fmt, nongit_ok);
free(to_free); free(to_free);
return ret; return ret;
@ -753,7 +753,7 @@ static const char *setup_discovered_git_dir(const char *gitdir,
if (is_bare_repository_cfg > 0) { if (is_bare_repository_cfg > 0) {
set_git_dir(offset == cwd->len ? gitdir : real_path(gitdir)); set_git_dir(offset == cwd->len ? gitdir : real_path(gitdir));
if (chdir(cwd->buf)) if (chdir(cwd->buf))
die_errno("Could not come back to cwd"); die_errno(_("cannot come back to cwd"));
return NULL; return NULL;
} }
@ -792,7 +792,7 @@ static const char *setup_bare_git_dir(struct strbuf *cwd, int offset,
gitdir = offset == cwd->len ? "." : xmemdupz(cwd->buf, offset); gitdir = offset == cwd->len ? "." : xmemdupz(cwd->buf, offset);
if (chdir(cwd->buf)) if (chdir(cwd->buf))
die_errno("Could not come back to cwd"); die_errno(_("cannot come back to cwd"));
return setup_explicit_git_dir(gitdir, cwd, repo_fmt, nongit_ok); return setup_explicit_git_dir(gitdir, cwd, repo_fmt, nongit_ok);
} }
@ -800,7 +800,7 @@ static const char *setup_bare_git_dir(struct strbuf *cwd, int offset,
inside_work_tree = 0; inside_work_tree = 0;
if (offset != cwd->len) { if (offset != cwd->len) {
if (chdir(cwd->buf)) if (chdir(cwd->buf))
die_errno("Cannot come back to cwd"); die_errno(_("cannot come back to cwd"));
root_len = offset_1st_component(cwd->buf); root_len = offset_1st_component(cwd->buf);
strbuf_setlen(cwd, offset > root_len ? offset : root_len); strbuf_setlen(cwd, offset > root_len ? offset : root_len);
set_git_dir(cwd->buf); set_git_dir(cwd->buf);
@ -813,9 +813,9 @@ static const char *setup_bare_git_dir(struct strbuf *cwd, int offset,
static const char *setup_nongit(const char *cwd, int *nongit_ok) static const char *setup_nongit(const char *cwd, int *nongit_ok)
{ {
if (!nongit_ok) if (!nongit_ok)
die(_("Not a git repository (or any of the parent directories): %s"), DEFAULT_GIT_DIR_ENVIRONMENT); die(_("not a git repository (or any of the parent directories): %s"), DEFAULT_GIT_DIR_ENVIRONMENT);
if (chdir(cwd)) if (chdir(cwd))
die_errno(_("Cannot come back to cwd")); die_errno(_("cannot come back to cwd"));
*nongit_ok = 1; *nongit_ok = 1;
return NULL; return NULL;
} }
@ -824,7 +824,7 @@ static dev_t get_device_or_die(const char *path, const char *prefix, int prefix_
{ {
struct stat buf; struct stat buf;
if (stat(path, &buf)) { if (stat(path, &buf)) {
die_errno("failed to stat '%*s%s%s'", die_errno(_("failed to stat '%*s%s%s'"),
prefix_len, prefix_len,
prefix ? prefix : "", prefix ? prefix : "",
prefix ? "/" : "", path); prefix ? "/" : "", path);
@ -1066,13 +1066,13 @@ const char *setup_git_directory_gently(int *nongit_ok)
break; break;
case GIT_DIR_DISCOVERED: case GIT_DIR_DISCOVERED:
if (dir.len < cwd.len && chdir(dir.buf)) if (dir.len < cwd.len && chdir(dir.buf))
die(_("Cannot change to '%s'"), dir.buf); die(_("cannot change to '%s'"), dir.buf);
prefix = setup_discovered_git_dir(gitdir.buf, &cwd, dir.len, prefix = setup_discovered_git_dir(gitdir.buf, &cwd, dir.len,
&repo_fmt, nongit_ok); &repo_fmt, nongit_ok);
break; break;
case GIT_DIR_BARE: case GIT_DIR_BARE:
if (dir.len < cwd.len && chdir(dir.buf)) if (dir.len < cwd.len && chdir(dir.buf))
die(_("Cannot change to '%s'"), dir.buf); die(_("cannot change to '%s'"), dir.buf);
prefix = setup_bare_git_dir(&cwd, dir.len, &repo_fmt, nongit_ok); prefix = setup_bare_git_dir(&cwd, dir.len, &repo_fmt, nongit_ok);
break; break;
case GIT_DIR_HIT_CEILING: case GIT_DIR_HIT_CEILING:
@ -1085,7 +1085,7 @@ const char *setup_git_directory_gently(int *nongit_ok)
strbuf_release(&dir); strbuf_release(&dir);
return NULL; return NULL;
} }
die(_("Not a git repository (or any parent up to mount point %s)\n" die(_("not a git repository (or any parent up to mount point %s)\n"
"Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set)."), "Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set)."),
dir.buf); dir.buf);
default: default:
@ -1169,7 +1169,7 @@ int git_config_perm(const char *var, const char *value)
/* A filemode value was given: 0xxx */ /* A filemode value was given: 0xxx */
if ((i & 0600) != 0600) if ((i & 0600) != 0600)
die(_("Problem with core.sharedRepository filemode value " die(_("problem with core.sharedRepository filemode value "
"(0%.3o).\nThe owner of files must always have " "(0%.3o).\nThe owner of files must always have "
"read and write permissions."), i); "read and write permissions."), i);
@ -1212,7 +1212,7 @@ void sanitize_stdfds(void)
while (fd != -1 && fd < 2) while (fd != -1 && fd < 2)
fd = dup(fd); fd = dup(fd);
if (fd == -1) if (fd == -1)
die_errno("open /dev/null or dup failed"); die_errno(_("open /dev/null or dup failed"));
if (fd > 2) if (fd > 2)
close(fd); close(fd);
} }
@ -1227,12 +1227,12 @@ int daemonize(void)
case 0: case 0:
break; break;
case -1: case -1:
die_errno("fork failed"); die_errno(_("fork failed"));
default: default:
exit(0); exit(0);
} }
if (setsid() == -1) if (setsid() == -1)
die_errno("setsid failed"); die_errno(_("setsid failed"));
close(0); close(0);
close(1); close(1);
close(2); close(2);

View File

@ -18,13 +18,13 @@ test_expect_success 'initial setup' '
test_expect_success 'bad setup: invalid .git file format' ' test_expect_success 'bad setup: invalid .git file format' '
echo "gitdir $REAL" >.git && echo "gitdir $REAL" >.git &&
test_must_fail git rev-parse 2>.err && test_must_fail git rev-parse 2>.err &&
grep "Invalid gitfile format" .err test_i18ngrep "invalid gitfile format" .err
' '
test_expect_success 'bad setup: invalid .git file path' ' test_expect_success 'bad setup: invalid .git file path' '
echo "gitdir: $REAL.not" >.git && echo "gitdir: $REAL.not" >.git &&
test_must_fail git rev-parse 2>.err && test_must_fail git rev-parse 2>.err &&
grep "Not a git repository" .err test_i18ngrep "not a git repository" .err
' '
test_expect_success 'final setup + check rev-parse --git-dir' ' test_expect_success 'final setup + check rev-parse --git-dir' '

View File

@ -307,7 +307,7 @@ test_expect_success_multi 'needs work tree' '' '
cd .git && cd .git &&
test_check_ignore "foo" 128 test_check_ignore "foo" 128
) && ) &&
stderr_contains "fatal: This operation must be run in a work tree" stderr_contains "fatal: this operation must be run in a work tree"
' '
############################################################################ ############################################################################

View File

@ -157,7 +157,7 @@ test_expect_success 'relative path not found' '
test_expect_success 'relative path outside worktree' ' test_expect_success 'relative path outside worktree' '
test_must_fail git rev-parse HEAD:../file.txt >output 2>error && test_must_fail git rev-parse HEAD:../file.txt >output 2>error &&
test -z "$(cat output)" && test -z "$(cat output)" &&
grep "outside repository" error test_i18ngrep "outside repository" error
' '
test_expect_success 'relative path when cwd is outside worktree' ' test_expect_success 'relative path when cwd is outside worktree' '