No-op C gettext wrappers
PATCH v4 19/73 gettextize: git-branch "(no branch)" message
In reply to Junio C HamanoGettextize the "(no branch)" message that's shown by "git branch" when you're in a detached HEAD.
--- builtin/branch.c | 2 +- t/t3203-branch-output.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
builtin/branch.c +1 -1
@@ -476,7 +476,7 @@ static void show_detached(struct ref_list *ref_list)if (head_commit &&is_descendant_of (head_commit, ref_list->with_commit)) {struct ref_item item; - item.name =xstrdup ("(no branch)" ); + item.name =xstrdup (_ ("(no branch)" )); item.len =strlen (item.name); item.kind =REF_LOCAL_BRANCH ; item.dest =NULL ;
t/t3203-branch-output.sh +1 -1
@@ -72,7 +72,7 @@ cat >expect <<'EOF' branch-two master EOF -test_expect_success 'git branch shows detached HEAD properly' ' +test_expect_success C_LOCALE_OUTPUT 'git branch shows detached HEAD properly' ' git checkout HEAD^0 && git branch >actual && test_cmp expect actual
Signature · 1 line
1.7.2.3
PATCH v4 20/73 gettextize: git-checkout basic messages
In reply to Junio C Hamano--- builtin/checkout.c | 68 ++++++++++++++++++++++++++-------------------------- 1 files changed, 34 insertions(+), 34 deletions(-)
builtin/checkout.c +34 -34
@@ -116,7 +116,7 @@ static int check_all_stages(struct cache_entry *ce, int pos) ce_stage(active_cache[pos+1]) != 2 || strcmp(active_cache[pos+2]->name, ce->name) || ce_stage(active_cache[pos+2]) != 3) -return error ("path '%s' does not have all three versions" , +return error (_ ("path '%s' does not have all three versions" ), ce->name);return 0 ; }
@@ -150,7 +150,7 @@ static int checkout_merged(int pos, struct checkout *state) ce_stage(active_cache[pos+1]) != 2 || strcmp(active_cache[pos+2]->name, path) || ce_stage(active_cache[pos+2]) != 3) -return error ("path '%s' does not have all 3 versions" , path); +return error (_ ("path '%s' does not have all 3 versions" ), path);read_mmblob (&ancestor, active_cache[pos]->sha1);read_mmblob (&ours, active_cache[pos+1 ]->sha1);
@@ -167,7 +167,7 @@ static int checkout_merged(int pos, struct checkout *state)free (theirs.ptr);if (status <0 || !result_buf.ptr) {free (result_buf.ptr); -return error ("path '%s': cannot merge" , path); +return error (_ ("path '%s': cannot merge" ), path); }/*
@@ -184,12 +184,12 @@ static int checkout_merged(int pos, struct checkout *state)*/ if (write_sha1_file (result_buf.ptr, result_buf.size, blob_type, sha1)) -die ("Unable to add merge result for '%s'" , path); +die (_ ("Unable to add merge result for '%s'" ), path); ce =make_cache_entry (create_ce_mode (active_cache[pos+1 ]->ce_mode), sha1, path,2 ,0 );if (!ce) -die ("make_cache_entry failed for path '%s'" , path); +die (_ ("make_cache_entry failed for path '%s'" ), path); status =checkout_entry (ce, state,NULL );return status; }
@@ -211,7 +211,7 @@ static int checkout_paths(struct tree *source_tree, const char **pathspec, newfd =hold_locked_index (lock_file,1 );if (read_cache_preload (pathspec) <0 ) -return error ("corrupt index file" ); +return error (_ ("corrupt index file" ));if (source_tree)read_tree_some (source_tree, pathspec);
@@ -239,14 +239,14 @@ static int checkout_paths(struct tree *source_tree, const char **pathspec,if (!ce_stage (ce))continue ;if (opts->force) { -warning ("path '%s' is unmerged" , ce->name); +warning (_ ("path '%s' is unmerged" ), ce->name); }else if (stage) { errs |=check_stage (stage, ce, pos); }else if (opts->merge) { errs |=check_all_stages (ce, pos); }else { errs =1 ; -error ("path '%s' is unmerged" , ce->name); +error (_ ("path '%s' is unmerged" ), ce->name); } pos =skip_same_name (ce, pos) -1 ; }
@@ -275,7 +275,7 @@ static int checkout_paths(struct tree *source_tree, const char **pathspec,if (write_cache (newfd, active_cache, active_nr) ||commit_locked_index (lock_file)) -die ("unable to write new index file" ); +die (_ ("unable to write new index file" ));resolve_ref ("HEAD" , rev,0 , &flag); head =lookup_commit_reference_gently (rev,1 );
@@ -292,7 +292,7 @@ static void show_local_changes(struct object *head, struct diff_options *opts) rev.diffopt.flags = opts->flags; rev.diffopt.output_format |=DIFF_FORMAT_NAME_STATUS ;if (diff_setup_done (&rev.diffopt) <0 ) -die ("diff_setup_done failed" ); +die (_ ("diff_setup_done failed" ));add_pending_object (&rev, head,NULL );run_diff_index (&rev,0 ); }
@@ -366,7 +366,7 @@ static int merge_working_tree(struct checkout_opts *opts,int newfd =hold_locked_index (lock_file,1 );if (read_cache_preload (NULL ) <0 ) -return error ("corrupt index file" ); +return error (_ ("corrupt index file" ));resolve_undo_clear ();if (opts->force) {
@@ -388,7 +388,7 @@ static int merge_working_tree(struct checkout_opts *opts,refresh_cache (REFRESH_QUIET );if (unmerged_cache ()) { -error ("you need to resolve your current index first" ); +error (_ ("you need to resolve your current index first" ));return 1 ; }
@@ -470,7 +470,7 @@ static int merge_working_tree(struct checkout_opts *opts,if (write_cache (newfd, active_cache, active_nr) ||commit_locked_index (lock_file)) -die ("unable to write new index file" ); +die (_ ("unable to write new index file" ));if (!opts->force && !opts->quiet)show_local_changes (&new->commit->object, &opts->diff_options);
@@ -519,7 +519,7 @@ static void update_refs_for_switch(struct checkout_opts *opts, temp = log_all_ref_updates; log_all_ref_updates =1 ;if (log_ref_setup (ref_name, log_file,sizeof (log_file))) { -fprintf (stderr,"Can not do reflog for '%s'\n" , +fprintf (stderr,_ ("Can not do reflog for '%s'\n" ), opts->new_orphan_branch); log_all_ref_updates = temp;return ;
@@ -545,14 +545,14 @@ static void update_refs_for_switch(struct checkout_opts *opts,create_symref ("HEAD" , new->path, msg.buf);if (!opts->quiet) {if (old->path && !strcmp (new->path, old->path)) -fprintf (stderr,"Already on '%s'\n" , +fprintf (stderr,_ ("Already on '%s'\n" ), new->name);else if (opts->new_branch)fprintf (stderr,"Switched to%s branch '%s'\n" , opts->branch_exists ?" and reset" :" a new" , new->name);else -fprintf (stderr,"Switched to branch '%s'\n" , +fprintf (stderr,_ ("Switched to branch '%s'\n" ), new->name); }if (old->path && old->name) {
@@ -597,7 +597,7 @@ static int switch_branches(struct checkout_opts *opts, struct branch_info *new) new->name ="HEAD" ; new->commit = old.commit;if (!new->commit) -die ("You are on a branch yet to be born" ); +die (_ ("You are on a branch yet to be born" ));parse_commit (new->commit); }
@@ -724,7 +724,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)/* we can assume from now on new_branch = !new_branch_force */ if (opts.new_branch && opts.new_branch_force) -die ("-B cannot be used with -b" ); +die (_ ("-B cannot be used with -b" ));/* copy -B over to -b, so that we can just check the latter */ if (opts.new_branch_force)
@@ -732,28 +732,28 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)if (patch_mode && (opts.track >0 || opts.new_branch || opts.new_branch_log || opts.merge || opts.force)) -die ("--patch is incompatible with all other options" ); +die (_ ("--patch is incompatible with all other options" ));/* --track without -b should DWIM */ if (0 < opts.track && !opts.new_branch) {const char *argv0 = argv[0 ];if (!argc || !strcmp (argv0,"--" )) -die ("--track needs a branch name" ); +die (_ ("--track needs a branch name" ));if (!prefixcmp (argv0,"refs/" )) argv0 +=5 ;if (!prefixcmp (argv0,"remotes/" )) argv0 +=8 ; argv0 =strchr (argv0,'/' );if (!argv0 || !argv0[1 ]) -die ("Missing branch name; try -b" ); +die (_ ("Missing branch name; try -b" )); opts.new_branch = argv0 +1 ; }if (opts.new_orphan_branch) {if (opts.new_branch) -die ("--orphan and -b|-B are mutually exclusive" ); +die (_ ("--orphan and -b|-B are mutually exclusive" ));if (opts.track >0 ) -die ("--orphan cannot be used with -t" ); +die (_ ("--orphan cannot be used with -t" )); opts.new_branch = opts.new_orphan_branch; }
@@ -763,7 +763,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix) }if (opts.force && opts.merge) -die ("git checkout: -f and -m are incompatible" ); +die (_ ("git checkout: -f and -m are incompatible" ));/* * case 1: git checkout <ref> -- [<paths>]
@@ -809,7 +809,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)if (get_sha1_mb (arg, rev)) {if (has_dash_dash)/* case (1) */ -die ("invalid reference: %s" , arg); +die (_ ("invalid reference: %s" ), arg); if (!patch_mode && dwim_new_local_branch && opts.track == BRANCH_TRACK_UNSPECIFIED &&
@@ -846,7 +846,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix) source_tree =parse_tree_indirect (rev);if (!source_tree)/* case (1): want a tree */ -die ("reference is not a tree: %s" , arg); +die (_ ("reference is not a tree: %s" ), arg);if (!has_dash_dash) {/* case (3 -> 1) */ /* * Do not complain the most common case
@@ -872,7 +872,7 @@ no_reference:const char **pathspec =get_pathspec (prefix, argv);if (!pathspec) -die ("invalid path specification" ); +die (_ ("invalid path specification" ));if (patch_mode)return interactive_checkout (new.name, pathspec, &opts);
@@ -880,14 +880,14 @@ no_reference:/* Checkout paths */ if (opts.new_branch) {if (argc ==1 ) { -die ("git checkout: updating paths is incompatible with switching branches.\nDid you intend to checkout '%s' which can not be resolved as commit?" , argv[0 ]); +die (_ ("git checkout: updating paths is incompatible with switching branches.\nDid you intend to checkout '%s' which can not be resolved as commit?" ), argv[0 ]); }else { -die ("git checkout: updating paths is incompatible with switching branches." ); +die (_ ("git checkout: updating paths is incompatible with switching branches." )); } }if (1 < !!opts.writeout_stage + !!opts.force + !!opts.merge) -die ("git checkout: --ours/--theirs, --force and --merge are incompatible when\nchecking out of the index." ); +die (_ ("git checkout: --ours/--theirs, --force and --merge are incompatible when\nchecking out of the index." ));return checkout_paths (source_tree, pathspec, &opts); }
@@ -898,22 +898,22 @@ no_reference:if (opts.new_branch) {struct strbuf buf =STRBUF_INIT ;if (strbuf_check_branch_ref (&buf, opts.new_branch)) -die ("git checkout: we do not like '%s' as a branch name." , +die (_ ("git checkout: we do not like '%s' as a branch name." ), opts.new_branch);if (!get_sha1 (buf.buf, rev)) { opts.branch_exists =1 ;if (!opts.new_branch_force) -die ("git checkout: branch %s already exists" , +die (_ ("git checkout: branch %s already exists" ), opts.new_branch); }strbuf_release (&buf); }if (new.name && !new.commit) { -die ("Cannot switch branch to a non-commit." ); +die (_ ("Cannot switch branch to a non-commit." )); }if (opts.writeout_stage) -die ("--ours/--theirs is incompatible with switching branches." ); +die (_ ("--ours/--theirs is incompatible with switching branches." ));return switch_branches (&opts, &new); }
Signature · 1 line
1.7.2.3
PATCH v4 21/73 gettextize: git-checkout: our/their version message
In reply to Junio C HamanoSplit up the "does not have our/their version" message to make it easier to translate.
--- builtin/checkout.c | 14 ++++++++------ 1 files changed, 8 insertions(+), 6 deletions(-)
builtin/checkout.c +8 -6
@@ -103,9 +103,10 @@ static int check_stage(int stage, struct cache_entry *ce, int pos)return 0 ; pos++; } -return error ("path '%s' does not have %s version" , - ce->name, - (stage ==2 ) ?"our" :"their" ); +if (stage ==2 ) +return error (_ ("path '%s' does not have our version" ), ce->name); +else +return error (_ ("path '%s' does not have their version" ), ce->name); }static int check_all_stages (struct cache_entry *ce,int pos)
@@ -130,9 +131,10 @@ static int checkout_stage(int stage, struct cache_entry *ce, int pos,return checkout_entry (active_cache[pos], state,NULL ); pos++; } -return error ("path '%s' does not have %s version" , - ce->name, - (stage ==2 ) ?"our" :"their" ); +if (stage ==2 ) +return error (_ ("path '%s' does not have our version" ), ce->name); +else +return error (_ ("path '%s' does not have their version" ), ce->name); }static int checkout_merged (int pos,struct checkout *state)
Signature · 1 line
1.7.2.3
PATCH v4 22/73 gettextize: git-checkout describe_detached_head messages
In reply to Junio C Hamano--- builtin/checkout.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
builtin/checkout.c +1 -1
@@ -613,7 +613,7 @@ static int switch_branches(struct checkout_opts *opts, struct branch_info *new)* to remind the user that it might be lost. */ if (!opts->quiet && !old.path && old.commit && new->commit != old.commit) -describe_detached_head ("Previous HEAD position was" , old.commit); +describe_detached_head (_ ("Previous HEAD position was" ), old.commit);update_refs_for_switch (opts, &old, new);
Signature · 1 line
1.7.2.3
PATCH v4 23/73 gettextize: git-checkout "HEAD is now at" message
In reply to Junio C HamanoGettextize the "HEAD is now at" messages. Several tests in t7201-co.sh explicitly checked for this message. Change them to skip under GETTEXT_POISON=YesPlease.
--- builtin/checkout.c | 2 +- t/t7201-co.sh | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-)
builtin/checkout.c +1 -1
@@ -571,7 +571,7 @@ static void update_refs_for_switch(struct checkout_opts *opts,if (!opts->quiet) {if (old->path && advice_detached_head)detach_advice (old->path, new->name); -describe_detached_head ("HEAD is now at" , new->commit); +describe_detached_head (_ ("HEAD is now at" ), new->commit); } }remove_branch_state ();
t/t7201-co.sh +5 -5
@@ -223,7 +223,7 @@ test_expect_success 'checkout --merge --conflict=diff3 <branch>' ' test_cmp two expect ' -test_expect_success 'checkout to detach HEAD (with advice declined)' ' +test_expect_success C_LOCALE_OUTPUT 'checkout to detach HEAD (with advice declined)' ' git config advice.detachedHead false && git checkout -f renamer && git clean -f &&
@@ -242,7 +242,7 @@ test_expect_success 'checkout to detach HEAD (with advice declined)' ' fi ' -test_expect_success 'checkout to detach HEAD' ' +test_expect_success C_LOCALE_OUTPUT 'checkout to detach HEAD' ' git config advice.detachedHead true && git checkout -f renamer && git clean -f && git checkout renamer^ 2>messages &&
@@ -260,7 +260,7 @@ test_expect_success 'checkout to detach HEAD' ' fi ' -test_expect_success 'checkout to detach HEAD with branchname^' ' +test_expect_success C_LOCALE_OUTPUT 'checkout to detach HEAD with branchname^' ' git checkout -f master && git clean -f && git checkout renamer^ &&
@@ -276,7 +276,7 @@ test_expect_success 'checkout to detach HEAD with branchname^' ' fi ' -test_expect_success 'checkout to detach HEAD with :/message' ' +test_expect_success C_LOCALE_OUTPUT 'checkout to detach HEAD with :/message' ' git checkout -f master && git clean -f && git checkout ":/Initial" &&
@@ -292,7 +292,7 @@ test_expect_success 'checkout to detach HEAD with :/message' ' fi ' -test_expect_success 'checkout to detach HEAD with HEAD^0' ' +test_expect_success C_LOCALE_OUTPUT 'checkout to detach HEAD with HEAD^0' ' git checkout -f master && git clean -f && git checkout HEAD^0 &&
Signature · 1 line
1.7.2.3
Re: [PATCH v4 23/73] gettextize: git-checkout "HEAD is now at" message
builtin/checkout.c static void update_refs_for_switch(struct checkout_opts *opts, · line 574
Quoted 8 lines · Ævar Arnfjörð Bjarmason
builtin/checkout.c +1
-1@@ -571,7 +571,7 @@ static void update_refs_for_switch(struct checkout_opts *opts,if (!opts->quiet) {if (old->path && advice_detached_head)detach_advice (old->path, new->name); -describe_detached_head ("HEAD is now at" , new->commit); +describe_detached_head (_ ("HEAD is now at" ), new->commit);
It might make sense to squash patches 22 and 23 with the following.
--- builtin/checkout.c | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-)
builtin/checkout.c +8 -1
@@ -305,7 +305,14 @@ static void describe_detached_head(const char *msg, struct commit *commit)struct pretty_print_context ctx = {0 };parse_commit (commit);pretty_print_commit (CMIT_FMT_ONELINE , commit, &sb, &ctx); -fprintf (stderr,"%s %s... %s\n" , msg, + +/* +* TRANSLATORS: The first '%s' is either "Previous HEAD position was" +* or "HEAD is now at". The second '%s' is an abbreviated hexadecimal +* commit id for HEAD and the third '%s' is the first line of its +* commit message. +*/ +fprintf (stderr,_ ("%s %s... %s\n" ), msg,find_unique_abbrev (commit->object.sha1,DEFAULT_ABBREV ), sb.buf);strbuf_release (&sb); }
Signature · 1 line
1.7.4.1
PATCH v4 24/73 gettextize: git-checkout "Switched to a .. branch" message
In reply to Junio C HamanoSplit up the "Switched to and reset branch" and "Switched to a new branch" messages to make them easier to translate.
--- builtin/checkout.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-)
builtin/checkout.c +4 -3
@@ -550,9 +550,10 @@ static void update_refs_for_switch(struct checkout_opts *opts,fprintf (stderr,_ ("Already on '%s'\n" ), new->name); else if (opts->new_branch) - fprintf(stderr, "Switched to%s branch '%s'\n", - opts->branch_exists ?" and reset" :" a new" , - new->name); + if (opts->branch_exists) + fprintf(stderr, _("Switched to and reset branch '%s'\n"), new->name); + else + fprintf(stderr, _("Switched to a new branch '%s'\n"), new->name); else fprintf(stderr, _("Switched to branch '%s'\n"), new->name);
Signature · 1 line
1.7.2.3
Re: [PATCH v4 24/73] gettextize: git-checkout "Switched to a .. branch" message
Quoted 4 lines · Ævar Arnfjörð Bjarmason
builtin/checkout.c +0
-0@@ -550,9 +550,10 @@ static void update_refs_for_switch(struct checkout_opts *opts, fprintf(stderr, _("Already on '%s'\n"),
builtin/checkout.c static void update_refs_for_switch(struct checkout_opts *opts, · line 557
Quoted 10 lines
builtin/checkout.c +4
-3new->name); else if (opts->new_branch) - fprintf(stderr, "Switched to%s branch '%s'\n", - opts->branch_exists ?" and reset" :" a new" , - new->name); + if (opts->branch_exists) + fprintf(stderr, _("Switched to and reset branch '%s'\n"), new->name); + else + fprintf(stderr, _("Switched to a new branch '%s'\n"), new->name); else
C grammar is on your side, but the following seems worthwhile for the sanity of readers and those who might modify the code in the future.
--- builtin/checkout.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-)
builtin/checkout.c +4 -3
@@ -553,17 +553,18 @@ static void update_refs_for_switch(struct checkout_opts *opts,if (new->path) {create_symref ("HEAD" , new->path, msg.buf);if (!opts->quiet) { -if (old->path && !strcmp (new->path, old->path)) +if (old->path && !strcmp (new->path, old->path)) {fprintf (stderr,_ ("Already on '%s'\n" ), new->name); -else if (opts->new_branch) + }else if (opts->new_branch) {if (opts->branch_exists)fprintf (stderr,_ ("Switched to and reset branch '%s'\n" ), new->name);else fprintf (stderr,_ ("Switched to a new branch '%s'\n" ), new->name); -else + }else {fprintf (stderr,_ ("Switched to branch '%s'\n" ), new->name); + } }if (old->path && old->name) {char log_file[PATH_MAX ], ref_file[PATH_MAX ];
Signature · 1 line
1.7.4.1
Re: [PATCH v4 24/73] gettextize: git-checkout "Switched to a .. branch" message
Quoted 3 lines · Jonathan Nieder
C grammar is on your side, but the following seems worthwhile for the sanity of readers and those who might modify the code in the future.
Good point. Thanks.
Re: [PATCH v4 24/73] gettextize: git-checkout "Switched to a .. branch" message
In reply to Jonathan NiederQuoted 3 lines · Jonathan Nieder
C grammar is on your side, but the following seems worthwhile for the sanity of readers and those who might modify the code in the future.
Agreed, and IIRC GCC and others will warn about nested if's without {}, even if they're unambiguous[1].
1. IIRC GCC will warn about them being "ambiguous", but they're not according to the standard. I think some GCC programmer confused "ambiguous" and "potentially misleading".
Re: [PATCH v4 24/73] gettextize: git-checkout "Switched to a .. branch" message
I've locally amended this, and inserted the distclean-pot, in the series, so no need to resend only for these two.
If you are re-rolling the series, please don't forget to include them, as I'd be wholesale replacing in that case.
Thanks.
Re: [PATCH v4 24/73] gettextize: git-checkout "Switched to a .. branch" message
Quoted 2 lines · Junio C Hamano
I've locally amended this, and inserted the distclean-pot, in the series, so no need to resend only for these two.
Tonight's quick status update, just to save everybody's time to avoid duplicated work:
- I queued Jonathan's reroll of Jeff's strbuf_vaddf() on jk/strbuf-vaddf topic (on top of the 'master');
- Jonathan's status_color_* work is queued on jn/status-translatable, which is forked from (i.e. builds on top of) jk/strbuf-vaddf;
- Jeff's GIT_TRACE_FROTZ work is on jk/trace-sifter, also building on top of jk/strbuf-vaddf; and
- Ævar's ab/i18n was rebased on jn/status-translatable.
I've merged all of the above to 'pu' and pushed the results out. It hopefully will mirror out shortly.
PATCH v4 25/73 gettextize: git-commit basic messages
In reply to Junio C Hamano--- builtin/commit.c | 118 +++++++++++++++++++++++++++--------------------------- 1 files changed, 59 insertions(+), 59 deletions(-)
builtin/commit.c +59 -59
@@ -243,7 +243,7 @@ static void add_remove_files(struct string_list *list)if (!lstat (p->string, &st)) {if (add_to_cache (p->string, &st,0 )) -die ("updating files failed" ); +die (_ ("updating files failed" )); }else remove_file_from_cache (p->string); }
@@ -270,7 +270,7 @@ static void create_base_index(void) opts.fn = oneway_merge; tree =parse_tree_indirect (head_sha1);if (!tree) -die ("failed to unpack HEAD tree object" ); +die (_ ("failed to unpack HEAD tree object" ));parse_tree (tree);init_tree_desc (&t, tree->buffer, tree->size);if (unpack_trees (1 , &t, &opts))
@@ -298,9 +298,9 @@ static char *prepare_index(int argc, const char **argv, const char *prefix, int refresh_flags |=REFRESH_UNMERGED ;if (interactive) {if (interactive_add (argc, argv, prefix) !=0 ) -die ("interactive add failed" ); +die (_ ("interactive add failed" ));if (read_cache_preload (NULL ) <0 ) -die ("index file corrupt" ); +die (_ ("index file corrupt" )); commit_style =COMMIT_AS_IS ;return get_index_file (); }
@@ -309,7 +309,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix, int pathspec =get_pathspec (prefix, argv);if (read_cache_preload (pathspec) <0 ) -die ("index file corrupt" ); +die (_ ("index file corrupt" ));/* * Non partial, non as-is commit.
@@ -329,7 +329,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix, intrefresh_cache_or_die (refresh_flags);if (write_cache (fd, active_cache, active_nr) ||close_lock_file (&index_lock)) -die ("unable to write new_index file" ); +die (_ ("unable to write new_index file" )); commit_style =COMMIT_NORMAL ;return index_lock.filename; }
@@ -349,7 +349,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix, intif (active_cache_changed) {if (write_cache (fd, active_cache, active_nr) ||commit_locked_index (&index_lock)) -die ("unable to write new_index file" ); +die (_ ("unable to write new_index file" )); }else {rollback_lock_file (&index_lock); }
@@ -379,7 +379,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix, int commit_style =COMMIT_PARTIAL ;if (in_merge) -die ("cannot do a partial commit during a merge." ); +die (_ ("cannot do a partial commit during a merge." ));memset (&partial,0 ,sizeof (partial)); partial.strdup_strings =1 ;
@@ -388,14 +388,14 @@ static char *prepare_index(int argc, const char **argv, const char *prefix, intdiscard_cache ();if (read_cache () <0 ) -die ("cannot read the index" ); +die (_ ("cannot read the index" )); fd =hold_locked_index (&index_lock,1 );add_remove_files (&partial);refresh_cache (REFRESH_QUIET );if (write_cache (fd, active_cache, active_nr) ||close_lock_file (&index_lock)) -die ("unable to write new_index file" ); +die (_ ("unable to write new_index file" )); fd = hold_lock_file_for_update(&false_lock, git_path("next-index-%"PRIuMAX,
@@ -408,7 +408,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix, intif (write_cache (fd, active_cache, active_nr) ||close_lock_file (&false_lock)) -die ("unable to write temporary index file" ); +die (_ ("unable to write temporary index file" ));discard_cache ();read_cache_from (false_lock.filename);
@@ -455,7 +455,7 @@ static int is_a_merge(const unsigned char *sha1) {struct commit *commit =lookup_commit (sha1);if (!commit ||parse_commit (commit)) -die ("could not parse HEAD commit" ); +die (_ ("could not parse HEAD commit" ));return !!(commit->parents && commit->parents->next); }
@@ -474,13 +474,13 @@ static void determine_author_info(struct strbuf *author_ident) a =strstr (use_message_buffer,"\nauthor " );if (!a) -die ("invalid commit: %s" , use_message); +die (_ ("invalid commit: %s" ), use_message); lb =strchrnul (a +strlen ("\nauthor " ),'<' ); rb =strchrnul (lb,'>' ); eol =strchrnul (rb,'\n' );if (!*lb || !*rb || !*eol) -die ("invalid commit: %s" , use_message); +die (_ ("invalid commit: %s" ), use_message);if (lb == a +strlen ("\nauthor " ))/* \nauthor <[email protected]> */
@@ -498,7 +498,7 @@ static void determine_author_info(struct strbuf *author_ident)const char *rb =strchr (force_author,'>' );if (!lb || !rb) -die ("malformed --author parameter" ); +die (_ ("malformed --author parameter" )); name =xstrndup (force_author, lb - force_author); email =xstrndup (lb +2 , rb - (lb +2 )); }
@@ -554,7 +554,7 @@ static char *cut_ident_timestamp_part(char *string) {char *ket =strrchr (string,'>' );if (!ket || ket[1 ] !=' ' ) -die ("Malformed ident string: '%s'" , string); +die (_ ("Malformed ident string: '%s'" ), string); *++ket ='\0' ;return ket; }
@@ -588,7 +588,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,struct commit *c; c =lookup_commit_reference_by_name (squash_message);if (!c) -die ("could not lookup commit %s" , squash_message); +die (_ ("could not lookup commit %s" ), squash_message); ctx.output_encoding =get_commit_output_encoding ();format_commit_message (c,"squash! %s\n\n" , &sb, &ctx);
@@ -600,19 +600,19 @@ static int prepare_to_commit(const char *index_file, const char *prefix, hook_arg1 ="message" ; }else if (logfile && !strcmp (logfile,"-" )) {if (isatty (0 )) -fprintf (stderr,"(reading log message from standard input)\n" ); +fprintf (stderr,_ ("(reading log message from standard input)\n" ));if (strbuf_read (&sb,0 ,0 ) <0 ) -die_errno ("could not read log from standard input" ); +die_errno (_ ("could not read log from standard input" )); hook_arg1 ="message" ; }else if (logfile) {if (strbuf_read_file (&sb, logfile,0 ) <0 ) -die_errno ("could not read log file '%s'" , +die_errno (_ ("could not read log file '%s'" ), logfile); hook_arg1 ="message" ; }else if (use_message) { buffer =strstr (use_message_buffer,"\n\n" );if (!buffer || buffer[2 ] =='\0' ) -die ("commit has empty message" ); +die (_ ("commit has empty message" ));strbuf_add (&sb, buffer +2 ,strlen (buffer +2 )); hook_arg1 ="commit" ; hook_arg2 = use_message;
@@ -621,22 +621,22 @@ static int prepare_to_commit(const char *index_file, const char *prefix,struct commit *commit; commit =lookup_commit_reference_by_name (fixup_message);if (!commit) -die ("could not lookup commit %s" , fixup_message); +die (_ ("could not lookup commit %s" ), fixup_message); ctx.output_encoding =get_commit_output_encoding ();format_commit_message (commit,"fixup! %s\n\n" , &sb, &ctx); hook_arg1 ="message" ; }else if (!stat (git_path ("MERGE_MSG" ), &statbuf)) {if (strbuf_read_file (&sb,git_path ("MERGE_MSG" ),0 ) <0 ) -die_errno ("could not read MERGE_MSG" ); +die_errno (_ ("could not read MERGE_MSG" )); hook_arg1 ="merge" ; }else if (!stat (git_path ("SQUASH_MSG" ), &statbuf)) {if (strbuf_read_file (&sb,git_path ("SQUASH_MSG" ),0 ) <0 ) -die_errno ("could not read SQUASH_MSG" ); +die_errno (_ ("could not read SQUASH_MSG" )); hook_arg1 ="squash" ; }else if (template_file && !stat (template_file, &statbuf)) {if (strbuf_read_file (&sb, template_file,0 ) <0 ) -die_errno ("could not read '%s'" , template_file); +die_errno (_ ("could not read '%s'" ), template_file); hook_arg1 ="template" ; }
@@ -659,7 +659,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix, fp =fopen (git_path (commit_editmsg),"w" );if (fp ==NULL ) -die_errno ("could not open '%s'" ,git_path (commit_editmsg)); +die_errno (_ ("could not open '%s'" ),git_path (commit_editmsg));if (cleanup_mode !=CLEANUP_NONE )stripspace (&sb,0 );
@@ -683,7 +683,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix, }if (fwrite (sb.buf,1 , sb.len, fp) < sb.len) -die_errno ("could not write commit template" ); +die_errno (_ ("could not write commit template" ));strbuf_release (&sb);
@@ -752,7 +752,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,const char *parent ="HEAD" ;if (!active_nr &&read_cache () <0 ) -die ("Cannot read index" ); +die (_ ("Cannot read index" ));if (amend) parent ="HEAD^1" ;
@@ -785,7 +785,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix, active_cache_tree =cache_tree ();if (cache_tree_update (active_cache_tree, active_cache, active_nr,0 ,0 ) <0 ) { -error ("Error building trees" ); +error (_ ("Error building trees" ));return 0 ; }
@@ -800,7 +800,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,snprintf (index,sizeof (index),"GIT_INDEX_FILE=%s" , index_file);if (launch_editor (git_path (commit_editmsg),NULL , env)) {fprintf (stderr, -"Please supply the message using either -m or -F option.\n" ); +_ ("Please supply the message using either -m or -F option.\n" ));exit (1 ); } }
@@ -880,7 +880,7 @@ static const char *find_author_by_nickname(const char *name)format_commit_message (commit,"%an <%ae>" , &buf, &ctx);return strbuf_detach (&buf,NULL ); } -die ("No existing author found with '%s'" , name); +die (_ ("No existing author found with '%s'" ), name); }
@@ -895,7 +895,7 @@ static void handle_untracked_files_arg(struct wt_status *s)else if (!strcmp (untracked_files_arg,"all" )) s->show_untracked_files =SHOW_ALL_UNTRACKED_FILES ;else -die ("Invalid untracked files mode '%s'" , untracked_files_arg); +die (_ ("Invalid untracked files mode '%s'" ), untracked_files_arg); } static int parse_and_validate_options(int argc, const char *argv[],
@@ -912,7 +912,7 @@ static int parse_and_validate_options(int argc, const char *argv[], force_author =find_author_by_nickname (force_author);if (force_author && renew_authorship) -die ("Using both --reset-author and --author does not make sense" ); +die (_ ("Using both --reset-author and --author does not make sense" ));if (logfile || message.len || use_message || fixup_message) use_editor =0 ;
@@ -926,7 +926,7 @@ static int parse_and_validate_options(int argc, const char *argv[],/* Sanity check options */ if (amend && initial_commit) -die ("You have nothing to amend." ); +die (_ ("You have nothing to amend." ));if (amend && in_merge)die ("You are in the middle of a merge -- cannot amend." );if (fixup_message && squash_message)
@@ -940,22 +940,22 @@ static int parse_and_validate_options(int argc, const char *argv[],if (logfile) f++;if (f >1 ) -die ("Only one of -c/-C/-F/--fixup can be used." ); +die (_ ("Only one of -c/-C/-F/--fixup can be used." ));if (message.len && f >0 ) -die ("Option -m cannot be combined with -c/-C/-F/--fixup." ); +die ((_ ("Option -m cannot be combined with -c/-C/-F/--fixup." )));if (edit_message) use_message = edit_message;if (amend && !use_message && !fixup_message) use_message ="HEAD" ;if (!use_message && renew_authorship) -die ("--reset-author can be used only with -C, -c or --amend." ); +die (_ ("--reset-author can be used only with -C, -c or --amend." ));if (use_message) {const char *out_enc;struct commit *commit; commit =lookup_commit_reference_by_name (use_message);if (!commit) -die ("could not lookup commit %s" , use_message); +die (_ ("could not lookup commit %s" ), use_message); out_enc =get_commit_output_encoding (); use_message_buffer =logmsg_reencode (commit, out_enc);
@@ -970,13 +970,13 @@ static int parse_and_validate_options(int argc, const char *argv[], }if (!!also + !!only + !!all + !!interactive >1 ) -die ("Only one of --include/--only/--all/--interactive can be used." ); +die (_ ("Only one of --include/--only/--all/--interactive can be used." ));if (argc ==0 && (also || (only && !amend))) -die ("No paths with --include/--only does not make sense." ); +die (_ ("No paths with --include/--only does not make sense." ));if (argc ==0 && only && amend) - only_include_assumed ="Clever... amending the last one with dirty index." ; + only_include_assumed =_ ("Clever... amending the last one with dirty index." );if (argc >0 && !also && !only) - only_include_assumed ="Explicit paths specified without -i nor -o; assuming --only paths..." ; + only_include_assumed =_ ("Explicit paths specified without -i nor -o; assuming --only paths..." );if (!cleanup_arg || !strcmp (cleanup_arg,"default" )) cleanup_mode = use_editor ?CLEANUP_ALL :CLEANUP_SPACE ;else if (!strcmp (cleanup_arg,"verbatim" ))
@@ -986,14 +986,14 @@ static int parse_and_validate_options(int argc, const char *argv[],else if (!strcmp (cleanup_arg,"strip" )) cleanup_mode =CLEANUP_ALL ;else -die ("Invalid cleanup mode %s" , cleanup_arg); +die (_ ("Invalid cleanup mode %s" ), cleanup_arg);handle_untracked_files_arg (s);if (all && argc >0 ) -die ("Paths with -a does not make sense." ); +die (_ ("Paths with -a does not make sense." ));else if (interactive && argc >0 ) -die ("Paths with --interactive does not make sense." ); +die (_ ("Paths with --interactive does not make sense." ));if (null_termination && status_format ==STATUS_FORMAT_LONG ) status_format =STATUS_FORMAT_PORCELAIN ;
@@ -1074,7 +1074,7 @@ static int git_status_config(const char *k, const char *v, void *cb)else if (!strcmp (v,"all" )) s->show_untracked_files =SHOW_ALL_UNTRACKED_FILES ;else -return error ("Invalid untracked files mode '%s'" , v); +return error (_ ("Invalid untracked files mode '%s'" ), v);return 0 ; }return git_diff_ui_config (k, v,NULL );
@@ -1180,9 +1180,9 @@ static void print_summary(const char *prefix, const unsigned char *sha1) commit =lookup_commit (sha1);if (!commit) -die ("couldn't look up newly created commit" ); +die (_ ("couldn't look up newly created commit" ));if (!commit ||parse_commit (commit)) -die ("could not parse newly created commit" ); +die (_ ("could not parse newly created commit" ));strbuf_addstr (&format,"format:%h] %s" );
@@ -1336,7 +1336,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix) reflog_msg ="commit (amend)" ; commit =lookup_commit (head_sha1);if (!commit ||parse_commit (commit)) -die ("could not parse HEAD commit" ); +die (_ ("could not parse HEAD commit" ));for (c = commit->parents; c; c = c->next) pptr = &commit_list_insert (c->item, pptr)->next;
@@ -1349,19 +1349,19 @@ int cmd_commit(int argc, const char **argv, const char *prefix) pptr = &commit_list_insert (lookup_commit (head_sha1), pptr)->next; fp =fopen (git_path ("MERGE_HEAD" ),"r" );if (fp ==NULL ) -die_errno ("could not open '%s' for reading" , +die_errno (_ ("could not open '%s' for reading" ),git_path ("MERGE_HEAD" ));while (strbuf_getline (&m, fp,'\n' ) !=EOF ) {unsigned char sha1[20 ];if (get_sha1_hex (m.buf, sha1) <0 ) -die ("Corrupt MERGE_HEAD file (%s)" , m.buf); +die (_ ("Corrupt MERGE_HEAD file (%s)" ), m.buf); pptr = &commit_list_insert (lookup_commit (sha1), pptr)->next; }fclose (fp);strbuf_release (&m);if (!stat (git_path ("MERGE_MODE" ), &statbuf)) {if (strbuf_read_file (&sb,git_path ("MERGE_MODE" ),0 ) <0 ) -die_errno ("could not read MERGE_MODE" ); +die_errno (_ ("could not read MERGE_MODE" ));if (!strcmp (sb.buf,"no-ff" )) allow_fast_forward =0 ; }
@@ -1378,7 +1378,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)if (strbuf_read_file (&sb,git_path (commit_editmsg),0 ) <0 ) {int saved_errno = errno;rollback_index_files (); -die ("could not read commit message: %s" ,strerror (saved_errno)); +die (_ ("could not read commit message: %s" ),strerror (saved_errno)); }/* Truncate the message just before the diff, if any. */
@@ -1392,14 +1392,14 @@ int cmd_commit(int argc, const char **argv, const char *prefix)stripspace (&sb, cleanup_mode ==CLEANUP_ALL );if (message_is_empty (&sb) && !allow_empty_message) {rollback_index_files (); -fprintf (stderr,"Aborting commit due to empty commit message.\n" ); +fprintf (stderr,_ ("Aborting commit due to empty commit message.\n" ));exit (1 ); }if (commit_tree (sb.buf, active_cache_tree->sha1, parents, commit_sha1, author_ident.buf)) {rollback_index_files (); -die ("failed to write commit object" ); +die (_ ("failed to write commit object" )); }strbuf_release (&author_ident);
@@ -1417,11 +1417,11 @@ int cmd_commit(int argc, const char **argv, const char *prefix)if (!ref_lock) {rollback_index_files (); -die ("cannot lock HEAD ref" ); +die (_ ("cannot lock HEAD ref" )); }if (write_ref_sha1 (ref_lock, commit_sha1, sb.buf) <0 ) {rollback_index_files (); -die ("cannot update HEAD ref" ); +die (_ ("cannot update HEAD ref" )); }unlink (git_path ("MERGE_HEAD" ));
@@ -1430,9 +1430,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" +die (_ ("Repository has been updated, but unable to write\n" "new_index file. Check that disk is not full or quota is\n" -"not exceeded, and then \"git reset HEAD\" to recover." ); +"not exceeded, and then \"git reset HEAD\" to recover." ));rerere (0 );run_hook (get_index_file (),"post-commit" ,NULL );
Signature · 1 line
1.7.2.3
PATCH v4 26/73 gettextize: git-commit "middle of a merge" message
In reply to Junio C HamanoGettextize the "You are in the middle of a merge -- cannot amend." message. Several tests in t7110-reset-merge.sh explicitly checked for this message. Change them to skip under GETTEXT_POISON=YesPlease.
--- builtin/commit.c | 4 ++-- t/t7110-reset-merge.sh | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-)
builtin/commit.c +2 -2
@@ -928,9 +928,9 @@ static int parse_and_validate_options(int argc, const char *argv[],if (amend && initial_commit)die (_ ("You have nothing to amend." ));if (amend && in_merge) -die ("You are in the middle of a merge -- cannot amend." ); +die (_ ("You are in the middle of a merge -- cannot amend." ));if (fixup_message && squash_message) -die ("Options --squash and --fixup cannot be used together" ); +die (_ ("Options --squash and --fixup cannot be used together" ));if (use_message) f++;if (edit_message)
t/t7110-reset-merge.sh +3 -3
@@ -233,7 +233,7 @@ test_expect_success '"reset --merge HEAD^" is ok with pending merge' ' # working index HEAD target working index HEAD # ---------------------------------------------------- # file1: X U B C --keep (disallowed) -test_expect_success '"reset --keep HEAD^" fails with pending merge' ' +test_expect_success C_LOCALE_OUTPUT '"reset --keep HEAD^" fails with pending merge' ' git reset --hard third && test_must_fail git merge branch1 && test_must_fail git reset --keep HEAD^ 2>err.log &&
@@ -259,7 +259,7 @@ test_expect_success '"reset --merge HEAD" is ok with pending merge' ' # working index HEAD target working index HEAD # ---------------------------------------------------- # file1: X U B B --keep (disallowed) -test_expect_success '"reset --keep HEAD" fails with pending merge' ' +test_expect_success C_LOCALE_OUTPUT '"reset --keep HEAD" fails with pending merge' ' git reset --hard third && test_must_fail git merge branch1 && test_must_fail git reset --keep HEAD 2>err.log &&
@@ -280,7 +280,7 @@ test_expect_success '--merge is ok with added/deleted merge' ' git diff --exit-code --cached ' -test_expect_success '--keep fails with added/deleted merge' ' +test_expect_success C_LOCALE_OUTPUT '--keep fails with added/deleted merge' ' git reset --hard third && rm -f file2 && test_must_fail git merge branch3 &&
Signature · 1 line
1.7.2.3
PATCH v4 27/73 gettextize: git-commit formatting messages
In reply to Junio C Hamano--- builtin/commit.c | 12 ++++++------ t/t7502-commit.sh | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-)
builtin/commit.c +6 -6
@@ -696,12 +696,12 @@ static int prepare_to_commit(const char *index_file, const char *prefix,char *ai_tmp, *ci_tmp;if (in_merge)fprintf (fp, -"#\n" +_ ("#\n" "# It looks like you may be committing a MERGE.\n" "# If this is not correct, please remove the file\n" "# %s\n" "# and try again.\n" -"#\n" , +"#\n" ),git_path ("MERGE_HEAD" )); fprintf(fp,
@@ -725,15 +725,15 @@ static int prepare_to_commit(const char *index_file, const char *prefix, ci_tmp =cut_ident_timestamp_part (committer_ident.buf);if (strcmp (author_ident->buf, committer_ident.buf))fprintf (fp, -"%s" -"# Author: %s\n" , +_ ("%s" +"# Author: %s\n" ), ident_shown++ ?"" :"#\n" , author_ident->buf);if (!user_ident_sufficiently_given ())fprintf (fp, -"%s" -"# Committer: %s\n" , +_ ("%s" +"# Committer: %s\n" ), ident_shown++ ?"" :"#\n" , committer_ident.buf);
t/t7502-commit.sh +2 -2
@@ -234,7 +234,7 @@ echo "# # Author: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> #" >> expect -test_expect_success 'author different from committer' ' +test_expect_success C_LOCALE_OUTPUT 'author different from committer' ' echo >>negative && git commit -e -m "sample"
@@ -248,7 +248,7 @@ rm -f expect.tmp echo "# Committer: #" >> expect -test_expect_success 'committer is automatic' ' +test_expect_success C_LOCALE_OUTPUT 'committer is automatic' ' echo >>negative && (
Signature · 1 line
1.7.2.3
PATCH 1/1 commit: error out for missing commit message template
When "git commit" was rewritten in C (v1.5.4-rc0~78^2~30, 2007-11-08), a subtle bug in --template was introduced. If the file named by a --template parameter is missing, previously git would error out with a message:
Commit template file does not exist.
but in the C version the --template parameter gets ignored and the default template is used.
t7500 has two tests for this case which would have caught it, except that with the default $EDITOR, the commit message template is left unmodified, causing 'git commit' to error out and the test to succeed.
---
Quoted 3 lines · Ævar Arnfjörð Bjarmason
builtin/commit.c +0
-0@@ -725,15 +725,15 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
[...]
builtin/commit.c
Quoted 4 lines
builtin/commit.c +2
-2-"%s" - "# Author: %s\n", +_ ("%s" + "# Author: %s\n"),
The above change causes the commit message template to be nonempty, excluding comments, so bare "git commit" succeeds, exposing this longstanding bug.
builtin/commit.c | 2 +- t/t7500-commit.sh | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-)
builtin/commit.c +1 -1
@@ -634,7 +634,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,if (strbuf_read_file (&sb,git_path ("SQUASH_MSG" ),0 ) <0 )die_errno ("could not read SQUASH_MSG" ); hook_arg1 ="squash" ; - }else if (template_file && !stat (template_file, &statbuf)) { + }else if (template_file) {if (strbuf_read_file (&sb, template_file,0 ) <0 )die_errno ("could not read '%s'" , template_file); hook_arg1 ="template" ;
t/t7500-commit.sh +11 -3
@@ -28,13 +28,21 @@ test_expect_success 'a basic commit in an empty tree should succeed' ' test_expect_success 'nonexistent template file should return error' ' echo changes >> foo && git add foo && - test_must_fail git commit --template "$PWD"/notexist + ( + GIT_EDITOR="echo hello >\"\$1\"" && + export GIT_EDITOR && + test_must_fail git commit --template "$PWD"/notexist + ) ' test_expect_success 'nonexistent template file in config should return error' ' git config commit.template "$PWD"/notexist && - test_must_fail git commit && - git config --unset commit.template + test_when_finished "git config --unset commit.template" && + ( + GIT_EDITOR="echo hello >\"\$1\"" && + export GIT_EDITOR && + test_must_fail git commit + ) ' # From now on we'll use a template file that exists.
Signature · 1 line
1.7.4.1
Re: [PATCH] commit: error out for missing commit message template
Quoted 4 lines · Jonathan Nieder
Quoted 3 lines
builtin/commit.c +0
-0@@ -725,15 +725,15 @@ static int prepare_to_commit(const char *index_file, const char *prefix,[...]
Quoted 8 lines
builtin/commit.c
Quoted 4 lines
builtin/commit.c +2
-2-"%s" - "# Author: %s\n", +_ ("%s" + "# Author: %s\n"),The above change causes the commit message template to be nonempty, excluding comments, so bare "git commit" succeeds, exposing this longstanding bug.
Thanks; using "#" at the beginning of poison message sometimes has its uses ;-)
Will queue.
Re: [PATCH v4 27/73] gettextize: git-commit formatting messages
In reply to Ævar Arnfjörð Bjarmasonbuiltin/commit.c static int prepare_to_commit(const char *index_file, const char *prefix, · line 699
Quoted 8 lines · Ævar Arnfjörð Bjarmason
builtin/commit.c +1
-1@@ -696,12 +696,12 @@ static int prepare_to_commit(const char *index_file, const char *prefix,char *ai_tmp, *ci_tmp;if (in_merge) fprintf(fp, - "#\n" + _("#\n"
[...]
(Everything up to and including patch 26 still looks good.)
Here's a weatherballoon patch to mark the tests affected by patch 27 as "expect failure", in case we want to go that route. Combined with "commit: error out for missing commit message template", it passes all tests.
-- 8< --
Subject: i18n: update expected test results for git-commit formatting messages
--- t/lib-commit-template.sh | 19 ++++++++ t/t3404-rebase-interactive.sh | 3 +- t/t4013-diff-various.sh | 82 +++++++++++++++++++++++------------- t/t7500-commit.sh | 19 ++++---- t/t7501-commit.sh | 9 ++-- t/t7505-prepare-commit-msg-hook.sh | 7 ++- t/t7507-commit-verbose.sh | 5 +- t/t7509-commit.sh | 3 +- 8 files changed, 97 insertions(+), 50 deletions(-) create mode 100644 t/lib-commit-template.sh
t/lib-commit-template.sh new file +19 -0
@@ -0,0 +1,19 @@ +#!/bin/sh + +# Messages such as +# +# # It looks like you may be committing a MERGE.\n" +# +# are now translatable, even though the "# " part probably ought not +# to be. Expect some tests to fail when GETTEXT_POISON is enabled. + +if test_have_prereq C_LOCALE_OUTPUT +then + test_log_messages_expect_success () { + test_expect_success "$@" + } +else + test_log_messages_expect_success () { + test_expect_failure "$@" + } +fi
t/t3404-rebase-interactive.sh +2 -1
@@ -28,6 +28,7 @@ Initial setup: . ./test-lib.sh . "$TEST_DIRECTORY"/lib-rebase.sh +. "$TEST_DIRECTORY"/lib-commit-template.sh test_cmp_rev () { git rev-parse --verify "$1" >expect.rev &&
@@ -390,7 +391,7 @@ D ONCE EOF -test_expect_success 'squash and fixup generate correct log messages' ' +test_log_messages_expect_success 'squash and fixup generate correct log messages' ' git checkout -b squash-fixup E && base=$(git rev-parse HEAD~4) && FAKE_COMMIT_AMEND="ONCE" FAKE_LINES="1 fixup 2 squash 3 fixup 4" \
t/t4013-diff-various.sh +52 -30
132 lines not on this page · raw message
t/t7500-commit.sh +10 -9
@@ -8,6 +8,7 @@ test_description='git commit Tests for selected commit options.' . ./test-lib.sh +. "$TEST_DIRECTORY/lib-commit-template.sh" commit_msg_is () { expect=commit_msg_is.expect
@@ -48,7 +49,7 @@ test_expect_success 'nonexistent template file in config should return error' ' # From now on we'll use a template file that exists. TEMPLATE="$PWD"/template -test_expect_success 'unedited template should not commit' ' +test_log_messages_expect_success 'unedited template should not commit' ' echo "template line" > "$TEMPLATE" && test_must_fail git commit --template "$TEMPLATE" '
@@ -72,7 +73,7 @@ test_expect_success 'adding comments to a template should not commit' ' ) ' -test_expect_success 'adding real content to a template should commit' ' +test_log_messages_expect_success 'adding real content to a template should commit' ' ( test_set_editor "$TEST_DIRECTORY"/t7500/add-content && git commit --template "$TEMPLATE"
@@ -80,7 +81,7 @@ test_expect_success 'adding real content to a template should commit' ' commit_msg_is "template linecommit message" ' -test_expect_success '-t option should be short for --template' ' +test_log_messages_expect_success '-t option should be short for --template' ' echo "short template" > "$TEMPLATE" && echo "new content" >> foo && git add foo &&
@@ -91,7 +92,7 @@ test_expect_success '-t option should be short for --template' ' commit_msg_is "short templatecommit message" ' -test_expect_success 'config-specified template should commit' ' +test_log_messages_expect_success 'config-specified template should commit' ' echo "new template" > "$TEMPLATE" && git config commit.template "$TEMPLATE" && echo "more content" >> foo &&
@@ -206,7 +207,7 @@ test_expect_success 'commit -F overrides -t' ' commit_msg_is "-F log" ' -test_expect_success 'Commit without message is allowed with --allow-empty-message' ' +test_log_messages_expect_success 'Commit without message is allowed with --allow-empty-message' ' echo "more content" >>foo && git add foo && >empty &&
@@ -214,7 +215,7 @@ test_expect_success 'Commit without message is allowed with --allow-empty-messag commit_msg_is "" ' -test_expect_success 'Commit without message is no-no without --allow-empty-message' ' +test_log_messages_expect_success 'Commit without message is no-no without --allow-empty-message' ' echo "more content" >>foo && git add foo && >empty &&
@@ -270,7 +271,7 @@ test_expect_success 'commit --squash works with -C' ' commit_msg_is "squash! target message subject lineintermediate commit" ' -test_expect_success 'commit --squash works with -c' ' +test_log_messages_expect_success 'commit --squash works with -c' ' commit_for_rebase_autosquash_setup && test_set_editor "$TEST_DIRECTORY"/t7500/edit-content && git commit --squash HEAD~1 -c HEAD &&
@@ -283,14 +284,14 @@ test_expect_success 'commit --squash works with -C for same commit' ' commit_msg_is "squash! intermediate commit" ' -test_expect_success 'commit --squash works with -c for same commit' ' +test_log_messages_expect_success 'commit --squash works with -c for same commit' ' commit_for_rebase_autosquash_setup && test_set_editor "$TEST_DIRECTORY"/t7500/edit-content && git commit --squash HEAD -c HEAD && commit_msg_is "squash! edited commit" ' -test_expect_success 'commit --squash works with editor' ' +test_log_messages_expect_success 'commit --squash works with editor' ' commit_for_rebase_autosquash_setup && test_set_editor "$TEST_DIRECTORY"/t7500/add-content && git commit --squash HEAD~1 &&
t/t7501-commit.sh +5 -4
@@ -8,6 +8,7 @@ test_description='git commit' . ./test-lib.sh +. "$TEST_DIRECTORY"/lib-commit-template.sh test_tick
@@ -163,7 +164,7 @@ d381ac431806e53f3dd7ac2f1ae0534f36d738b9 402702b49136e7587daa9280e91e4bb7cb2179f7 EOF -test_expect_success \ +test_log_messages_expect_success \ 'validate git rev-list output.' \ 'test_cmp expected current'
@@ -200,7 +201,7 @@ test_expect_success 'partial commit that involves removal (3)' ' ' author="The Real Author <[email protected]>" -test_expect_success 'amend commit to fix author' ' +test_log_messages_expect_success 'amend commit to fix author' ' oldtick=$GIT_AUTHOR_DATE && test_tick &&
@@ -215,7 +216,7 @@ test_expect_success 'amend commit to fix author' ' ' -test_expect_success 'amend commit to fix date' ' +test_log_messages_expect_success 'amend commit to fix date' ' test_tick && newtick=$GIT_AUTHOR_DATE &&
@@ -329,7 +330,7 @@ test_expect_success 'multiple -m' ' ' author="The Real Author <[email protected]>" -test_expect_success 'amend commit to fix author' ' +test_log_messages_expect_success 'amend commit to fix author' ' oldtick=$GIT_AUTHOR_DATE && test_tick &&
t/t7505-prepare-commit-msg-hook.sh +4 -3
@@ -3,6 +3,7 @@ test_description='prepare-commit-msg hook' . ./test-lib.sh +. "$TEST_DIRECTORY"/lib-commit-template.sh test_expect_success 'with no hook' '
@@ -103,7 +104,7 @@ test_expect_success 'with hook (-C)' ' ' -test_expect_success 'with hook (editor)' ' +test_log_messages_expect_success 'with hook (editor)' ' echo "more more" >> file && git add file &&
@@ -112,7 +113,7 @@ test_expect_success 'with hook (editor)' ' ' -test_expect_success 'with hook (--amend)' ' +test_log_messages_expect_success 'with hook (--amend)' ' head=`git rev-parse HEAD` && echo "more" >> file &&
@@ -122,7 +123,7 @@ test_expect_success 'with hook (--amend)' ' ' -test_expect_success 'with hook (-c)' ' +test_log_messages_expect_success 'with hook (-c)' ' head=`git rev-parse HEAD` && echo "more" >> file &&
t/t7507-commit-verbose.sh +3 -2
@@ -2,6 +2,7 @@ test_description='verbose commit template' . ./test-lib.sh +. "$TEST_DIRECTORY"/lib-commit-template.sh cat >check-for-diff <<EOF #!$SHELL_PATH
@@ -37,12 +38,12 @@ check_message() { test_cmp "$1" actual } -test_expect_success 'verbose diff is stripped out' ' +test_log_messages_expect_success 'verbose diff is stripped out' ' git commit --amend -v && check_message message ' -test_expect_success 'verbose diff is stripped out (mnemonicprefix)' ' +test_log_messages_expect_success 'verbose diff is stripped out (mnemonicprefix)' ' git config diff.mnemonicprefix true && git commit --amend -v && check_message message
t/t7509-commit.sh +2 -1
@@ -6,6 +6,7 @@ test_description='git commit --reset-author' . ./test-lib.sh +. "$TEST_DIRECTORY"/lib-commit-template.sh author_header () { git cat-file commit "$1" |
@@ -57,7 +58,7 @@ test_expect_success '-c option copies authorship and message' ' test_cmp expect actual ' -test_expect_success '-c option copies only the message with --reset-author' ' +test_log_messages_expect_success '-c option copies only the message with --reset-author' ' echo "Test 4" >>foo && test_tick && EDITOR=: VISUAL=: git commit -a -c Initial --reset-author &&
Signature · 1 line
1.7.4.1
Re: [PATCH v4 27/73] gettextize: git-commit formatting messages
Quoted 6 lines · Jonathan Nieder
t/lib-commit-template.sh new file +0
-0
t/lib-commit-template.sh line 8
Quoted 8 lines
t/lib-commit-template.sh new file +8
-0@@ -0,0 +1,19 @@ +#!/bin/sh + +# Messages such as +# +# # It looks like you may be committing a MERGE.\n" +# +# are now translatable, even though the "# " part probably ought not +# to be. Expect some tests to fail when GETTEXT_POISON is enabled.
We shouldn't mark "# " part as translatable to begin with. Perhaps the underlying code in wt-status.c needs to be changed even before we merge the i18n _() patches to make it easier?
It might be a good idea to introduce status_print{,_ln,_more} wrapper functions around color_vfprintf(), and change the existing callers to look like this:
const char *c = color(WT_STATUS_HEADER, s);
- color_fprintf_ln(s->fp, c, "# Unmerged paths:");
+ status_printf_ln(s, c, "Unmerged paths:");
if (!advice_status_hints)
return;
if (s->in_merge)
;
...
- color_fprintf(s->fp, color(WT_STATUS_HEADER, s), "#\t");
+ status_printf(s, color(WT_STATUS_HEADER, s), "\t");
switch (status) {
case DIFF_STATUS_ADDED:
- color_fprintf(s->fp, c, "new file: %s", one);
+ status_printf_more(s, c, "new file: %s", one);
break;Possible semantics for the three wrappers are:
* status_printf_ln() takes all the parameters necessary to produce a single line; it works just like color_fprintf_ln() but adds the "# " prefix itself.
* status_printf_more() is just a synonym for color_fprintf_ln() in the above but is not necessary.
* status_printf() would be like color_printf() but adds the "# " prefix itself.
I am Ok with naming "status-printf-more" to just "status-printf" and renaming "status-printf" to "status-printf-bol", as long as we have two functions, one that adds "# " and the other that does not.
The adding of "# " done by status_printf() and status_printf_ln() can and probably should have a bit of twist to adjust to the _real_ contents that are fed to them.
Ideally, status_printf_ln(s, color, "") should omit the trailing SP and give "<COLOR>#</COLOR>\n", and status_printf(s, color, "\t") should should give "<COLOR>#\t</COLOR>" to avoid SP-HT.
Doing this would have two advantages over the current code:
- The obvious one is to force separation of the "#" from the translatable part of the message, which is the topic of this thread.
- Another advantage is that this makes it easier for us to drop "#" prefix in "git status" output in later versions of git if we wanted to.
In "git commit" template, these lines need to be made into comments, but there is no reason, other than that we are sooooo used to seeing these lines prefixed with "# ", in "git status" output.
Re: [PATCH v4 27/73] gettextize: git-commit formatting messages
Quoted 2 lines · Junio C Hamano
It might be a good idea to introduce status_print{,_ln,_more} wrapper functions around
color_vfprintf()
My main obstacle to sending this was lack of good names for the relevant functions. :)
Quoted 6 lines
- Another advantage is that this makes it easier for us to drop "#" prefix in "git status" output in later versions of git if we wanted to.
In "git commit" template, these lines need to be made into comments, but there is no reason, other than that we are sooooo used to seeing these lines prefixed with "# ", in "git status" output.
Good point. Expect patches soon (for the status_print*, not "#" removal from output).
Re: [PATCH v4 27/73] gettextize: git-commit formatting messages
In reply to Junio C HamanoQuoted 12 lines · Junio C Hamano
Quoted 10 lines · Jonathan Nieder
t/lib-commit-template.sh new file +4
-0@@ -0,0 +1,19 @@ +#!/bin/sh + +# Messages such as +#
Quoted 8 lines
t/lib-commit-template.sh line 8
Quoted 4 lines
t/lib-commit-template.sh new file +4
-0+# # It looks like you may be committing a MERGE.\n" +# +# are now translatable, even though the "# " part probably ought not +# to be. Expect some tests to fail when GETTEXT_POISON is enabled.We shouldn't mark "# " part as translatable to begin with. Perhaps the underlying code in
wt-status.cneeds to be changed even before we merge the i18n_()patches to make it easier?
Agreed, and Jonathan already implemented this:
https://github.com/avar/git/commit/394a9d1 https://github.com/avar/git/commit/da15d84
Perhaps it would be better to modify that patch so it goes in ahead of the i18n series. It would simplify this going back and forth within i18n itself.
PATCH v4 28/73 gettextize: git-commit print_summary messages
In reply to Junio C HamanoGettextize the "(root-commit)" and "detached HEAD" fragments that appear when you commit either the root commit, or a commit in a detached head translatable.
--- builtin/commit.c | 4 ++-- t/t7502-commit.sh | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-)
builtin/commit.c +2 -2
@@ -1223,9 +1223,9 @@ static void print_summary(const char *prefix, const unsigned char *sha1) !prefixcmp (head,"refs/heads/" ) ? head +11 : !strcmp (head,"HEAD" ) ? -"detached HEAD" : +_ ("detached HEAD" ) : head, - initial_commit ? " (root-commit)" : ""); + initial_commit ? _(" (root-commit)") : "");if (!log_tree_commit (&rev, commit)) { rev.always_show_header =1 ;
t/t7502-commit.sh +8 -2
@@ -22,7 +22,10 @@ check_summary_oneline() { SUMMARY_POSTFIX="$(git log -1 --pretty='format:%h')" echo "[$SUMMARY_PREFIX $SUMMARY_POSTFIX] $2" >exp && - test_cmp exp act + if test_have_prereq C_LOCALE_OUTPUT + then + test_cmp exp act + fi } test_expect_success 'output summary format' '
@@ -32,7 +35,10 @@ test_expect_success 'output summary format' ' check_summary_oneline "root-commit" "initial" && echo change >>file1 && - git add file1 && + git add file1 +' + +test_expect_success 'output summary format: root-commit' ' check_summary_oneline "" "a change" '
Signature · 1 line
1.7.2.3
PATCH v4 29/73 gettextize: git-commit "enter the commit message" message
In reply to Junio C HamanoGettextize the "# Please enter the commit message for your changes." message. Several tests in t7500-commit.sh and t7502-commit.sh assume that this message starts with a newline. Change the tests to to skip under GETTEXT_POISON=YesPlease.
These fail under GETTEXT_POISON=YesPlease because the poison editor message doesn't do the right thing with comments and line breaks, so these messages will be incorrectly broken up across lines.
This test should not be skipped under a hypothetical future testing mode that tests Git under language locales, since those messages should all start with a newline like the original.
--- builtin/commit.c | 12 ++++++------ t/t7500-commit.sh | 8 ++++---- t/t7502-commit.sh | 26 +++++++++++++++++--------- 3 files changed, 27 insertions(+), 19 deletions(-)
builtin/commit.c +6 -6
@@ -705,19 +705,19 @@ static int prepare_to_commit(const char *index_file, const char *prefix, git_path("MERGE_HEAD"));fprintf (fp, -"\n" -"# Please enter the commit message for your changes." ); +_ ("\n" +"# Please enter the commit message for your changes." ));if (cleanup_mode ==CLEANUP_ALL )fprintf (fp, -" Lines starting\n" +_ (" Lines starting\n" "# with '#' will be ignored, and an empty" -" message aborts the commit.\n" ); +" message aborts the commit.\n" ));else /* CLEANUP_SPACE, that is. */ fprintf (fp, -" Lines starting\n" +_ (" Lines starting\n" "# with '#' will be kept; you may remove them" " yourself if you want to.\n" -"# An empty message aborts the commit.\n" ); +"# An empty message aborts the commit.\n" ));if (only_include_assumed)fprintf (fp,"# %s\n" , only_include_assumed);
t/t7500-commit.sh +4 -4
@@ -59,7 +59,7 @@ test_expect_success 'adding comments to a template should not commit' ' ) ' -test_expect_success 'adding real content to a template should commit' ' +test_expect_success C_LOCALE_OUTPUT 'adding real content to a template should commit' ' ( test_set_editor "$TEST_DIRECTORY"/t7500/add-content && git commit --template "$TEMPLATE"
@@ -67,7 +67,7 @@ test_expect_success 'adding real content to a template should commit' ' commit_msg_is "template linecommit message" ' -test_expect_success '-t option should be short for --template' ' +test_expect_success C_LOCALE_OUTPUT '-t option should be short for --template' ' echo "short template" > "$TEMPLATE" && echo "new content" >> foo && git add foo &&
@@ -78,7 +78,7 @@ test_expect_success '-t option should be short for --template' ' commit_msg_is "short templatecommit message" ' -test_expect_success 'config-specified template should commit' ' +test_expect_success C_LOCALE_OUTPUT 'config-specified template should commit' ' echo "new template" > "$TEMPLATE" && git config commit.template "$TEMPLATE" && echo "more content" >> foo &&
@@ -277,7 +277,7 @@ test_expect_success 'commit --squash works with -c for same commit' ' commit_msg_is "squash! edited commit" ' -test_expect_success 'commit --squash works with editor' ' +test_expect_success C_LOCALE_OUTPUT 'commit --squash works with editor' ' commit_for_rebase_autosquash_setup && test_set_editor "$TEST_DIRECTORY"/t7500/add-content && git commit --squash HEAD~1 &&
t/t7502-commit.sh +17 -9
@@ -221,19 +221,21 @@ test_expect_success 'cleanup commit messages (strip,-F)' ' ' -echo "sample - -# Please enter the commit message for your changes. Lines starting -# with '#' will be ignored, and an empty message aborts the commit." >expect - test_expect_success 'cleanup commit messages (strip,-F,-e)' ' echo >>negative && { echo;echo sample;echo; } >text && git commit -e -F text -a && - head -n 4 .git/COMMIT_EDITMSG >actual && - test_cmp expect actual + head -n 4 .git/COMMIT_EDITMSG >actual +' + +echo "sample +# Please enter the commit message for your changes. Lines starting +# with '#' will be ignored, and an empty message aborts the commit." >expect + +test_expect_success C_LOCALE_OUTPUT 'cleanup commit messages (strip,-F,-e): output' ' + test_cmp expect actual ' echo "#
@@ -244,7 +246,10 @@ test_expect_success C_LOCALE_OUTPUT 'author different from committer' ' echo >>negative && git commit -e -m "sample" - head -n 7 .git/COMMIT_EDITMSG >actual && + head -n 7 .git/COMMIT_EDITMSG >actual +' + +test_expect_success C_LOCALE_OUTPUT 'author different from committer: output' ' test_cmp expect actual '
@@ -264,7 +269,10 @@ test_expect_success C_LOCALE_OUTPUT 'committer is automatic' ' test_must_fail git commit -e -m "sample" ) && head -n 8 .git/COMMIT_EDITMSG | \ - sed "s/^# Committer: .*/# Committer:/" >actual && + sed "s/^# Committer: .*/# Committer:/" >actual +' + +test_expect_success C_LOCALE_OUTPUT 'committer is automatic: output' ' test_cmp expect actual '
Signature · 1 line
1.7.2.3
PATCH v4 30/73 gettextize: git-commit advice messages
In reply to Junio C Hamano--- builtin/commit.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-)
builtin/commit.c +6 -6
@@ -38,7 +38,7 @@ static const char * const builtin_status_usage[] = { };static const char implicit_ident_advice[] = -"Your name and email address were configured automatically based\n" +N_ ("Your name and email address were configured automatically based\n" "on your username and hostname. Please check that they are accurate.\n" "You can suppress this message by setting them explicitly:\n" "\n"
@@ -47,12 +47,12 @@ static const char implicit_ident_advice[] ="\n" "After doing this, you may fix the identity used for this commit with:\n" "\n" -" git commit --amend --reset-author\n" ; +" git commit --amend --reset-author\n");static const char empty_amend_advice[] = -"You asked to amend the most recent commit, but doing so would make\n" +N_ ("You asked to amend the most recent commit, but doing so would make\n" "it empty. You can repeat your command with --allow-empty, or you can\n" -"remove the commit entirely with \"git reset HEAD^\".\n" ; +"remove the commit entirely with \"git reset HEAD^\".\n" );static unsigned char head_sha1[20 ];
@@ -770,7 +770,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix, !(amend && is_a_merge(head_sha1))) {run_status (stdout, index_file, prefix,0 , s);if (amend) -fputs (empty_amend_advice, stderr); +fputs (_ (empty_amend_advice), stderr);return 0 ; }
@@ -1197,7 +1197,7 @@ static void print_summary(const char *prefix, const unsigned char *sha1)strbuf_addbuf_percentquote (&format, &committer_ident);if (advice_implicit_identity) {strbuf_addch (&format,'\n' ); -strbuf_addstr (&format, implicit_ident_advice); +strbuf_addstr (&format,_ (implicit_ident_advice)); } }strbuf_release (&author_ident);
Signature · 1 line
1.7.2.3
PATCH v4 31/73 gettextize: git-diff basic messages
In reply to Junio C Hamano--- builtin/diff.c | 18 +++++++++--------- 1 files changed, 9 insertions(+), 9 deletions(-)
builtin/diff.c +9 -9
@@ -71,9 +71,9 @@ static int builtin_diff_b_f(struct rev_info *revs,usage (builtin_diff_usage);if (lstat (path, &st)) -die_errno ("failed to stat '%s'" , path); +die_errno (_ ("failed to stat '%s'" ), path);if (!(S_ISREG (st.st_mode) ||S_ISLNK (st.st_mode))) -die ("'%s': not a regular file or symlink" , path); +die (_ ("'%s': not a regular file or symlink" ), path);diff_set_mnemonic_prefix (&revs->diffopt,"o/" ,"w/" );
@@ -222,7 +222,7 @@ static int builtin_diff_files(struct rev_info *revs, int argc, const char **argvelse if (!strcmp (argv[1 ],"-h" ))usage (builtin_diff_usage);else -return error ("invalid option: %s" , argv[1 ]); +return error (_ ("invalid option: %s" ), argv[1 ]); argv++; argc--; }
@@ -299,12 +299,12 @@ int cmd_diff(int argc, const char **argv, const char *prefix)DIFF_OPT_SET (&rev.diffopt,ALLOW_TEXTCONV );if (nongit) -die ("Not a git repository" ); +die (_ ("Not a git repository" )); argc =setup_revisions (argc, argv, &rev,NULL );if (!rev.diffopt.output_format) { rev.diffopt.output_format =DIFF_FORMAT_PATCH ;if (diff_setup_done (&rev.diffopt) <0 ) -die ("diff_setup_done failed" ); +die (_ ("diff_setup_done failed" )); }DIFF_OPT_SET (&rev.diffopt,RECURSIVE );
@@ -349,12 +349,12 @@ int cmd_diff(int argc, const char **argv, const char *prefix) obj =parse_object (obj->sha1); obj =deref_tag (obj,NULL ,0 );if (!obj) -die ("invalid object '%s' given." , name); +die (_ ("invalid object '%s' given." ), name);if (obj->type ==OBJ_COMMIT ) obj = &((struct commit *)obj)->tree->object;if (obj->type ==OBJ_TREE ) {if (ARRAY_SIZE (ent) <= ents) -die ("more than %d trees given: '%s'" , +die (_ ("more than %d trees given: '%s'" ), (int )ARRAY_SIZE (ent), name); obj->flags |= flags; ent[ents].item = obj;
@@ -364,7 +364,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix) }if (obj->type ==OBJ_BLOB ) {if (2 <= blobs) -die ("more than two blobs given: '%s'" , name); +die (_ ("more than two blobs given: '%s'" ), name);hashcpy (blob[blobs].sha1, obj->sha1); blob[blobs].name = name; blob[blobs].mode = list->mode;
@@ -372,7 +372,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)continue ; } -die ("unhandled object '%s' given." , name); +die (_ ("unhandled object '%s' given." ), name); }if (rev.prune_data) {const char **pathspec = rev.prune_data;
Signature · 1 line
1.7.2.3
PATCH v4 32/73 gettextize: git-fetch basic messages
In reply to Junio C Hamano--- builtin/fetch.c | 46 +++++++++++++++++++++++----------------------- 1 files changed, 23 insertions(+), 23 deletions(-)
builtin/fetch.c +23 -23
@@ -184,7 +184,7 @@ static struct ref *get_ref_map(struct transport *transport, }else { ref_map =get_remote_ref (remote_refs,"HEAD" );if (!ref_map) -die ("Couldn't find remote ref HEAD" ); +die (_ ("Couldn't find remote ref HEAD" )); ref_map->merge =1 ; tail = &ref_map->next; }
@@ -237,7 +237,7 @@ static int update_local_ref(struct ref *ref, *display =0 ; type =sha1_object_info (ref->new_sha1,NULL );if (type <0 ) -die ("object %s not found" ,sha1_to_hex (ref->new_sha1)); +die (_ ("object %s not found" ),sha1_to_hex (ref->new_sha1));if (!hashcmp (ref->old_sha1, ref->new_sha1)) {if (verbosity >0 )
@@ -337,7 +337,7 @@ static int store_updated_refs(const char *raw_url, const char *remote_name, fp =fopen (filename,"a" );if (!fp) -return error ("cannot open %s: %s\n" , filename,strerror (errno)); +return error (_ ("cannot open %s: %s\n" ), filename,strerror (errno));if (raw_url) url =transport_anonymize_url (raw_url);
@@ -426,9 +426,9 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,free (url);fclose (fp);if (rc &STORE_REF_ERROR_DF_CONFLICT ) -error ("some local refs could not be updated; try running\n" +error (_ ("some local refs could not be updated; try running\n" " 'git remote prune %s' to remove any old, conflicting " -"branches" , remote_name); +"branches" ), remote_name);return rc; }
@@ -476,7 +476,7 @@ static int quickfetch(struct ref *ref_map) err =start_command (&revlist);if (err) { -error ("could not run rev-list" ); +error (_ ("could not run rev-list" ));return err; }
@@ -490,14 +490,14 @@ static int quickfetch(struct ref *ref_map)if (write_in_full (revlist.in,sha1_to_hex (ref->old_sha1),40 ) <0 ||write_str_in_full (revlist.in,"\n" ) <0 ) {if (errno !=EPIPE && errno !=EINVAL ) -error ("failed write to rev-list: %s" ,strerror (errno)); +error (_ ("failed write to rev-list: %s" ),strerror (errno)); err =-1 ;break ; } }if (close (revlist.in)) { -error ("failed to close rev-list's stdin: %s" ,strerror (errno)); +error (_ ("failed to close rev-list's stdin: %s" ),strerror (errno)); err =-1 ; }
@@ -650,8 +650,8 @@ static void check_not_current_branch(struct ref *ref_map)for (; ref_map; ref_map = ref_map->next)if (ref_map->peer_ref && !strcmp (current_branch->refname, ref_map->peer_ref->name)) -die ("Refusing to fetch into current branch %s " -"of non-bare repository" , current_branch->refname); +die (_ ("Refusing to fetch into current branch %s " +"of non-bare repository" ), current_branch->refname); }static int truncate_fetch_head (void )
@@ -660,7 +660,7 @@ static int truncate_fetch_head(void)FILE *fp =fopen (filename,"w" );if (!fp) -return error ("cannot open %s: %s\n" , filename,strerror (errno)); +return error (_ ("cannot open %s: %s\n" ), filename,strerror (errno));fclose (fp);return 0 ; }
@@ -684,7 +684,7 @@ static int do_fetch(struct transport *transport, }if (!transport->get_refs_list || !transport->fetch) -die ("Don't know how to fetch from %s" , transport->url); +die (_ ("Don't know how to fetch from %s" ), transport->url);/* if not appending, truncate FETCH_HEAD */ if (!append && !dry_run) {
@@ -738,10 +738,10 @@ static void set_option(const char *name, const char *value) {int r =transport_set_option (transport, name, value);if (r <0 ) -die ("Option \"%s\" value \"%s\" is not valid for %s" , +die (_ ("Option \"%s\" value \"%s\" is not valid for %s" ), name, value, transport->url);if (r >0 ) -warning ("Option \"%s\" is ignored for %s\n" , +warning (_ ("Option \"%s\" is ignored for %s\n" ), name, transport->url); }
@@ -838,9 +838,9 @@ static int fetch_multiple(struct string_list *list) argv[argc] = name; argv[argc +1 ] =NULL ;if (verbosity >=0 ) -printf ("Fetching %s\n" , name); +printf (_ ("Fetching %s\n" ), name);if (run_command_v_opt (argv,RUN_GIT_CMD )) { -error ("Could not fetch %s" , name); +error (_ ("Could not fetch %s" ), name); result =1 ; } }
@@ -856,8 +856,8 @@ static int fetch_one(struct remote *remote, int argc, const char **argv)int exit_code;if (!remote) -die ("No remote repository specified. Please, specify either a URL or a\n" -"remote name from which new revisions should be fetched." ); +die (_ ("No remote repository specified. Please, specify either a URL or a\n" +"remote name from which new revisions should be fetched." )); transport =transport_get (remote,NULL );transport_set_verbosity (transport, verbosity, progress);
@@ -876,7 +876,7 @@ static int fetch_one(struct remote *remote, int argc, const char **argv)char *ref; i++;if (i >= argc) -die ("You need to specify a tag name." ); +die (_ ("You need to specify a tag name." )); ref =xmalloc (strlen (argv[i]) *2 +22 );strcpy (ref,"refs/tags/" );strcat (ref, argv[i]);
@@ -916,9 +916,9 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)if (all) {if (argc ==1 ) -die ("fetch --all does not take a repository argument" ); +die (_ ("fetch --all does not take a repository argument" ));else if (argc >1 ) -die ("fetch --all does not make sense with refspecs" ); +die (_ ("fetch --all does not make sense with refspecs" )); (void )for_each_remote (get_one_remote_for_fetch, &list); result =fetch_multiple (&list); }else if (argc ==0 ) {
@@ -929,7 +929,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)/* All arguments are assumed to be remotes or groups */ for (i =0 ; i < argc; i++)if (!add_remote_or_group (argv[i], &list)) -die ("No such remote or remote group: %s" , argv[i]); +die (_ ("No such remote or remote group: %s" ), argv[i]); result =fetch_multiple (&list); }else {/* Single remote or group */
@@ -937,7 +937,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)if (list.nr >1 ) {/* More than one remote */ if (argc >1 ) -die ("Fetching a group and specifying refspecs does not make sense" ); +die (_ ("Fetching a group and specifying refspecs does not make sense" )); result =fetch_multiple (&list); }else {/* Zero or one remotes */
Signature · 1 line
1.7.2.3
PATCH v4 33/73 gettextize: git-fetch formatting messages
In reply to Junio C HamanoTranslate some of the formatting messages that appear on git-fetch showing how branches/tags etc. were updated.
--- builtin/fetch.c | 20 ++++++++++---------- t/t5526-fetch-submodules.sh | 40 ++++++++++++++++++++++++++++++++-------- 2 files changed, 42 insertions(+), 18 deletions(-)
builtin/fetch.c +10 -10
@@ -242,7 +242,7 @@ static int update_local_ref(struct ref *ref,if (!hashcmp (ref->old_sha1, ref->new_sha1)) {if (verbosity >0 )sprintf (display,"= %-*s %-*s -> %s" ,TRANSPORT_SUMMARY_WIDTH , -"[up to date]" ,REFCOL_WIDTH , remote, +_ ("[up to date]" ),REFCOL_WIDTH , remote, pretty_ref);return 0 ; }
@@ -255,8 +255,8 @@ static int update_local_ref(struct ref *ref,* If this is the head, and it's not okay to update * the head, and the old value of the head isn't empty... */ -sprintf (display,"! %-*s %-*s -> %s (can't fetch in current branch)" , -TRANSPORT_SUMMARY_WIDTH ,"[rejected]" ,REFCOL_WIDTH , remote, +sprintf (display,_ ("! %-*s %-*s -> %s (can't fetch in current branch)" ), +TRANSPORT_SUMMARY_WIDTH ,_ ("[rejected]" ),REFCOL_WIDTH , remote, pretty_ref);return 1 ; }
@@ -266,8 +266,8 @@ static int update_local_ref(struct ref *ref,int r; r =s_update_ref ("updating tag" , ref,0 );sprintf (display,"%c %-*s %-*s -> %s%s" , r ?'!' :'-' , -TRANSPORT_SUMMARY_WIDTH ,"[tag update]" ,REFCOL_WIDTH , remote, - pretty_ref, r ?" (unable to update local ref)" :"" ); +TRANSPORT_SUMMARY_WIDTH ,_ ("[tag update]" ),REFCOL_WIDTH , remote, + pretty_ref, r ?_ (" (unable to update local ref)" ) :"" );return r; }
@@ -415,7 +415,7 @@ static int store_updated_refs(const char *raw_url, const char *remote_name, REFCOL_WIDTH, *what ? what : "HEAD");if (*note) {if (verbosity >=0 && !shown_url) { -fprintf (stderr,"From %.*s\n" , +fprintf (stderr,_ ("From %.*s\n" ), url_len, url); shown_url =1 ; }
@@ -524,16 +524,16 @@ static int prune_refs(struct transport *transport, struct ref *ref_map)int result =0 ;struct ref *ref, *stale_refs =get_stale_heads (transport->remote, ref_map);const char *dangling_msg = dry_run - ?" (%s will become dangling)\n" - :" (%s has become dangling)\n" ; + ?_ (" (%s will become dangling)\n" ) + :_ (" (%s has become dangling)\n" );for (ref = stale_refs; ref; ref = ref->next) {if (!dry_run) result |=delete_ref (ref->name,NULL ,0 );if (verbosity >=0 ) {fprintf (stderr," x %-*s %-*s -> %s\n" , -TRANSPORT_SUMMARY_WIDTH ,"[deleted]" , -REFCOL_WIDTH ,"(none)" ,prettify_refname (ref->name)); +TRANSPORT_SUMMARY_WIDTH ,_ ("[deleted]" ), +REFCOL_WIDTH ,_ ("(none)" ),prettify_refname (ref->name));warn_dangling_symref (stderr, dangling_msg, ref->name); } }
t/t5526-fetch-submodules.sh +32 -8
@@ -66,7 +66,10 @@ test_expect_success "fetch --recurse-submodules recurses into submodules" ' ( cd downstream && git fetch --recurse-submodules >../actual.out 2>../actual.err - ) && + ) +' + +test_expect_success C_LOCALE_OUTPUT "fetch --recurse-submodules recurses into submodules: output" ' test_cmp expect.out actual.out && test_cmp expect.err actual.err '
@@ -95,7 +98,10 @@ test_expect_success "using fetchRecurseSubmodules=true in .gitmodules recurses i cd downstream && git config -f .gitmodules submodule.submodule.fetchRecurseSubmodules true && git fetch >../actual.out 2>../actual.err - ) && + ) +' + +test_expect_success C_LOCALE_OUTPUT "using fetchRecurseSubmodules=true in .gitmodules recurses into submodules" ' test_cmp expect.out actual.out && test_cmp expect.err actual.err '
@@ -126,7 +132,10 @@ test_expect_success "--recurse-submodules overrides fetchRecurseSubmodules setti git fetch --recurse-submodules >../actual.out 2>../actual.err && git config --unset -f .gitmodules submodule.submodule.fetchRecurseSubmodules && git config --unset submodule.submodule.fetchRecurseSubmodules - ) && + ) +' + +test_expect_success C_LOCALE_OUTPUT "--recurse-submodules overrides fetchRecurseSubmodules setting from .git/config: output" ' test_cmp expect.out actual.out && test_cmp expect.err actual.err '
@@ -145,13 +154,22 @@ test_expect_success "--dry-run propagates to submodules" ' ( cd downstream && git fetch --recurse-submodules --dry-run >../actual.out 2>../actual.err - ) && + ) +' + +test_expect_success C_LOCALE_OUTPUT "--dry-run propagates to submodules: output" ' test_cmp expect.out actual.out && - test_cmp expect.err actual.err && + test_cmp expect.err actual.err +' + +test_expect_success "Without --dry-run propagates to submodules" ' ( cd downstream && git fetch --recurse-submodules >../actual.out 2>../actual.err - ) && + ) +' + +test_expect_success C_LOCALE_OUTPUT "Without --dry-run propagates to submodules: output" ' test_cmp expect.out actual.out && test_cmp expect.err actual.err '
@@ -162,7 +180,10 @@ test_expect_success "recurseSubmodules=true propagates into submodules" ' cd downstream && git config fetch.recurseSubmodules true git fetch >../actual.out 2>../actual.err - ) && + ) +' + +test_expect_success C_LOCALE_OUTPUT "recurseSubmodules=true propagates into submodules: output" ' test_cmp expect.out actual.out && test_cmp expect.err actual.err '
@@ -176,7 +197,10 @@ test_expect_success "--recurse-submodules overrides config in submodule" ' git config fetch.recurseSubmodules false ) && git fetch --recurse-submodules >../actual.out 2>../actual.err - ) && + ) +' + +test_expect_success C_LOCALE_OUTPUT "--recurse-submodules overrides config in submodule: output" ' test_cmp expect.out actual.out && test_cmp expect.err actual.err '
Signature · 1 line
1.7.2.3
PATCH v4 34/73 gettextize: git-fetch update_local_ref messages
In reply to Junio C HamanoTranslate a "[rejected]" message spotted by Jeff King, and other things in update_local_ref along with it.
--- builtin/fetch.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-)
builtin/fetch.c +5 -5
@@ -279,17 +279,17 @@ static int update_local_ref(struct ref *ref,int r;if (!strncmp (ref->name,"refs/tags/" ,10 )) { msg ="storing tag" ; - what ="[new tag]" ; + what =_ ("[new tag]" ); }else { msg ="storing head" ; - what ="[new branch]" ; + what =_ ("[new branch]" ); } r =s_update_ref (msg, ref,0 );sprintf (display,"%c %-*s %-*s -> %s%s" , r ?'!' :'*' ,TRANSPORT_SUMMARY_WIDTH , what,REFCOL_WIDTH , remote, pretty_ref, - r ?" (unable to update local ref)" :"" ); + r ?_ (" (unable to update local ref)" ) :"" );return r; }
@@ -302,7 +302,7 @@ static int update_local_ref(struct ref *ref, r =s_update_ref ("fast-forward" , ref,1 );sprintf (display,"%c %-*s %-*s -> %s%s" , r ?'!' :' ' ,TRANSPORT_SUMMARY_WIDTH , quickref,REFCOL_WIDTH , remote, - pretty_ref, r ?" (unable to update local ref)" :"" ); + pretty_ref, r ?_ (" (unable to update local ref)" ) :"" );return r; }else if (force || ref->force) {char quickref[84 ];
@@ -314,7 +314,7 @@ static int update_local_ref(struct ref *ref,sprintf (display,"%c %-*s %-*s -> %s (%s)" , r ?'!' :'+' ,TRANSPORT_SUMMARY_WIDTH , quickref,REFCOL_WIDTH , remote, pretty_ref, - r ?"unable to update local ref" :"forced update" ); + r ?_ ("unable to update local ref" ) :_ ("forced update" ));return r; }else { sprintf(display, "! %-*s %-*s -> %s (non-fast-forward)",
Signature · 1 line
1.7.2.3
PATCH v4 35/73 gettextize: git-fetch split up "(non-fast-forward)" message
In reply to Junio C HamanoSplit up the "(non-fast-forward)" message from printf directives and make it translatable.
--- builtin/fetch.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
builtin/fetch.c +3 -3
@@ -317,9 +317,9 @@ static int update_local_ref(struct ref *ref, r ? _("unable to update local ref") : _("forced update"));return r; }else { -sprintf (display,"! %-*s %-*s -> %s (non-fast-forward)" , -TRANSPORT_SUMMARY_WIDTH ,"[rejected]" ,REFCOL_WIDTH , remote, - pretty_ref); +sprintf (display,"! %-*s %-*s -> %s %s" , +TRANSPORT_SUMMARY_WIDTH ,_ ("[rejected]" ),REFCOL_WIDTH , remote, + pretty_ref,_ ("(non-fast-forward)" ));return 1 ; } }
Signature · 1 line
1.7.2.3
PATCH v4 36/73 gettextize: git-grep basic messages
In reply to Junio C Hamano--- builtin/grep.c | 32 ++++++++++++++++---------------- 1 files changed, 16 insertions(+), 16 deletions(-)
builtin/grep.c +16 -16
@@ -245,7 +245,7 @@ static void start_threads(struct grep_opt *opt) err =pthread_create (&threads[i],NULL , run, o);if (err) -die ("grep: failed to create thread: %s" , +die (_ ("grep: failed to create thread: %s" ),strerror (err)); } }
@@ -450,7 +450,7 @@ static void *load_sha1(const unsigned char *sha1, unsigned long *size,void *data =lock_and_read_sha1_file (sha1, &type, size);if (!data) -error ("'%s': unable to read %s" , name,sha1_to_hex (sha1)); +error (_ ("'%s': unable to read %s" ), name,sha1_to_hex (sha1));return data; }
@@ -501,7 +501,7 @@ static void *load_file(const char *filename, size_t *sz)if (lstat (filename, &st) <0 ) { err_ret:if (errno !=ENOENT ) -error ("'%s': %s" , filename,strerror (errno)); +error (_ ("'%s': %s" ), filename,strerror (errno));return 0 ; }if (!S_ISREG (st.st_mode))
@@ -512,7 +512,7 @@ static void *load_file(const char *filename, size_t *sz) goto err_ret; data =xmalloc (*sz +1 );if (st.st_size !=read_in_full (i, data, *sz)) { -error ("'%s': short read %s" , filename,strerror (errno)); +error (_ ("'%s': short read %s" ), filename,strerror (errno));close (i);free (data);return 0 ;
@@ -574,7 +574,7 @@ static void run_pager(struct grep_opt *opt, const char *prefix) argv[path_list->nr] =NULL ;if (prefix &&chdir (prefix)) -die ("Failed to chdir: %s" , prefix); +die (_ ("Failed to chdir: %s" ), prefix); status =run_command_v_opt (argv,RUN_USING_SHELL );if (status)exit (status);
@@ -664,7 +664,7 @@ static int grep_tree(struct grep_opt *opt, const char **paths, data =lock_and_read_sha1_file (entry.sha1, &type, &size);if (!data) -die ("unable to read tree (%s)" , +die (_ ("unable to read tree (%s)" ),sha1_to_hex (entry.sha1));init_tree_desc (&sub, data, size); hit |=grep_tree (opt, paths, &sub, tree_name, down);
@@ -690,13 +690,13 @@ static int grep_object(struct grep_opt *opt, const char **paths, data =read_object_with_reference (obj->sha1, tree_type, &size,NULL );if (!data) -die ("unable to read tree (%s)" ,sha1_to_hex (obj->sha1)); +die (_ ("unable to read tree (%s)" ),sha1_to_hex (obj->sha1));init_tree_desc (&tree, data, size); hit =grep_tree (opt, paths, &tree, name,"" );free (data);return hit; } -die ("unable to grep from object of type %s" ,typename (obj->type)); +die (_ ("unable to grep from object of type %s" ),typename (obj->type)); } static int grep_objects(struct grep_opt *opt, const char **paths,
@@ -748,7 +748,7 @@ static int context_callback(const struct option *opt, const char *arg, } value =strtol (arg, (char **)&endp,10 );if (*endp) { -return error ("switch `%c' expects a numerical value" , +return error (_ ("switch `%c' expects a numerical value" ), opt->short_name); } grep_opt->pre_context = grep_opt->post_context = value;
@@ -764,7 +764,7 @@ static int file_callback(const struct option *opt, const char *arg, int unset) patterns =fopen (arg,"r" );if (!patterns) -die_errno ("cannot open '%s'" , arg); +die_errno (_ ("cannot open '%s'" ), arg);while (strbuf_getline (&sb, patterns,'\n' ) ==0 ) {char *s;size_t len;
@@ -1005,11 +1005,11 @@ int cmd_grep(int argc, const char **argv, const char *prefix) }if (!opt.pattern_list) -die ("no pattern given." ); +die (_ ("no pattern given." ));if (!opt.fixed && opt.ignore_case) opt.regflags |=REG_ICASE ;if ((opt.regflags !=REG_NEWLINE ) && opt.fixed) -die ("cannot mix --fixed-strings and regexp" ); +die (_ ("cannot mix --fixed-strings and regexp" ));#ifndef NO_PTHREADS if (online_cpus () ==1 || !grep_threads_ok (&opt))
@@ -1034,7 +1034,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)if (!get_sha1 (arg, sha1)) {struct object *object =parse_object (sha1);if (!object) -die ("bad object %s" , arg); +die (_ ("bad object %s" ), arg);add_object_array (object, arg, &list);continue ; }
@@ -1086,9 +1086,9 @@ int cmd_grep(int argc, const char **argv, const char *prefix)if (!use_index) {if (cached) -die ("--cached cannot be used with --no-index." ); +die (_ ("--cached cannot be used with --no-index." ));if (list.nr) -die ("--no-index cannot be used with revs." ); +die (_ ("--no-index cannot be used with revs." )); hit =grep_directory (&opt, paths); }else if (!list.nr) {if (!cached)
@@ -1097,7 +1097,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix) hit =grep_cache (&opt, paths, cached); }else {if (cached) -die ("both --cached and trees are given." ); +die (_ ("both --cached and trees are given." )); hit =grep_objects (&opt, paths, &list); }
Signature · 1 line
1.7.2.3
PATCH v4 37/73 gettextize: git-grep "--open-files-in-pager" message
In reply to Junio C HamanoGettextize the "--open-files-in-pager only works on the worktree" message. A test in t7811-grep-open.sh explicitly checked for this message. Change it to skip under GETTEXT_POISON=YesPlease.
--- builtin/grep.c | 2 +- t/t7811-grep-open.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
builtin/grep.c +1 -1
@@ -1061,7 +1061,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix) }if (show_in_pager && (cached || list.nr)) -die ("--open-files-in-pager only works on the worktree" ); +die (_ ("--open-files-in-pager only works on the worktree" ));if (show_in_pager && opt.pattern_list && !opt.pattern_list->next) {const char *pager = path_list.items[0 ].string;
t/t7811-grep-open.sh +1 -1
@@ -61,7 +61,7 @@ test_expect_success SIMPLEPAGER 'git grep -O' ' test_cmp empty out ' -test_expect_success 'git grep -O --cached' ' +test_expect_success C_LOCALE_OUTPUT 'git grep -O --cached' ' test_must_fail git grep --cached -O GREP_PATTERN >out 2>msg && grep open-files-in-pager msg '
Signature · 1 line
1.7.2.3
PATCH v4 38/73 gettextize: git-log basic messages
In reply to Junio C Hamano--- builtin/log.c | 62 ++++++++++++++++++++++++++++---------------------------- 1 files changed, 31 insertions(+), 31 deletions(-)
builtin/log.c +31 -31
@@ -101,7 +101,7 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix,const char *v =skip_prefix (arg,"--decorate=" ); decoration_style =parse_decoration_style (arg, v);if (decoration_style <0 ) -die ("invalid --decorate option: %s" , arg); +die (_ ("invalid --decorate option: %s" ), arg); decoration_given =1 ; }else if (!strcmp (arg,"--no-decorate" )) { decoration_style =0 ;
@@ -110,7 +110,7 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix, }else if (!strcmp (arg,"-h" )) {usage (builtin_log_usage); }else -die ("unrecognized argument: %s" , arg); +die (_ ("unrecognized argument: %s" ), arg); }/*
@@ -153,7 +153,7 @@ static void show_early_header(struct rev_info *rev, const char *stage, int nr)if (rev->commit_format !=CMIT_FMT_ONELINE )putchar (rev->diffopt.line_termination); } -printf ("Final output: %d %s\n" , nr, stage); +printf (_ ("Final output: %d %s\n" ), nr, stage); }static struct itimerval early_output_timer;
@@ -252,7 +252,7 @@ static int cmd_log_walk(struct rev_info *rev)setup_early_output (rev);if (prepare_revision_walk (rev)) -die ("revision walk setup failed" ); +die (_ ("revision walk setup failed" ));if (rev->early_output)finish_early_output (rev);
@@ -343,7 +343,7 @@ static int show_object(const unsigned char *sha1, int show_tag_object,int offset =0 ;if (!buf) -return error ("Could not read object %s" ,sha1_to_hex (sha1)); +return error (_ ("Could not read object %s" ),sha1_to_hex (sha1));if (show_tag_object)while (offset < size && buf[offset] !='\n' ) {
@@ -430,7 +430,7 @@ int cmd_show(int argc, const char **argv, const char *prefix)break ; o =parse_object (t->tagged->sha1);if (!o) - ret =error ("Could not read object %s" , + ret =error (_ ("Could not read object %s" ),sha1_to_hex (t->tagged->sha1)); objects[i].item = o; i--;
@@ -454,7 +454,7 @@ int cmd_show(int argc, const char **argv, const char *prefix) ret =cmd_log_walk (&rev);break ;default : - ret =error ("Unknown type: %d" , o->type); + ret =error (_ ("Unknown type: %d" ), o->type); } }free (objects);
@@ -554,7 +554,7 @@ static int git_format_config(const char *var, const char *value, void *cb) {if (!strcmp (var,"format.headers" )) {if (!value) -die ("format.headers without value" ); +die (_ ("format.headers without value" ));add_header (value);return 0 ; }
@@ -626,7 +626,7 @@ static int reopen_stdout(struct commit *commit, struct rev_info *rev)strbuf_addstr (&filename, output_directory);if (filename.len >=PATH_MAX -FORMAT_PATCH_NAME_MAX - suffix_len) -return error ("name of output directory is too long" ); +return error (_ ("name of output directory is too long" ));if (filename.buf[filename.len -1 ] !='/' )strbuf_addch (&filename,'/' ); }
@@ -637,7 +637,7 @@ static int reopen_stdout(struct commit *commit, struct rev_info *rev)fprintf (realstdout,"%s\n" , filename.buf + outdir_offset);if (freopen (filename.buf,"w" , stdout) ==NULL ) -return error ("Cannot open patch file %s" , filename.buf); +return error (_ ("Cannot open patch file %s" ), filename.buf);strbuf_release (&filename);return 0 ;
@@ -651,7 +651,7 @@ static void get_patch_ids(struct rev_info *rev, struct patch_ids *ids, const chaunsigned flags1, flags2;if (rev->pending.nr !=2 ) -die ("Need exactly one range." ); +die (_ ("Need exactly one range." )); o1 = rev->pending.objects[0 ].item; flags1 = o1->flags;
@@ -659,7 +659,7 @@ static void get_patch_ids(struct rev_info *rev, struct patch_ids *ids, const cha flags2 = o2->flags;if ((flags1 &UNINTERESTING ) == (flags2 &UNINTERESTING )) -die ("Not a range." ); +die (_ ("Not a range." ));init_patch_ids (ids);
@@ -670,7 +670,7 @@ static void get_patch_ids(struct rev_info *rev, struct patch_ids *ids, const chaadd_pending_object (&check_rev, o1,"o1" );add_pending_object (&check_rev, o2,"o2" );if (prepare_revision_walk (&check_rev)) -die ("revision walk setup failed" ); +die (_ ("revision walk setup failed" ));while ((commit =get_revision (&check_rev)) !=NULL ) {/* ignore merges */
@@ -696,7 +696,7 @@ static void gen_message_id(struct rev_info *info, char *base)const char *email_end =strrchr (committer,'>' );struct strbuf buf =STRBUF_INIT ;if (!email_start || !email_end || email_start > email_end -1 ) -die ("Could not extract email from committer identity." ); +die (_ ("Could not extract email from committer identity." ));strbuf_addf (&buf,"%s.%lu.git.%.*s" , base, (unsigned long )time (NULL ), (int )(email_end - email_start -1 ), email_start +1 );
@@ -728,7 +728,7 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,struct commit *commit =NULL ;if (rev->commit_format !=CMIT_FMT_EMAIL ) -die ("Cover letter needs email format" ); +die (_ ("Cover letter needs email format" )); committer =git_committer_info (0 );
@@ -821,7 +821,7 @@ static const char *clean_message_id(const char *msg_id) m++; }if (!z) -die ("insane in-reply-to: %s" , msg_id); +die (_ ("insane in-reply-to: %s" ), msg_id);if (++z == m)return a;return xmemdupz (a, z - a);
@@ -894,7 +894,7 @@ static int output_directory_callback(const struct option *opt, const char *arg, {const char **dir = (const char **)opt->value;if (*dir) -die ("Two output directories?" ); +die (_ ("Two output directories?" )); *dir = arg;return 0 ; }
@@ -1082,7 +1082,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix) committer =git_committer_info (IDENT_ERROR_ON_NO_NAME ); endpos =strchr (committer,'>' );if (!endpos) -die ("bogus committer info %s" , committer); +die (_ ("bogus committer info %s" ), committer); add_signoff =xmemdupz (committer, endpos - committer +1 ); }
@@ -1127,13 +1127,13 @@ 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 and -k are mutually exclusive." ); +die (_ ("--subject-prefix and -k are mutually exclusive." )); 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" );
@@ -1163,9 +1163,9 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)if (output_directory) {if (use_stdout) -die ("standard output, or directory, which one?" ); +die (_ ("standard output, or directory, which one?" ));if (mkdir (output_directory,0777 ) <0 && errno !=EEXIST ) -die_errno ("Could not create directory '%s'" , +die_errno (_ ("Could not create directory '%s'" ), output_directory); }
@@ -1219,7 +1219,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix) realstdout =xfdopen (xdup (1 ),"w" );if (prepare_revision_walk (&rev)) -die ("revision walk setup failed" ); +die (_ ("revision walk setup failed" )); rev.boundary =1 ;while ((commit =get_revision (&rev)) !=NULL ) {if (commit->object.flags &BOUNDARY ) {
@@ -1300,7 +1300,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)if (!use_stdout &&reopen_stdout (numbered_files ?NULL : commit, &rev)) -die ("Failed to create output files" ); +die (_ ("Failed to create output files" )); shown =log_tree_commit (&rev, commit);free (commit->buffer); commit->buffer =NULL ;
@@ -1387,9 +1387,9 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)if (!current_branch || !current_branch->merge || !current_branch->merge[0 ] || !current_branch->merge[0 ]->dst) { -fprintf (stderr,"Could not find a tracked" +fprintf (stderr,_ ("Could not find a tracked" " remote branch, please" -" specify <upstream> manually.\n" ); +" specify <upstream> manually.\n" ));usage_with_options (cherry_usage, options); }
@@ -1403,9 +1403,9 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)DIFF_OPT_SET (&revs.diffopt,RECURSIVE );if (add_pending_commit (head, &revs,0 )) -die ("Unknown commit %s" , head); +die (_ ("Unknown commit %s" ), head);if (add_pending_commit (upstream, &revs,UNINTERESTING )) -die ("Unknown commit %s" , upstream); +die (_ ("Unknown commit %s" ), upstream);/* Don't say anything if head and upstream are the same. */ if (revs.pending.nr ==2 ) {
@@ -1417,11 +1417,11 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)get_patch_ids (&revs, &ids, prefix);if (limit &&add_pending_commit (limit, &revs,UNINTERESTING )) -die ("Unknown commit %s" , limit); +die (_ ("Unknown commit %s" ), limit);/* reverse the list of commits */ if (prepare_revision_walk (&revs)) -die ("revision walk setup failed" ); +die (_ ("revision walk setup failed" ));while ((commit =get_revision (&revs)) !=NULL ) {/* ignore merges */ if (commit->parents && commit->parents->next)
Signature · 1 line
1.7.2.3
PATCH v4 39/73 gettextize: git-log "--OPT does not make sense" messages
In reply to Junio C HamanoGettextize the "--name-only/--name-status/--check does not make sense" messages. A test in t4014-format-patch.sh explicitly checked for these messages. Change them to skip under GETTEXT_POISON=YesPlease.
--- builtin/log.c | 6 +++--- t/t4014-format-patch.sh | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)
builtin/log.c +3 -3
@@ -1136,11 +1136,11 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)die (_ ("unrecognized argument: %s" ), argv[1 ]);if (rev.diffopt.output_format &DIFF_FORMAT_NAME ) -die ("--name-only does not make sense" ); +die (_ ("--name-only does not make sense" ));if (rev.diffopt.output_format &DIFF_FORMAT_NAME_STATUS ) -die ("--name-status does not make sense" ); +die (_ ("--name-status does not make sense" ));if (rev.diffopt.output_format &DIFF_FORMAT_CHECKDIFF ) -die ("--check does not make sense" ); +die (_ ("--check does not make sense" )); if (!use_patch_format && (!rev.diffopt.output_format ||
t/t4014-format-patch.sh +1 -1
@@ -614,7 +614,7 @@ echo "fatal: --name-only does not make sense" > expect.name-only echo "fatal: --name-status does not make sense" > expect.name-status echo "fatal: --check does not make sense" > expect.check -test_expect_success 'options no longer allowed for format-patch' ' +test_expect_success C_LOCALE_OUTPUT 'options no longer allowed for format-patch' ' test_must_fail git format-patch --name-only 2> output && test_cmp expect.name-only output && test_must_fail git format-patch --name-status 2> output &&
Signature · 1 line
1.7.2.3
PATCH v4 40/73 gettextize: git-merge basic messages
In reply to Junio C Hamano--- builtin/merge.c | 124 ++++++++++++++++++++++---------------------- t/t7607-merge-overwrite.sh | 10 +++- t/t7611-merge-abort.sh | 20 ++++++-- 3 files changed, 86 insertions(+), 68 deletions(-)
builtin/merge.c +62 -62
@@ -80,7 +80,7 @@ static int option_parse_message(const struct option *opt,strbuf_addf (buf,"%s%s" , buf->len ?"\n\n" :"" , arg); have_message =1 ; }else -return error ("switch `m' requires a value" ); +return error (_ ("switch `m' requires a value" ));return 0 ; }
@@ -117,13 +117,13 @@ static struct strategy *get_strategy(const char *name)exclude_cmds (&main_cmds, ¬_strategies); }if (!is_in_cmdlist (&main_cmds, name) && !is_in_cmdlist (&other_cmds, name)) { -fprintf (stderr,"Could not find merge strategy '%s'.\n" , name); -fprintf (stderr,"Available strategies are:" ); +fprintf (stderr,_ ("Could not find merge strategy '%s'.\n" ), name); +fprintf (stderr,_ ("Available strategies are:" ));for (i =0 ; i < main_cmds.cnt; i++)fprintf (stderr," %s" , main_cmds.names[i]->name);fprintf (stderr,".\n" );if (other_cmds.cnt) { -fprintf (stderr,"Available custom strategies are:" ); +fprintf (stderr,_ ("Available custom strategies are:" ));for (i =0 ; i < other_cmds.cnt; i++)fprintf (stderr," %s" , other_cmds.names[i]->name);fprintf (stderr,".\n" );
@@ -224,17 +224,17 @@ static void save_state(void) cp.git_cmd =1 ;if (start_command (&cp)) -die ("could not run stash." ); +die (_ ("could not run stash." )); len =strbuf_read (&buffer, cp.out,1024 );close (cp.out);if (finish_command (&cp) || len <0 ) -die ("stash failed" ); +die (_ ("stash failed" ));else if (!len)return ;strbuf_setlen (&buffer, buffer.len-1 );if (get_sha1 (buffer.buf, stash)) -die ("not a valid object: %s" , buffer.buf); +die (_ ("not a valid object: %s" ), buffer.buf); }static void read_empty (unsigned const char *sha1,int verbose)
@@ -252,7 +252,7 @@ static void read_empty(unsigned const char *sha1, int verbose) args[i] =NULL ;if (run_command_v_opt (args,RUN_GIT_CMD )) -die ("read-tree failed" ); +die (_ ("read-tree failed" )); }static void reset_hard (unsigned const char *sha1,int verbose)
@@ -269,7 +269,7 @@ static void reset_hard(unsigned const char *sha1, int verbose) args[i] =NULL ;if (run_command_v_opt (args,RUN_GIT_CMD )) -die ("read-tree failed" ); +die (_ ("read-tree failed" )); }static void restore_state (void )
@@ -298,7 +298,7 @@ static void restore_state(void)static void finish_up_to_date (const char *msg) {if (verbosity >=0 ) -printf ("%s%s\n" , squash ?" (nothing to squash)" :"" , msg); +printf ("%s%s\n" , squash ?_ (" (nothing to squash)" ) :"" , msg);drop_save (); }
@@ -311,10 +311,10 @@ static void squash_message(void)int fd;struct pretty_print_context ctx = {0 }; -printf ("Squash commit -- not updating HEAD\n" ); +printf (_ ("Squash commit -- not updating HEAD\n" )); fd =open (git_path ("SQUASH_MSG" ),O_WRONLY |O_CREAT ,0666 );if (fd <0 ) -die_errno ("Could not write to '%s'" ,git_path ("SQUASH_MSG" )); +die_errno (_ ("Could not write to '%s'" ),git_path ("SQUASH_MSG" ));init_revisions (&rev,NULL ); rev.ignore_merges =1 ;
@@ -329,7 +329,7 @@ static void squash_message(void)setup_revisions (0 ,NULL , &rev,NULL );if (prepare_revision_walk (&rev)) -die ("revision walk setup failed" ); +die (_ ("revision walk setup failed" )); ctx.abbrev = rev.abbrev; ctx.date_mode = rev.date_mode;
@@ -342,9 +342,9 @@ static void squash_message(void)pretty_print_commit (rev.commit_format, commit, &out, &ctx); }if (write (fd, out.buf, out.len) <0 ) -die_errno ("Writing SQUASH_MSG" ); +die_errno (_ ("Writing SQUASH_MSG" ));if (close (fd)) -die_errno ("Finishing SQUASH_MSG" ); +die_errno (_ ("Finishing SQUASH_MSG" ));strbuf_release (&out); }
@@ -364,7 +364,7 @@ static void finish(const unsigned char *new_head, const char *msg)squash_message (); }else {if (verbosity >=0 && !merge_msg.len) -printf ("No merge message -- not updating HEAD\n" ); +printf (_ ("No merge message -- not updating HEAD\n" ));else {const char *argv_gc_auto[] = {"gc" ,"--auto" ,NULL }; update_ref(reflog_message.buf, "HEAD",
@@ -386,7 +386,7 @@ static void finish(const unsigned char *new_head, const char *msg)if (diff_use_color_default >0 )DIFF_OPT_SET (&opts,COLOR_DIFF );if (diff_setup_done (&opts) <0 ) -die ("diff_setup_done failed" ); +die (_ ("diff_setup_done failed" ));diff_tree_sha1 (head, new_head,"" , &opts);diffcore_std (&opts);diff_flush (&opts);
@@ -415,7 +415,7 @@ static void merge_name(const char *remote, struct strbuf *msg)memset (branch_head,0 ,sizeof (branch_head)); remote_head =peel_to_type (remote,0 ,NULL ,OBJ_COMMIT );if (!remote_head) -die ("'%s' does not point to a commit" , remote); +die (_ ("'%s' does not point to a commit" ), remote);if (dwim_ref (remote,strlen (remote), branch_head, &found_ref) >0 ) {if (!prefixcmp (found_ref,"refs/heads/" )) {
@@ -480,7 +480,7 @@ static void merge_name(const char *remote, struct strbuf *msg) fp =fopen (git_path ("FETCH_HEAD" ),"r" );if (!fp) -die_errno ("could not open '%s' for reading" , +die_errno (_ ("could not open '%s' for reading" ),git_path ("FETCH_HEAD" ));strbuf_getline (&line, fp,'\n' );fclose (fp);
@@ -510,7 +510,7 @@ static int git_merge_config(const char *k, const char *v, void *cb) buf =xstrdup (v); argc =split_cmdline (buf, &argv);if (argc <0 ) -die ("Bad branch.%s.mergeoptions string: %s" , branch, +die (_ ("Bad branch.%s.mergeoptions string: %s" ), branch,split_cmdline_strerror (argc)); argv =xrealloc (argv,sizeof (*argv) * (argc +2 ));memmove (argv +1 , argv,sizeof (*argv) * (argc +1 ));
@@ -532,7 +532,7 @@ static int git_merge_config(const char *k, const char *v, void *cb)int is_bool; shortlog_len =git_config_bool_or_int (k, v, &is_bool);if (!is_bool && shortlog_len <0 ) -return error ("%s: negative length %s" , k, v); +return error (_ ("%s: negative length %s" ), k, v);if (is_bool && shortlog_len) shortlog_len =DEFAULT_MERGE_LOG_LEN ;return 0 ;
@@ -579,7 +579,7 @@ static int read_tree_trivial(unsigned char *common, unsigned char *head,static void write_tree_trivial (unsigned char *sha1) {if (write_cache_as_tree (sha1,0 ,NULL )) -die ("git write-tree failed to write a tree" ); +die (_ ("git write-tree failed to write a tree" )); } int try_merge_command(const char *strategy, size_t xopts_nr,
@@ -621,7 +621,7 @@ int try_merge_command(const char *strategy, size_t xopts_nr,free (args);discard_cache ();if (read_cache () <0 ) -die ("failed to read the cache" ); +die (_ ("failed to read the cache" ));resolve_undo_clear ();return ret;
@@ -638,7 +638,7 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,if (active_cache_changed && (write_cache (index_fd, active_cache, active_nr) ||commit_locked_index (lock))) -return error ("Unable to write index." ); +return error (_ ("Unable to write index." ));rollback_lock_file (lock);if (!strcmp (strategy,"recursive" ) || !strcmp (strategy,"subtree" )) {
@@ -651,7 +651,7 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,struct commit_list *j;if (remoteheads->next) { -error ("Not handling anything other than two heads merge." ); +error (_ ("Not handling anything other than two heads merge." ));return 2 ; }
@@ -663,7 +663,7 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,for (x =0 ; x < xopts_nr; x++)if (parse_merge_opt (&o, xopts[x])) -die ("Unknown option for merge-recursive: -X%s" , xopts[x]); +die (_ ("Unknown option for merge-recursive: -X%s" ), xopts[x]); o.branch1 = head_arg; o.branch2 = remoteheads->item->util;
@@ -677,7 +677,7 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,if (active_cache_changed && (write_cache (index_fd, active_cache, active_nr) ||commit_locked_index (lock))) -die ("unable to write %s" ,get_index_file ()); +die (_ ("unable to write %s" ),get_index_file ());rollback_lock_file (lock);return clean ?0 :1 ; }else {
@@ -749,7 +749,7 @@ int checkout_fast_forward(const unsigned char *head, const unsigned char *remotereturn -1 ;if (write_cache (fd, active_cache, active_nr) ||commit_locked_index (lock_file)) -die ("unable to write new index file" ); +die (_ ("unable to write new index file" ));return 0 ; }
@@ -852,7 +852,7 @@ static int suggest_conflicts(int renormalizing) fp =fopen (git_path ("MERGE_MSG" ),"a" );if (!fp) -die_errno ("Could not open '%s' for writing" , +die_errno (_ ("Could not open '%s' for writing" ),git_path ("MERGE_MSG" ));fprintf (fp,"\nConflicts:\n" );for (pos =0 ; pos < active_nr; pos++) {
@@ -868,8 +868,8 @@ static int suggest_conflicts(int renormalizing) }fclose (fp);rerere (allow_rerere_auto); -printf ("Automatic merge failed; " -"fix conflicts and then commit the result.\n" ); +printf (_ ("Automatic merge failed; " +"fix conflicts and then commit the result.\n" ));return 1 ; }
@@ -883,7 +883,7 @@ static struct commit *is_old_style_invocation(int argc, const char **argv)return NULL ; second_token =lookup_commit_reference_gently (second_sha1,0 );if (!second_token) -die ("'%s' is not a commit" , argv[1 ]); +die (_ ("'%s' is not a commit" ), argv[1 ]);if (hashcmp (second_token->object.sha1, head))return NULL ; }
@@ -951,7 +951,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)const char *nargv[] = {"reset" ,"--merge" ,NULL };if (!file_exists (git_path ("MERGE_HEAD" ))) -die ("There is no merge to abort (MERGE_HEAD missing)." ); +die (_ ("There is no merge to abort (MERGE_HEAD missing)." ));/* Invoke 'git reset --merge' */ return cmd_reset (nargc, nargv, prefix);
@@ -966,10 +966,10 @@ int cmd_merge(int argc, const char **argv, const char *prefix)* add/rm <file>', just 'git commit'. */ if (advice_resolve_conflict) -die ("You have not concluded your merge (MERGE_HEAD exists).\n" -"Please, commit your changes before you can merge." ); +die (_ ("You have not concluded your merge (MERGE_HEAD exists).\n" +"Please, commit your changes before you can merge." ));else -die ("You have not concluded your merge (MERGE_HEAD exists)." ); +die (_ ("You have not concluded your merge (MERGE_HEAD exists)." )); }resolve_undo_clear ();
@@ -978,12 +978,12 @@ int cmd_merge(int argc, const char **argv, const char *prefix)if (squash) {if (!allow_fast_forward) -die ("You cannot combine --squash with --no-ff." ); +die (_ ("You cannot combine --squash with --no-ff." )); option_commit =0 ; }if (!allow_fast_forward && fast_forward_only) -die ("You cannot combine --no-ff with --ff-only." ); +die (_ ("You cannot combine --no-ff with --ff-only." ));if (!argc) usage_with_options(builtin_merge_usage,
@@ -1011,16 +1011,16 @@ int cmd_merge(int argc, const char **argv, const char *prefix)* We do the same for "git pull". */ if (argc !=1 ) -die ("Can merge only exactly one commit into " -"empty head" ); +die (_ ("Can merge only exactly one commit into " +"empty head" ));if (squash) -die ("Squash commit into empty head not supported yet" ); +die (_ ("Squash commit into empty head not supported yet" ));if (!allow_fast_forward) -die ("Non-fast-forward commit does not make sense into " -"an empty head" ); +die (_ ("Non-fast-forward commit does not make sense into " +"an empty head" )); remote_head =peel_to_type (argv[0 ],0 ,NULL ,OBJ_COMMIT );if (!remote_head) -die ("%s - not something we can merge" , argv[0 ]); +die (_ ("%s - not something we can merge" ), argv[0 ]);update_ref ("initial pull" ,"HEAD" , remote_head->sha1,NULL ,0 ,DIE_ON_ERR );read_empty (remote_head->sha1,0 );
@@ -1066,7 +1066,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix) o =peel_to_type (argv[i],0 ,NULL ,OBJ_COMMIT );if (!o) -die ("%s - not something we can merge" , argv[i]); +die (_ ("%s - not something we can merge" ), argv[i]); commit =lookup_commit (o->sha1); commit->util = (void *)argv[i]; remotes = &commit_list_insert (commit, remotes)->next;
@@ -1158,11 +1158,11 @@ int cmd_merge(int argc, const char **argv, const char *prefix)if (allow_trivial && !fast_forward_only) {/* See if it is really trivial. */ git_committer_info (IDENT_ERROR_ON_NO_NAME ); -printf ("Trying really trivial in-index merge...\n" ); +printf (_ ("Trying really trivial in-index merge...\n" ));if (!read_tree_trivial (common->item->object.sha1, head, remoteheads->item->object.sha1))return merge_trivial (); -printf ("Nope.\n" ); +printf (_ ("Nope.\n" )); } }else {/*
@@ -1195,7 +1195,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix) }if (fast_forward_only) -die ("Not possible to fast-forward, aborting." ); +die (_ ("Not possible to fast-forward, aborting." ));/* We are going to make a new commit. */ git_committer_info (IDENT_ERROR_ON_NO_NAME );
@@ -1221,11 +1221,11 @@ int cmd_merge(int argc, const char **argv, const char *prefix)for (i =0 ; i < use_strategies_nr; i++) {int ret;if (i) { -printf ("Rewinding the tree to pristine...\n" ); +printf (_ ("Rewinding the tree to pristine...\n" ));restore_state (); }if (use_strategies_nr !=1 ) -printf ("Trying merge strategy %s...\n" , +printf (_ ("Trying merge strategy %s...\n" ), use_strategies[i]->name);/* * Remember which strategy left the state in the working
@@ -1286,17 +1286,17 @@ int cmd_merge(int argc, const char **argv, const char *prefix)restore_state ();if (use_strategies_nr >1 )fprintf (stderr, -"No merge strategy handled the merge.\n" ); +_ ("No merge strategy handled the merge.\n" ));else -fprintf (stderr,"Merge with strategy %s failed.\n" , +fprintf (stderr,_ ("Merge with strategy %s failed.\n" ), use_strategies[0 ]->name);return 2 ; }else if (best_strategy == wt_strategy) ;/* We already have its result in the working tree. */ else { -printf ("Rewinding the tree to pristine...\n" ); +printf (_ ("Rewinding the tree to pristine...\n" ));restore_state (); -printf ("Using the %s to prepare resolving by hand.\n" , +printf (_ ("Using the %s to prepare resolving by hand.\n" ), best_strategy);try_merge_strategy (best_strategy, common, head_arg); }
@@ -1312,35 +1312,35 @@ int cmd_merge(int argc, const char **argv, const char *prefix) sha1_to_hex(j->item->object.sha1)); fd =open (git_path ("MERGE_HEAD" ),O_WRONLY |O_CREAT ,0666 );if (fd <0 ) -die_errno ("Could not open '%s' for writing" , +die_errno (_ ("Could not open '%s' for writing" ),git_path ("MERGE_HEAD" ));if (write_in_full (fd, buf.buf, buf.len) != buf.len) -die_errno ("Could not write to '%s'" ,git_path ("MERGE_HEAD" )); +die_errno (_ ("Could not write to '%s'" ),git_path ("MERGE_HEAD" ));close (fd);strbuf_addch (&merge_msg,'\n' ); fd =open (git_path ("MERGE_MSG" ),O_WRONLY |O_CREAT ,0666 );if (fd <0 ) -die_errno ("Could not open '%s' for writing" , +die_errno (_ ("Could not open '%s' for writing" ),git_path ("MERGE_MSG" ));if (write_in_full (fd, merge_msg.buf, merge_msg.len) != merge_msg.len) -die_errno ("Could not write to '%s'" ,git_path ("MERGE_MSG" )); +die_errno (_ ("Could not write to '%s'" ),git_path ("MERGE_MSG" ));close (fd); fd =open (git_path ("MERGE_MODE" ),O_WRONLY |O_CREAT |O_TRUNC ,0666 );if (fd <0 ) -die_errno ("Could not open '%s' for writing" , +die_errno (_ ("Could not open '%s' for writing" ),git_path ("MERGE_MODE" ));strbuf_reset (&buf);if (!allow_fast_forward)strbuf_addf (&buf,"no-ff" );if (write_in_full (fd, buf.buf, buf.len) != buf.len) -die_errno ("Could not write to '%s'" ,git_path ("MERGE_MODE" )); +die_errno (_ ("Could not write to '%s'" ),git_path ("MERGE_MODE" ));close (fd); }if (merge_was_ok) { -fprintf (stderr,"Automatic merge went well; " -"stopped before committing as requested\n" ); +fprintf (stderr,_ ("Automatic merge went well; " +"stopped before committing as requested\n" ));return 0 ; }else return suggest_conflicts (option_renormalize);
t/t7607-merge-overwrite.sh +8 -2
@@ -150,8 +150,14 @@ test_expect_success 'will not overwrite untracked file on unborn branch' ' git rm -fr . && git checkout --orphan new && cp important c0.c && - test_must_fail git merge c0 2>out && - test_cmp out expect && + test_must_fail git merge c0 2>out +' + +test_expect_success C_LOCALE_OUTPUT 'will not overwrite untracked file on unborn branch: output' ' + test_cmp out expect +' + +test_expect_success 'will not overwrite untracked file on unborn branch .git/MERGE_HEAD sanity etc.' ' test_path_is_missing .git/MERGE_HEAD && test_cmp important c0.c '
t/t7611-merge-abort.sh +16 -4
@@ -46,8 +46,14 @@ test_expect_success 'setup' ' pre_merge_head="$(git rev-parse HEAD)" test_expect_success 'fails without MERGE_HEAD (unstarted merge)' ' - test_must_fail git merge --abort 2>output && - grep -q MERGE_HEAD output && + test_must_fail git merge --abort 2>output +' + +test_expect_success C_LOCALE_OUTPUT 'fails without MERGE_HEAD (unstarted merge): fatal output' ' + grep -q MERGE_HEAD output +' + +test_expect_success 'fails without MERGE_HEAD (unstarted merge): .git/MERGE_HEAD sanity' ' test ! -f .git/MERGE_HEAD && test "$pre_merge_head" = "$(git rev-parse HEAD)" '
@@ -57,8 +63,14 @@ test_expect_success 'fails without MERGE_HEAD (completed merge)' ' test ! -f .git/MERGE_HEAD && # Merge successfully completed post_merge_head="$(git rev-parse HEAD)" && - test_must_fail git merge --abort 2>output && - grep -q MERGE_HEAD output && + test_must_fail git merge --abort 2>output +' + +test_expect_success C_LOCALE_OUTPUT 'fails without MERGE_HEAD (completed merge): output' ' + grep -q MERGE_HEAD output +' + +test_expect_success 'fails without MERGE_HEAD (completed merge): .git/MERGE_HEAD sanity' ' test ! -f .git/MERGE_HEAD && test "$post_merge_head" = "$(git rev-parse HEAD)" '
Signature · 1 line
1.7.2.3
PATCH v4 41/73 gettextize: git-merge "Updating %s..%s" message
In reply to Junio C HamanoGettextize the "Updating %s..%s\n" message. A test in t1200-tutorial.sh explicitly checked for this message. Split it into two tests to skip the test_cmp test under GETTEXT_POISON=YesPlease.
--- builtin/merge.c | 2 +- t/t1200-tutorial.sh | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-)
builtin/merge.c +1 -1
@@ -1124,7 +1124,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)strcpy (hex,find_unique_abbrev (head,DEFAULT_ABBREV ));if (verbosity >=0 ) -printf ("Updating %s..%s\n" , +printf (_ ("Updating %s..%s\n" ), hex,find_unique_abbrev (remoteheads->item->object.sha1,DEFAULT_ABBREV ));
t/t1200-tutorial.sh +4 -1
@@ -163,7 +163,10 @@ test_expect_success 'git resolve' ' git checkout mybranch && git merge -m "Merge upstream changes." master | sed -e "1s/[0-9a-f]\{7\}/VARIABLE/g" \ - -e "s/^Fast[- ]forward /FASTFORWARD /" >resolve.output && + -e "s/^Fast[- ]forward /FASTFORWARD /" >resolve.output +' + +test_expect_success C_LOCALE_OUTPUT 'git resolve output' ' test_cmp resolve.expect resolve.output '
Signature · 1 line
1.7.2.3
PATCH v4 42/73 gettextize: git-merge "You have not concluded your merge" messages
In reply to Junio C HamanoGettextize the "You have not concluded your merge messages. A test in t3030-merge-recursive.sh explicitly checked for this message. Change it to skip the test under GETTEXT_POISON=YesPlease.
--- t/t3030-merge-recursive.sh | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
t/t3030-merge-recursive.sh +1 -1
@@ -312,7 +312,7 @@ test_expect_success 'merge-recursive result' ' ' -test_expect_success 'fail if the index has unresolved entries' ' +test_expect_success C_LOCALE_OUTPUT 'fail if the index has unresolved entries' ' rm -fr [abcd] && git checkout -f "$c1" &&
Signature · 1 line
1.7.2.3
PATCH v4 43/73 gettextize: git-merge "Wonderful" message
In reply to Junio C HamanoGettextize the "Wonderful" message. A test in t7600-merge.sh explicitly checked for this message. Change it to skip under GETTEXT_POISON=YesPlease.
--- builtin/merge.c | 2 +- t/t7600-merge.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
builtin/merge.c +1 -1
@@ -803,7 +803,7 @@ static int merge_trivial(void)struct commit_list *parent =xmalloc (sizeof (*parent));write_tree_trivial (result_tree); -printf ("Wonderful.\n" ); +printf (_ ("Wonderful.\n" )); parent->item =lookup_commit (head); parent->next =xmalloc (sizeof (*parent->next)); parent->next->item = remoteheads->item;
t/t7600-merge.sh +1 -1
@@ -495,7 +495,7 @@ test_expect_success 'merge fast-forward in a dirty tree' ' test_debug 'git log --graph --decorate --oneline --all' -test_expect_success 'in-index merge' ' +test_expect_success C_LOCALE_OUTPUT 'in-index merge' ' git reset --hard c0 && git merge --no-ff -s resolve c1 >out && grep "Wonderful." out &&
Signature · 1 line
1.7.2.3
PATCH v4 44/73 gettextize: git-mv basic messages
In reply to Junio C Hamano--- builtin/mv.c | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-)
builtin/mv.c +8 -8
@@ -74,7 +74,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix) newfd =hold_locked_index (&lock_file,1 );if (read_cache () <0 ) -die ("index file corrupt" ); +die (_ ("index file corrupt" )); source =copy_pathspec (prefix, argv, argc,0 ); modes =xcalloc (argc,sizeof (enum update_mode ));
@@ -100,7 +100,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)const char *bad =NULL ;if (show_only) -printf ("Checking rename of '%s' to '%s'\n" , src, dst); +printf (_ ("Checking rename of '%s' to '%s'\n" ), src, dst); length =strlen (src);if (lstat (src, &st) <0 )
@@ -120,7 +120,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix) first =cache_name_pos (src_w_slash, len_w_slash);if (first >=0 ) -die ("Huh? %.*s is in index?" , +die (_ ("Huh? %.*s is in index?" ), len_w_slash, src_w_slash); first =-1 - first;
@@ -172,7 +172,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)* check both source and destination */ if (S_ISREG (st.st_mode) ||S_ISLNK (st.st_mode)) { -warning ("%s; will overwrite!" , bad); +warning (_ ("%s; will overwrite!" ), bad); bad =NULL ; }else bad ="Cannot overwrite" ;
@@ -193,7 +193,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix) i--; } }else -die ("%s, source=%s, destination=%s" , +die (_ ("%s, source=%s, destination=%s" ), bad, src, dst); } }
@@ -203,10 +203,10 @@ int cmd_mv(int argc, const char **argv, const char *prefix)enum update_mode mode = modes[i];int pos;if (show_only || verbose) -printf ("Renaming %s to %s\n" , src, dst); +printf (_ ("Renaming %s to %s\n" ), src, dst);if (!show_only && mode !=INDEX &&rename (src, dst) <0 && !ignore_errors) -die_errno ("renaming '%s' failed" , src); +die_errno (_ ("renaming '%s' failed" ), src);if (mode ==WORKING_DIRECTORY )continue ;
@@ -220,7 +220,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)if (active_cache_changed) {if (write_cache (newfd, active_cache, active_nr) ||commit_locked_index (&lock_file)) -die ("Unable to write new index file" ); +die (_ ("Unable to write new index file" )); }return 0 ;
Signature · 1 line
1.7.2.3
PATCH v4 45/73 gettextize: git-mv "bad" messages
In reply to Junio C HamanoGettextize messages made by assigning to the "bad" char* variable.
--- builtin/mv.c | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-)
builtin/mv.c +8 -8
@@ -104,13 +104,13 @@ int cmd_mv(int argc, const char **argv, const char *prefix) length =strlen (src);if (lstat (src, &st) <0 ) - bad ="bad source" ; + bad =_ ("bad source" );else if (!strncmp (src, dst, length) && (dst[length] ==0 || dst[length] =='/' )) { - bad ="can not move directory into itself" ; + bad =_ ("can not move directory into itself" ); }else if ((src_is_dir =S_ISDIR (st.st_mode)) &&lstat (dst, &st) ==0 ) - bad ="cannot move directory over file" ; + bad =_ ("cannot move directory over file" );else if (src_is_dir) {const char *src_w_slash =add_slash (src);int len_w_slash = length +1 ;
@@ -132,7 +132,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)free ((char *)src_w_slash);if (last - first <1 ) - bad ="source directory is empty" ; + bad =_ ("source directory is empty" );else {int j, dst_len;
@@ -163,9 +163,9 @@ int cmd_mv(int argc, const char **argv, const char *prefix) argc += last - first; } }else if (cache_name_pos (src, length) <0 ) - bad ="not under version control" ; + bad =_ ("not under version control" );else if (lstat (dst, &st) ==0 ) { - bad ="destination exists" ; + bad =_ ("destination exists" );if (force) {/* * only files can overwrite each other:
@@ -175,10 +175,10 @@ int cmd_mv(int argc, const char **argv, const char *prefix)warning (_ ("%s; will overwrite!" ), bad); bad =NULL ; }else - bad ="Cannot overwrite" ; + bad =_ ("Cannot overwrite" ); } }else if (string_list_has_string (&src_for_dst, dst)) - bad ="multiple sources for the same target" ; + bad =_ ("multiple sources for the same target" );else string_list_insert (&src_for_dst, dst);
Signature · 1 line
1.7.2.3
PATCH v4 46/73 gettextize: git-rm basic messages
In reply to Junio C HamanoMake the basic git-mv messages translatable, but skip things like "rm '%s'\n" and "git rm '%s'\n" for now.
--- builtin/rm.c | 22 +++++++++++----------- 1 files changed, 11 insertions(+), 11 deletions(-)
builtin/rm.c +11 -11
@@ -106,19 +106,19 @@ static int check_local_mod(unsigned char *head, int index_only)*/ if (local_changes && staged_changes) {if (!index_only || !(ce->ce_flags &CE_INTENT_TO_ADD )) - errs =error ("'%s' has staged content different " + errs =error (_ ("'%s' has staged content different " "from both the file and the HEAD\n" -"(use -f to force removal)" , name); +"(use -f to force removal)" ), name); }else if (!index_only) {if (staged_changes) - errs =error ("'%s' has changes staged in the index\n" + errs =error (_ ("'%s' has changes staged in the index\n" "(use --cached to keep the file, " -"or -f to force removal)" , name); +"or -f to force removal)" ), name);if (local_changes) - errs =error ("'%s' has local modifications\n" + errs =error (_ ("'%s' has local modifications\n" "(use --cached to keep the file, " -"or -f to force removal)" , name); +"or -f to force removal)" ), name); } }return errs;
@@ -159,7 +159,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix) newfd =hold_locked_index (&lock_file,1 );if (read_cache () <0 ) -die ("index file corrupt" ); +die (_ ("index file corrupt" )); pathspec =get_pathspec (prefix, argv);refresh_index (&the_index,REFRESH_QUIET , pathspec,NULL ,NULL );
@@ -183,7 +183,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)for (i =0 ; (match = pathspec[i]) !=NULL ; i++) {if (!seen[i]) {if (!ignore_unmatch) { -die ("pathspec '%s' did not match any files" , +die (_ ("pathspec '%s' did not match any files" ), match); } }
@@ -191,7 +191,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix) seen_any =1 ; }if (!recursive && seen[i] ==MATCHED_RECURSIVELY ) -die ("not removing '%s' recursively without -r" , +die (_ ("not removing '%s' recursively without -r" ), *match ? match :"." ); }
@@ -227,7 +227,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)printf ("rm '%s'\n" , path);if (remove_file_from_cache (path)) -die ("git rm: unable to remove %s" , path); +die (_ ("git rm: unable to remove %s" ), path); }if (show_only)
@@ -257,7 +257,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)if (active_cache_changed) {if (write_cache (newfd, active_cache, active_nr) ||commit_locked_index (&lock_file)) -die ("Unable to write new index file" ); +die (_ ("Unable to write new index file" )); }return 0 ;
Signature · 1 line
1.7.2.3
PATCH v4 47/73 gettextize: git-reset basic messages
In reply to Junio C Hamano--- builtin/reset.c | 26 +++++++++++++------------- 1 files changed, 13 insertions(+), 13 deletions(-)
builtin/reset.c +13 -13
@@ -92,20 +92,20 @@ static int reset_index_file(const unsigned char *sha1, int reset_type, int quietif (reset_type ==KEEP ) {unsigned char head_sha1[20 ];if (get_sha1 ("HEAD" , head_sha1)) -return error ("You do not have a valid HEAD." ); +return error (_ ("You do not have a valid HEAD." ));if (!fill_tree_descriptor (desc, head_sha1)) -return error ("Failed to find tree of HEAD." ); +return error (_ ("Failed to find tree of HEAD." )); nr++; opts.fn = twoway_merge; }if (!fill_tree_descriptor (desc + nr -1 , sha1)) -return error ("Failed to find tree of %s." ,sha1_to_hex (sha1)); +return error (_ ("Failed to find tree of %s." ),sha1_to_hex (sha1));if (unpack_trees (nr, desc, &opts))return -1 ;if (write_cache (newfd, active_cache, active_nr) ||commit_locked_index (lock)) -return error ("Could not write new index file." ); +return error (_ ("Could not write new index file." ));return 0 ; }
@@ -115,7 +115,7 @@ static void print_new_head_line(struct commit *commit)const char *hex, *body; hex =find_unique_abbrev (commit->object.sha1,DEFAULT_ABBREV ); -printf ("HEAD is now at %s" , hex); +printf (_ ("HEAD is now at %s" ), hex); body =strstr (commit->buffer,"\n\n" );if (body) {const char *eol;
@@ -139,7 +139,7 @@ static int update_index_refresh(int fd, struct lock_file *index_lock, int flags) }if (read_cache () <0 ) -return error ("Could not read index" ); +return error (_ ("Could not read index" )); result =refresh_index (&the_index, (flags),NULL ,NULL ,"Unstaged changes after reset:" ) ?1 :0 ;
@@ -167,7 +167,7 @@ static void update_index_from_diff(struct diff_queue_struct *q, ce =make_cache_entry (one->mode, one->sha1, one->path,0 ,0 );if (!ce) -die ("make_cache_entry failed for path '%s'" , +die (_ ("make_cache_entry failed for path '%s'" ), one->path);add_cache_entry (ce,ADD_CACHE_OK_TO_ADD |ADD_CACHE_OK_TO_REPLACE );
@@ -222,7 +222,7 @@ static void prepend_reflog_action(const char *action, char *buf, size_t size)if (!rla) rla = sep ="" ;if (snprintf (buf, size,"%s%s%s" , rla, sep, action) >= size) -warning ("Reflog action message too long: %.*s..." ,50 , buf); +warning (_ ("Reflog action message too long: %.*s..." ),50 , buf); }static void die_if_unmerged_cache (int reset_type)
@@ -300,16 +300,16 @@ int cmd_reset(int argc, const char **argv, const char *prefix) }if (get_sha1 (rev, sha1)) -die ("Failed to resolve '%s' as a valid ref." , rev); +die (_ ("Failed to resolve '%s' as a valid ref." ), rev); commit =lookup_commit_reference (sha1);if (!commit) -die ("Could not parse object '%s'." , rev); +die (_ ("Could not parse object '%s'." ), rev);hashcpy (sha1, commit->object.sha1);if (patch_mode) {if (reset_type !=NONE ) -die ("--patch is incompatible with --{hard,mixed,soft}" ); +die (_ ("--patch is incompatible with --{hard,mixed,soft}" ));return interactive_reset (rev, argv + i, prefix); }
@@ -318,7 +318,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)* affecting the working tree nor HEAD. */ if (i < argc) {if (reset_type ==MIXED ) -warning ("--mixed with paths is deprecated; use 'git reset -- <paths>' instead." ); +warning (_ ("--mixed with paths is deprecated; use 'git reset -- <paths>' instead." ));else if (reset_type !=NONE )die ("Cannot do %s reset with paths." , reset_type_names[reset_type]);
@@ -348,7 +348,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)if (reset_type ==KEEP ) err = err ||reset_index_file (sha1,MIXED , quiet);if (err) -die ("Could not reset index file to revision '%s'." , rev); +die (_ ("Could not reset index file to revision '%s'." ), rev); }/* Any resets update HEAD to the head being switched to,
Signature · 1 line
1.7.2.3
PATCH v4 48/73 gettextize: git-reset reset_type_names messages
In reply to Junio C HamanoMake the messages in git-reset that use the reset_type_names static array to be translatable by marking the array items with N_() and using _() later.
--- builtin/reset.c | 14 +++++++------- 1 files changed, 7 insertions(+), 7 deletions(-)
builtin/reset.c +7 -7
@@ -30,7 +30,7 @@ static const char * const git_reset_usage[] = {enum reset_type {MIXED ,SOFT ,HARD ,MERGE ,KEEP ,NONE };static const char *reset_type_names[] = { -"mixed" ,"soft" ,"hard" ,"merge" ,"keep" ,NULL +N_ ("mixed" ),N_ ("soft" ),N_ ("hard" ),N_ ("merge" ),N_ ("keep" ),NULL };static char *args_to_str (const char **argv)
@@ -228,8 +228,8 @@ static void prepend_reflog_action(const char *action, char *buf, size_t size)static void die_if_unmerged_cache (int reset_type) {if (is_merge () ||read_cache () <0 ||unmerged_cache ()) -die ("Cannot do a %s reset in the middle of a merge." , - reset_type_names[reset_type]); +die (_ ("Cannot do a %s reset in the middle of a merge." ), +_ (reset_type_names[reset_type])); }
@@ -320,8 +320,8 @@ int cmd_reset(int argc, const char **argv, const char *prefix)if (reset_type ==MIXED )warning (_ ("--mixed with paths is deprecated; use 'git reset -- <paths>' instead." ));else if (reset_type !=NONE ) -die ("Cannot do %s reset with paths." , - reset_type_names[reset_type]); +die (_ ("Cannot do %s reset with paths." ), +_ (reset_type_names[reset_type]));return read_from_tree (prefix, argv + i, sha1, quiet ?REFRESH_QUIET :REFRESH_IN_PORCELAIN ); }
@@ -332,8 +332,8 @@ int cmd_reset(int argc, const char **argv, const char *prefix)setup_work_tree ();if (reset_type ==MIXED &&is_bare_repository ()) -die ("%s reset is not allowed in a bare repository" , - reset_type_names[reset_type]); +die (_ ("%s reset is not allowed in a bare repository" ), +_ (reset_type_names[reset_type]));/* Soft reset does not touch the index file nor the working tree * at all, but requires them in a good order. Other resets reset
Signature · 1 line
1.7.2.3
PATCH v4 49/73 gettextize: git-reset "Unstaged changes after reset" message
In reply to Junio C HamanoGettextize the ""Unstaged changes after reset:" message. A test in t7102-reset.sh explicitly checked for this message. Change it to skip under GETTEXT_POISON=YesPlease.
--- builtin/reset.c | 2 +- t/t7102-reset.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
builtin/reset.c +1 -1
@@ -142,7 +142,7 @@ static int update_index_refresh(int fd, struct lock_file *index_lock, int flags)return error (_ ("Could not read index" )); result =refresh_index (&the_index, (flags),NULL ,NULL , -"Unstaged changes after reset:" ) ?1 :0 ; +_ ("Unstaged changes after reset:" )) ?1 :0 ;if (write_cache (fd, active_cache, active_nr) ||commit_locked_index (index_lock))return error ("Could not refresh index" );
t/t7102-reset.sh +1 -1
@@ -423,7 +423,7 @@ Unstaged changes after reset: M file2 EOF -test_expect_success '--mixed refreshes the index' ' +test_expect_success C_LOCALE_OUTPUT '--mixed refreshes the index' ' echo 123 >> file2 && git reset --mixed HEAD > output && test_cmp expect output
Signature · 1 line
1.7.2.3
PATCH v4 50/73 gettextize: git-tag basic messages
In reply to Junio C Hamano--- builtin/tag.c | 60 ++++++++++++++++++++++++++++---------------------------- 1 files changed, 30 insertions(+), 30 deletions(-)
builtin/tag.c +30 -30
@@ -118,12 +118,12 @@ static int for_each_tag_name(const char **argv, each_tag_name_fn fn)for (p = argv; *p; p++) {if (snprintf (ref,sizeof (ref),"refs/tags/%s" , *p) >=sizeof (ref)) { -error ("tag name too long: %.*s..." ,50 , *p); +error (_ ("tag name too long: %.*s..." ),50 , *p); had_error =1 ;continue ; }if (!resolve_ref (ref, sha1,1 ,NULL )) { -error ("tag '%s' not found." , *p); +error (_ ("tag '%s' not found." ), *p); had_error =1 ;continue ; }
@@ -138,7 +138,7 @@ static int delete_tag(const char *name, const char *ref, {if (delete_ref (ref, sha1,0 ))return 1 ; -printf ("Deleted tag '%s' (was %s)\n" , name,find_unique_abbrev (sha1,DEFAULT_ABBREV )); +printf (_ ("Deleted tag '%s' (was %s)\n" ), name,find_unique_abbrev (sha1,DEFAULT_ABBREV ));return 0 ; }
@@ -150,7 +150,7 @@ static int verify_tag(const char *name, const char *ref, argv_verify_tag[2 ] =sha1_to_hex (sha1);if (run_command_v_opt (argv_verify_tag,RUN_GIT_CMD )) -return error ("could not verify the tag '%s'" , name); +return error (_ ("could not verify the tag '%s'" ), name);return 0 ; }
@@ -165,7 +165,7 @@ static int do_sign(struct strbuf *buffer)if (!*signingkey) {if (strlcpy (signingkey,git_committer_info (IDENT_ERROR_ON_NO_NAME ),sizeof (signingkey)) >sizeof (signingkey) -1 ) -return error ("committer info too long." ); +return error (_ ("committer info too long." )); bracket =strchr (signingkey,'>' );if (bracket) bracket[1 ] ='\0' ;
@@ -185,20 +185,20 @@ static int do_sign(struct strbuf *buffer) args[3 ] =NULL ;if (start_command (&gpg)) -return error ("could not run gpg." ); +return error (_ ("could not run gpg." ));if (write_in_full (gpg.in, buffer->buf, buffer->len) != buffer->len) {close (gpg.in);close (gpg.out);finish_command (&gpg); -return error ("gpg did not accept the tag data" ); +return error (_ ("gpg did not accept the tag data" )); }close (gpg.in); len =strbuf_read (buffer, gpg.out,1024 );close (gpg.out);if (finish_command (&gpg) || !len || len <0 ) -return error ("gpg failed to sign the tag" ); +return error (_ ("gpg failed to sign the tag" ));/* Strip CR from the line endings, in case we are on Windows. */ for (i = j =0 ; i < buffer->len; i++)
@@ -221,7 +221,7 @@ static const char tag_template[] =static void set_signingkey (const char *value) {if (strlcpy (signingkey, value,sizeof (signingkey)) >=sizeof (signingkey)) -die ("signing key value too long (%.10s...)" , value); +die (_ ("signing key value too long (%.10s...)" ), value); }static int git_tag_config (const char *var,const char *value,void *cb)
@@ -261,9 +261,9 @@ static void write_tag_body(int fd, const unsigned char *sha1)static int build_tag_object (struct strbuf *buf,int sign,unsigned char *result) {if (sign &&do_sign (buf) <0 ) -return error ("unable to sign the tag" ); +return error (_ ("unable to sign the tag" ));if (write_sha1_file (buf->buf, buf->len, tag_type, result) <0 ) -return error ("unable to write tag file" ); +return error (_ ("unable to write tag file" ));return 0 ; }
@@ -278,7 +278,7 @@ static void create_tag(const unsigned char *object, const char *tag, type =sha1_object_info (object,NULL );if (type <=OBJ_NONE ) -die ("bad object type." ); +die (_ ("bad object type." )); header_len =snprintf (header_buf,sizeof (header_buf), "object %s\n"
@@ -291,7 +291,7 @@ static void create_tag(const unsigned char *object, const char *tag, git_committer_info(IDENT_ERROR_ON_NO_NAME));if (header_len >sizeof (header_buf) -1 ) -die ("tag header too big." ); +die (_ ("tag header too big." ));if (!message) {int fd;
@@ -300,7 +300,7 @@ static void create_tag(const unsigned char *object, const char *tag, path =git_pathdup ("TAG_EDITMSG" ); fd =open (path,O_CREAT |O_TRUNC |O_WRONLY ,0600 );if (fd <0 ) -die_errno ("could not create file '%s'" , path); +die_errno (_ ("could not create file '%s'" ), path);if (!is_null_sha1 (prev))write_tag_body (fd, prev);
@@ -310,7 +310,7 @@ static void create_tag(const unsigned char *object, const char *tag,if (launch_editor (path, buf,NULL )) {fprintf (stderr, -"Please supply the message using either -m or -F option.\n" ); +_ ("Please supply the message using either -m or -F option.\n" ));exit (1 ); } }
@@ -318,13 +318,13 @@ static void create_tag(const unsigned char *object, const char *tag,stripspace (buf,1 );if (!message && !buf->len) -die ("no tag message?" ); +die (_ ("no tag message?" ));strbuf_insert (buf,0 , header_buf, header_len);if (build_tag_object (buf, sign, result) <0 ) {if (path) -fprintf (stderr,"The tag message has been left in %s\n" , +fprintf (stderr,_ ("The tag message has been left in %s\n" ), path);exit (128 ); }
@@ -417,9 +417,9 @@ int cmd_tag(int argc, const char **argv, const char *prefix)return list_tags (argv[0 ], lines ==-1 ?0 : lines, with_commit);if (lines !=-1 ) -die ("-n option is only allowed with -l." ); +die (_ ("-n option is only allowed with -l." ));if (with_commit) -die ("--contains option is only allowed with -l." ); +die (_ ("--contains option is only allowed with -l." ));if (delete)return for_each_tag_name (argv, delete_tag);if (verify)
@@ -427,17 +427,17 @@ int cmd_tag(int argc, const char **argv, const char *prefix)if (msg.given || msgfile) {if (msg.given && msgfile) -die ("only one -F or -m option is allowed." ); +die (_ ("only one -F or -m option is allowed." )); annotate =1 ;if (msg.given)strbuf_addbuf (&buf, &(msg.buf));else {if (!strcmp (msgfile,"-" )) {if (strbuf_read (&buf,0 ,1024 ) <0 ) -die_errno ("cannot read '%s'" , msgfile); +die_errno (_ ("cannot read '%s'" ), msgfile); }else {if (strbuf_read_file (&buf, msgfile,1024 ) <0 ) -die_errno ("could not open or read '%s'" , +die_errno (_ ("could not open or read '%s'" ), msgfile); } }
@@ -447,20 +447,20 @@ int cmd_tag(int argc, const char **argv, const char *prefix) object_ref = argc ==2 ? argv[1 ] :"HEAD" ;if (argc >2 ) -die ("too many params" ); +die (_ ("too many params" ));if (get_sha1 (object_ref, object)) -die ("Failed to resolve '%s' as a valid ref." , object_ref); +die (_ ("Failed to resolve '%s' as a valid ref." ), object_ref);if (snprintf (ref,sizeof (ref),"refs/tags/%s" , tag) >sizeof (ref) -1 ) -die ("tag name too long: %.*s..." ,50 , tag); +die (_ ("tag name too long: %.*s..." ),50 , tag);if (check_ref_format (ref)) -die ("'%s' is not a valid tag name." , tag); +die (_ ("'%s' is not a valid tag name." ), tag);if (!resolve_ref (ref, prev,1 ,NULL ))hashclr (prev);else if (!force) -die ("tag '%s' already exists" , tag); +die (_ ("tag '%s' already exists" ), tag);if (annotate) create_tag(object, tag, &buf, msg.given || msgfile,
@@ -468,11 +468,11 @@ int cmd_tag(int argc, const char **argv, const char *prefix) lock =lock_any_ref_for_update (ref, prev,0 );if (!lock) -die ("%s: cannot lock the ref" , ref); +die (_ ("%s: cannot lock the ref" ), ref);if (write_ref_sha1 (lock, object,NULL ) <0 ) -die ("%s: cannot update the ref" , ref); +die (_ ("%s: cannot update the ref" ), ref);if (force &&hashcmp (prev, object)) -printf ("Updated tag '%s' (was %s)\n" , tag,find_unique_abbrev (prev,DEFAULT_ABBREV )); +printf (_ ("Updated tag '%s' (was %s)\n" ), tag,find_unique_abbrev (prev,DEFAULT_ABBREV ));strbuf_release (&buf);return 0 ;
Signature · 1 line
1.7.2.3
PATCH v4 51/73 gettextize: git-tag tag_template message
In reply to Junio C HamanoMark the tag_template message as translatable with N_() and then use it later with _(). We need to skip a test under GETTEXT_POISON that relies on the output having a leading newline.
--- builtin/tag.c | 6 +++--- t/t7004-tag.sh | 1 + 2 files changed, 4 insertions(+), 3 deletions(-)
builtin/tag.c +3 -3
@@ -213,10 +213,10 @@ static int do_sign(struct strbuf *buffer) }static const char tag_template[] = -"\n" +N_ ("\n" "#\n" "# Write a tag message\n" -"#\n" ; +"#\n" );static void set_signingkey (const char *value) {
@@ -305,7 +305,7 @@ static void create_tag(const unsigned char *object, const char *tag,if (!is_null_sha1 (prev))write_tag_body (fd, prev);else -write_or_die (fd, tag_template,strlen (tag_template)); +write_or_die (fd,_ (tag_template),strlen (_ (tag_template)));close (fd);if (launch_editor (path, buf,NULL )) {
t/t7004-tag.sh +1 -0
@@ -1121,6 +1121,7 @@ test_expect_success \ ' test_expect_success \ + C_LOCALE_OUTPUT \ 'message in editor has initial comment: first line' ' # check the first line --- should be empty echo >first.expect &&
Signature · 1 line
1.7.2.3
PATCH v4 52/73 gettextize: git-push basic messages
In reply to Junio C Hamano--- builtin/push.c | 38 +++++++++++++++++++------------------- 1 files changed, 19 insertions(+), 19 deletions(-)
builtin/push.c +19 -19
@@ -40,7 +40,7 @@ static void set_refspecs(const char **refs, int nr)char *tag;int len;if (nr <= ++i) -die ("tag shorthand without <tag>" ); +die (_ ("tag shorthand without <tag>" )); len =strlen (refs[i]) +11 ;if (deleterefs) { tag =xmalloc (len+1 );
@@ -59,7 +59,7 @@ static void set_refspecs(const char **refs, int nr)strcat (delref, ref); ref = delref; }else if (deleterefs) -die ("--delete only accepts plain target ref names" ); +die (_ ("--delete only accepts plain target ref names" ));add_refspec (ref); } }
@@ -69,13 +69,13 @@ static void setup_push_tracking(void)struct strbuf refspec =STRBUF_INIT ;struct branch *branch =branch_get (NULL );if (!branch) -die ("You are not currently on a branch." ); +die (_ ("You are not currently on a branch." ));if (!branch->merge_nr || !branch->merge) -die ("The current branch %s is not tracking anything." , +die (_ ("The current branch %s is not tracking anything." ), branch->name);if (branch->merge_nr !=1 ) -die ("The current branch %s is tracking multiple branches, " -"refusing to push." , branch->name); +die (_ ("The current branch %s is tracking multiple branches, " +"refusing to push." ), branch->name);strbuf_addf (&refspec,"%s:%s" , branch->name, branch->merge[0 ]->src);add_refspec (refspec.buf); }
@@ -97,8 +97,8 @@ static void setup_default_push_refspecs(void)break ;case PUSH_DEFAULT_NOTHING : -die ("You didn't specify any refspecs to push, and " -"push.default is \"nothing\"." ); +die (_ ("You didn't specify any refspecs to push, and " +"push.default is \"nothing\"." ));break ; } }
@@ -117,11 +117,11 @@ static int push_with_options(struct transport *transport, int flags)transport_set_option (transport,TRANS_OPT_THIN ,"yes" );if (verbosity >0 ) -fprintf (stderr,"Pushing to %s\n" , transport->url); +fprintf (stderr,_ ("Pushing to %s\n" ), transport->url); err =transport_push (transport, refspec_nr, refspec, flags, &nonfastforward);if (err !=0 ) -error ("failed to push some refs to '%s'" , transport->url); +error (_ ("failed to push some refs to '%s'" ), transport->url); err |=transport_disconnect (transport);
@@ -146,8 +146,8 @@ static int do_push(const char *repo, int flags)if (!remote) {if (repo) -die ("bad repository '%s'" , repo); -die ("No destination configured to push to." ); +die (_ ("bad repository '%s'" ), repo); +die (_ ("No destination configured to push to." )); }if (remote->mirror)
@@ -155,19 +155,19 @@ static int do_push(const char *repo, int flags)if ((flags &TRANSPORT_PUSH_ALL ) && refspec) {if (!strcmp (*refspec,"refs/tags/*" )) -return error ("--all and --tags are incompatible" ); -return error ("--all can't be combined with refspecs" ); +return error (_ ("--all and --tags are incompatible" )); +return error (_ ("--all can't be combined with refspecs" )); }if ((flags &TRANSPORT_PUSH_MIRROR ) && refspec) {if (!strcmp (*refspec,"refs/tags/*" )) -return error ("--mirror and --tags are incompatible" ); -return error ("--mirror can't be combined with refspecs" ); +return error (_ ("--mirror and --tags are incompatible" )); +return error (_ ("--mirror can't be combined with refspecs" )); }if ((flags & (TRANSPORT_PUSH_ALL |TRANSPORT_PUSH_MIRROR )) == (TRANSPORT_PUSH_ALL |TRANSPORT_PUSH_MIRROR )) { -return error ("--all and --mirror are incompatible" ); +return error (_ ("--all and --mirror are incompatible" )); }if (!refspec && !(flags &TRANSPORT_PUSH_ALL )) {
@@ -232,9 +232,9 @@ int cmd_push(int argc, const char **argv, const char *prefix) argc =parse_options (argc, argv, prefix, options, push_usage,0 );if (deleterefs && (tags || (flags & (TRANSPORT_PUSH_ALL |TRANSPORT_PUSH_MIRROR )))) -die ("--delete is incompatible with --all, --mirror and --tags" ); +die (_ ("--delete is incompatible with --all, --mirror and --tags" ));if (deleterefs && argc <2 ) -die ("--delete doesn't make sense without any refs" ); +die (_ ("--delete doesn't make sense without any refs" ));if (tags)add_refspec ("refs/tags/*" );
Signature · 1 line
1.7.2.3
PATCH v4 53/73 gettextize: git-push "prevent you from losing" message
In reply to Junio C HamanoGettextize the "To prevent you from losing history" message. A test in lib-httpd.sh and another in t5541-http-push.sh explicitly checked for this message. Change them to skip under GETTEXT_POISON=YesPlease.
--- builtin/push.c | 4 ++-- t/lib-httpd.sh | 2 +- t/t5541-http-push.sh | 7 +++++-- 3 files changed, 8 insertions(+), 5 deletions(-)
builtin/push.c +2 -2
@@ -129,9 +129,9 @@ static int push_with_options(struct transport *transport, int flags)return 0 ;if (nonfastforward && advice_push_nonfastforward) { -fprintf (stderr,"To prevent you from losing history, non-fast-forward updates were rejected\n" +fprintf (stderr,_ ("To prevent you from losing history, non-fast-forward updates were rejected\n" "Merge the remote changes (e.g. 'git pull') before pushing again. See the\n" -"'Note about fast-forwards' section of 'git push --help' for details.\n" ); +"'Note about fast-forwards' section of 'git push --help' for details.\n" )); }return 1 ;
t/lib-httpd.sh +1 -1
@@ -157,7 +157,7 @@ test_http_push_nonff() { grep "^ ! \[rejected\][ ]*$BRANCH -> $BRANCH (non-fast-forward)$" output ' - test_expect_success 'non-fast-forward push shows help message' ' + test_expect_success C_LOCALE_OUTPUT 'non-fast-forward push shows help message' ' grep "To prevent you from losing history, non-fast-forward updates were rejected" \ output '
t/t5541-http-push.sh +5 -2
@@ -128,11 +128,14 @@ test_expect_success 'push fails for non-fast-forward refs unmatched by remote he # push master too; this ensures there is at least one '"'push'"' command to # the remote helper and triggers interaction with the helper. - test_must_fail git push -v origin +master master:retsam >output 2>&1 && + test_must_fail git push -v origin +master master:retsam >output 2>&1' +test_expect_success 'push fails for non-fast-forward refs unmatched by remote helper: remote output' ' grep "^ + [a-f0-9]*\.\.\.[a-f0-9]* *master -> master (forced update)$" output && - grep "^ ! \[rejected\] *master -> retsam (non-fast-forward)$" output && + grep "^ ! \[rejected\] *master -> retsam (non-fast-forward)$" output +' +test_expect_success C_LOCALE_OUTPUT 'push fails for non-fast-forward refs unmatched by remote helper: our output' ' grep "To prevent you from losing history, non-fast-forward updates were rejected" \ output '
Signature · 1 line
1.7.2.3
PATCH v4 54/73 gettextize: git-status basic messages
In reply to Junio C HamanoGettextize the most common git-status messages. Many tests checked for these explicitly. Change them to skip under GETTEXT_POISON=YesPlease.
Some of the tests in t7508-status.sh needed to be split up when I added C_LOCALE_OUTPUT to them, since parts of them affected later tests (some of which aren't being skipped) indirectly.
--- t/t7060-wtstatus.sh | 2 +- t/t7506-status-submodule.sh | 20 ++++---- t/t7508-status.sh | 115 ++++++++++++++++++++++++------------------- wt-status.c | 86 ++++++++++++++++---------------- 4 files changed, 119 insertions(+), 104 deletions(-)
t/t7060-wtstatus.sh +1 -1
@@ -38,7 +38,7 @@ cat >expect <<EOF no changes added to commit (use "git add" and/or "git commit -a") EOF -test_expect_success 'M/D conflict does not segfault' ' +test_expect_success C_LOCALE_OUTPUT 'M/D conflict does not segfault' ' mkdir mdconflict && ( cd mdconflict &&
t/t7506-status-submodule.sh +10 -10
@@ -30,7 +30,7 @@ test_expect_success 'commit --dry-run -a clean' ' grep "nothing to commit" output ' -test_expect_success 'status with modified file in submodule' ' +test_expect_success C_LOCALE_OUTPUT 'status with modified file in submodule' ' (cd sub && git reset --hard) && echo "changed" >sub/foo && git status >output &&
@@ -46,7 +46,7 @@ test_expect_success 'status with modified file in submodule (porcelain)' ' EOF ' -test_expect_success 'status with added file in submodule' ' +test_expect_success C_LOCALE_OUTPUT 'status with added file in submodule' ' (cd sub && git reset --hard && echo >foo && git add foo) && git status >output && grep "modified: sub (modified content)" output
@@ -60,14 +60,14 @@ test_expect_success 'status with added file in submodule (porcelain)' ' EOF ' -test_expect_success 'status with untracked file in submodule' ' +test_expect_success C_LOCALE_OUTPUT 'status with untracked file in submodule' ' (cd sub && git reset --hard) && echo "content" >sub/new-file && git status >output && grep "modified: sub (untracked content)" output ' -test_expect_success 'status -uno with untracked file in submodule' ' +test_expect_success C_LOCALE_OUTPUT 'status -uno with untracked file in submodule' ' git status -uno >output && grep "^nothing to commit" output '
@@ -79,7 +79,7 @@ test_expect_success 'status with untracked file in submodule (porcelain)' ' EOF ' -test_expect_success 'status with added and untracked file in submodule' ' +test_expect_success C_LOCALE_OUTPUT 'status with added and untracked file in submodule' ' (cd sub && git reset --hard && echo >foo && git add foo) && echo "content" >sub/new-file && git status >output &&
@@ -95,7 +95,7 @@ test_expect_success 'status with added and untracked file in submodule (porcelai EOF ' -test_expect_success 'status with modified file in modified submodule' ' +test_expect_success C_LOCALE_OUTPUT 'status with modified file in modified submodule' ' (cd sub && git reset --hard) && rm sub/new-file && (cd sub && echo "next change" >foo && git commit -m "next change" foo) &&
@@ -113,7 +113,7 @@ test_expect_success 'status with modified file in modified submodule (porcelain) EOF ' -test_expect_success 'status with added file in modified submodule' ' +test_expect_success C_LOCALE_OUTPUT 'status with added file in modified submodule' ' (cd sub && git reset --hard && echo >foo && git add foo) && git status >output && grep "modified: sub (new commits, modified content)" output
@@ -127,7 +127,7 @@ test_expect_success 'status with added file in modified submodule (porcelain)' ' EOF ' -test_expect_success 'status with untracked file in modified submodule' ' +test_expect_success C_LOCALE_OUTPUT 'status with untracked file in modified submodule' ' (cd sub && git reset --hard) && echo "content" >sub/new-file && git status >output &&
@@ -141,7 +141,7 @@ test_expect_success 'status with untracked file in modified submodule (porcelain EOF ' -test_expect_success 'status with added and untracked file in modified submodule' ' +test_expect_success C_LOCALE_OUTPUT 'status with added and untracked file in modified submodule' ' (cd sub && git reset --hard && echo >foo && git add foo) && echo "content" >sub/new-file && git status >output &&
@@ -167,7 +167,7 @@ test_expect_success 'setup .git file for sub' ' git commit -m "added .real to .gitignore" .gitignore ' -test_expect_success 'status with added file in modified submodule with .git file' ' +test_expect_success C_LOCALE_OUTPUT 'status with added file in modified submodule with .git file' ' (cd sub && git reset --hard && echo >foo && git add foo) && git status >output && grep "modified: sub (new commits, modified content)" output
t/t7508-status.sh +65 -50
371 lines not on this page · raw message
wt-status.c +43 -43
197 lines not on this page · raw message
Signature · 1 line
1.7.2.3
PATCH v4 55/73 gettextize: git-status "nothing to commit" messages
In reply to Junio C HamanoGettextize the "nothing to commit" messages. Many tests explicitly checked for this message. Change them to skip under GETTEXT_POISON=YesPlease.
--- t/t7506-status-submodule.sh | 8 ++++---- wt-status.c | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-)
t/t7506-status-submodule.sh +4 -4
@@ -20,12 +20,12 @@ test_expect_success 'setup' ' git commit -m "Add submodule sub" ' -test_expect_success 'status clean' ' +test_expect_success C_LOCALE_OUTPUT 'status clean' ' git status >output && grep "nothing to commit" output ' -test_expect_success 'commit --dry-run -a clean' ' +test_expect_success C_LOCALE_OUTPUT 'commit --dry-run -a clean' ' test_must_fail git commit --dry-run -a >output && grep "nothing to commit" output '
@@ -177,12 +177,12 @@ test_expect_success 'rm submodule contents' ' rm -rf sub/* sub/.git ' -test_expect_success 'status clean (empty submodule dir)' ' +test_expect_success C_LOCALE_OUTPUT 'status clean (empty submodule dir)' ' git status >output && grep "nothing to commit" output ' -test_expect_success 'status -a clean (empty submodule dir)' ' +test_expect_success C_LOCALE_OUTPUT 'status -a clean (empty submodule dir)' ' test_must_fail git commit --dry-run -a >output && grep "nothing to commit" output '
wt-status.c +6 -6
@@ -689,14 +689,14 @@ void wt_status_print(struct wt_status *s) advice_status_hints ? _(" (use \"git add\" to track)") : ""); else if (s->is_initial) - printf("nothing to commit%s\n", advice_status_hints - ? " (create/copy files and use \"git add\" to track)" : ""); + printf(_("nothing to commit%s\n"), advice_status_hints + ? _(" (create/copy files and use \"git add\" to track)") : ""); else if (!s->show_untracked_files) -printf ("nothing to commit%s\n" , advice_status_hints - ?" (use -u to show untracked files)" :"" ); +printf (_ ("nothing to commit%s\n" ), advice_status_hints + ?_ (" (use -u to show untracked files)" ) :"" ); else - printf("nothing to commit%s\n", advice_status_hints - ? " (working directory clean)" : ""); + printf(_("nothing to commit%s\n"), advice_status_hints + ? _(" (working directory clean)") : ""); } }
Signature · 1 line
1.7.2.3
PATCH v4 56/73 gettextize: git-status shortstatus messages
In reply to Junio C HamanoMake the messages added in v1.7.2-rc0~54^2~1 translatable. Some of these could use the to be implemented plural support in the gettext library.
--- wt-status.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-)
wt-status.c +6 -6
@@ -804,13 +804,13 @@ static void wt_shortstatus_print_tracking(struct wt_status *s)if (!prefixcmp (branch_name,"refs/heads/" )) branch_name +=11 ;else if (!strcmp (branch_name,"HEAD" )) { - branch_name ="HEAD (no branch)" ; + branch_name =_ ("HEAD (no branch)" ); branch_color_local =color (WT_STATUS_NOBRANCH , s); } branch =branch_get (s->branch +11 );if (s->is_initial) -color_fprintf (s->fp, header_color,"Initial commit on " ); +color_fprintf (s->fp, header_color,_ ("Initial commit on " ));if (!stat_tracking_info (branch, &num_ours, &num_theirs)) {color_fprintf_ln (s->fp, branch_color_local,"%s" , branch_name);
@@ -825,15 +825,15 @@ static void wt_shortstatus_print_tracking(struct wt_status *s)color_fprintf (s->fp, header_color," [" );if (!num_ours) { -color_fprintf (s->fp, header_color,"behind " ); +color_fprintf (s->fp, header_color,_ ("behind " ));color_fprintf (s->fp, branch_color_remote,"%d" , num_theirs); }else if (!num_theirs) { -color_fprintf (s->fp, header_color,"ahead " ); +color_fprintf (s->fp, header_color,_ ("ahead " ));color_fprintf (s->fp, branch_color_local,"%d" , num_ours); }else { -color_fprintf (s->fp, header_color,"ahead " ); +color_fprintf (s->fp, header_color,_ ("ahead " ));color_fprintf (s->fp, branch_color_local,"%d" , num_ours); -color_fprintf (s->fp, header_color,", behind " ); +color_fprintf (s->fp, header_color,_ (", behind " ));color_fprintf (s->fp, branch_color_remote,"%d" , num_theirs); }
Signature · 1 line
1.7.2.3
PATCH v4 57/73 gettextize: git-status "Changes to be committed" message
In reply to Junio C HamanoGettextize the "# Changes to be committed:" messages. Several tests explicitly checked for this message. Change them to skip under GETTEXT_POISON=YesPlease.
Since these tests didn't check for the rest of the git-status(1) output this change has been split up from the "git-status basic messages" patch.
--- t/t7502-commit.sh | 20 ++++++++++---------- wt-status.c | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-)
t/t7502-commit.sh +10 -10
@@ -384,66 +384,66 @@ try_commit () { try_commit_status_combo () { - test_expect_success 'commit' ' + test_expect_success C_LOCALE_OUTPUT 'commit' ' clear_config commit.status && try_commit "" && grep "^# Changes to be committed:" .git/COMMIT_EDITMSG ' - test_expect_success 'commit' ' + test_expect_success C_LOCALE_OUTPUT 'commit' ' clear_config commit.status && try_commit "" && grep "^# Changes to be committed:" .git/COMMIT_EDITMSG ' - test_expect_success 'commit --status' ' + test_expect_success C_LOCALE_OUTPUT 'commit --status' ' clear_config commit.status && try_commit --status && grep "^# Changes to be committed:" .git/COMMIT_EDITMSG ' - test_expect_success 'commit --no-status' ' + test_expect_success C_LOCALE_OUTPUT 'commit --no-status' ' clear_config commit.status && try_commit --no-status && ! grep "^# Changes to be committed:" .git/COMMIT_EDITMSG ' - test_expect_success 'commit with commit.status = yes' ' + test_expect_success C_LOCALE_OUTPUT 'commit with commit.status = yes' ' clear_config commit.status && git config commit.status yes && try_commit "" && grep "^# Changes to be committed:" .git/COMMIT_EDITMSG ' - test_expect_success 'commit with commit.status = no' ' + test_expect_success C_LOCALE_OUTPUT 'commit with commit.status = no' ' clear_config commit.status && git config commit.status no && try_commit "" && ! grep "^# Changes to be committed:" .git/COMMIT_EDITMSG ' - test_expect_success 'commit --status with commit.status = yes' ' + test_expect_success C_LOCALE_OUTPUT 'commit --status with commit.status = yes' ' clear_config commit.status && git config commit.status yes && try_commit --status && grep "^# Changes to be committed:" .git/COMMIT_EDITMSG ' - test_expect_success 'commit --no-status with commit.status = yes' ' + test_expect_success C_LOCALE_OUTPUT 'commit --no-status with commit.status = yes' ' clear_config commit.status && git config commit.status yes && try_commit --no-status && ! grep "^# Changes to be committed:" .git/COMMIT_EDITMSG ' - test_expect_success 'commit --status with commit.status = no' ' + test_expect_success C_LOCALE_OUTPUT 'commit --status with commit.status = no' ' clear_config commit.status && git config commit.status no && try_commit --status && grep "^# Changes to be committed:" .git/COMMIT_EDITMSG ' - test_expect_success 'commit --no-status with commit.status = no' ' + test_expect_success C_LOCALE_OUTPUT 'commit --no-status with commit.status = no' ' clear_config commit.status && git config commit.status no && try_commit --no-status &&
wt-status.c +1 -1
@@ -74,7 +74,7 @@ static void wt_status_print_cached_header(struct wt_status *s) {const char *c =color (WT_STATUS_HEADER , s); -color_fprintf_ln (s->fp, c,"# Changes to be committed:" ); +color_fprintf_ln (s->fp, c,_ ("# Changes to be committed:" ));if (!advice_status_hints)return ;if (s->in_merge)
Signature · 1 line
1.7.2.3
PATCH v4 58/73 gettextize: git-status "Initial commit" message
In reply to Junio C HamanoGettextize the "# Initial commit" message. A test in t7501-commit.sh explicitly checked for this message. Change it to skip under GETTEXT_POISON=YesPlease.
--- t/t7501-commit.sh | 7 +++++-- wt-status.c | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-)
t/t7501-commit.sh +5 -2
@@ -14,8 +14,11 @@ test_tick test_expect_success \ "initial status" \ "echo 'bongo bongo' >file && - git add file && \ - git status | grep 'Initial commit'" + git add file" + +test_expect_success C_LOCALE_OUTPUT \ + "Constructing initial commit" \ + "git status | grep 'Initial commit'" test_expect_success \ "fail initial amend" \
wt-status.c +1 -1
@@ -651,7 +651,7 @@ void wt_status_print(struct wt_status *s)if (s->is_initial) {color_fprintf_ln (s->fp,color (WT_STATUS_HEADER , s),"#" ); -color_fprintf_ln (s->fp,color (WT_STATUS_HEADER , s),"# Initial commit" ); +color_fprintf_ln (s->fp,color (WT_STATUS_HEADER , s),_ ("# Initial commit" ));color_fprintf_ln (s->fp,color (WT_STATUS_HEADER , s),"#" ); }
Signature · 1 line
1.7.2.3
PATCH v4 59/73 gettextize: git-status "renamed: " message
In reply to Junio C HamanoGettextize the "renamed: %s -> %s" message which appears as part of git-status(1) output. Two tests in t4001-diff-rename.sh explicitly checked for this message. Change them to skip under GETTEXT_POISON=YesPlease.
--- t/t4001-diff-rename.sh | 4 ++-- wt-status.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
t/t4001-diff-rename.sh +2 -2
@@ -64,7 +64,7 @@ test_expect_success \ 'validate the output.' \ 'compare_diff_patch current expected' -test_expect_success 'favour same basenames over different ones' ' +test_expect_success C_LOCALE_OUTPUT 'favour same basenames over different ones' ' cp path1 another-path && git add another-path && git commit -m 1 &&
@@ -73,7 +73,7 @@ test_expect_success 'favour same basenames over different ones' ' git mv another-path subdir/path1 && git status | grep "renamed: .*path1 -> subdir/path1"' -test_expect_success 'favour same basenames even with minor differences' ' +test_expect_success C_LOCALE_OUTPUT 'favour same basenames even with minor differences' ' git show HEAD:path1 | sed "s/15/16/" > subdir/path1 && git status | grep "renamed: .*path1 -> subdir/path1"'
wt-status.c +1 -1
@@ -201,7 +201,7 @@ static void wt_status_print_change_data(struct wt_status *s,color_fprintf (s->fp, c,_ ("modified: %s" ), one);break ;case DIFF_STATUS_RENAMED : -color_fprintf (s->fp, c,"renamed: %s -> %s" , one, two); +color_fprintf (s->fp, c,_ ("renamed: %s -> %s" ), one, two);break ;case DIFF_STATUS_TYPE_CHANGED :color_fprintf (s->fp, c,_ ("typechange: %s" ), one);
Signature · 1 line
1.7.2.3
PATCH v4 60/73 gettextize: git-archive basic messages
In reply to Junio C Hamano--- builtin/archive.c | 14 +++++++------- 1 files changed, 7 insertions(+), 7 deletions(-)
builtin/archive.c +7 -7
@@ -14,10 +14,10 @@ static void create_output_file(const char *output_file) {int output_fd =open (output_file,O_CREAT |O_WRONLY |O_TRUNC ,0666 );if (output_fd <0 ) -die_errno ("could not create archive file '%s'" , output_file); +die_errno (_ ("could not create archive file '%s'" ), output_file);if (output_fd !=1 ) {if (dup2 (output_fd,1 ) <0 ) -die_errno ("could not redirect output" ); +die_errno (_ ("could not redirect output" ));else close (output_fd); }
@@ -33,7 +33,7 @@ static int run_remote_archiver(int argc, const char **argv, _remote =remote_get (remote);if (!_remote->url[0 ]) -die ("git archive: Remote with no URL" ); +die (_ ("git archive: Remote with no URL" )); transport =transport_get (_remote, _remote->url[0 ]);transport_connect (transport,"git-upload-archive" , exec, fd);
@@ -43,18 +43,18 @@ static int run_remote_archiver(int argc, const char **argv, len =packet_read_line (fd[0 ], buf,sizeof (buf));if (!len) -die ("git archive: expected ACK/NAK, got EOF" ); +die (_ ("git archive: expected ACK/NAK, got EOF" ));if (buf[len-1 ] =='\n' ) buf[--len] =0 ;if (strcmp (buf,"ACK" )) {if (len >5 && !prefixcmp (buf,"NACK " )) -die ("git archive: NACK %s" , buf +5 ); -die ("git archive: protocol error" ); +die (_ ("git archive: NACK %s" ), buf +5 ); +die (_ ("git archive: protocol error" )); } len =packet_read_line (fd[0 ], buf,sizeof (buf));if (len) -die ("git archive: expected a flush" ); +die (_ ("git archive: expected a flush" ));/* Now, start reading from fd[0] and spit it out to stdout */ rv =recv_sideband ("archive" , fd[0 ],1 );
Signature · 1 line
1.7.2.3
PATCH v4 61/73 gettextize: git-bundle basic messages
In reply to Junio C Hamano--- builtin/bundle.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
builtin/bundle.c +3 -3
@@ -44,7 +44,7 @@ int cmd_bundle(int argc, const char **argv, const char *prefix)close (bundle_fd);if (verify_bundle (&header,1 ))return 1 ; -fprintf (stderr,"%s is okay\n" , bundle_file); +fprintf (stderr,_ ("%s is okay\n" ), bundle_file);return 0 ; }if (!strcmp (cmd,"list-heads" )) {
@@ -53,11 +53,11 @@ int cmd_bundle(int argc, const char **argv, const char *prefix) }if (!strcmp (cmd,"create" )) {if (!startup_info->have_repository) -die ("Need a repository to create a bundle." ); +die (_ ("Need a repository to create a bundle." ));return !!create_bundle (&header, bundle_file, argc, argv); }else if (!strcmp (cmd,"unbundle" )) {if (!startup_info->have_repository) -die ("Need a repository to unbundle." ); +die (_ ("Need a repository to unbundle." ));return !!unbundle (&header, bundle_fd) ||list_bundle_refs (&header, argc, argv); }else
Signature · 1 line
1.7.2.3
PATCH v4 62/73 gettextize: git-clean basic messages
In reply to Junio C Hamano--- builtin/clean.c | 20 ++++++++++---------- t/t7012-skip-worktree-writing.sh | 4 ++-- t/t7300-clean.sh | 6 +++--- 3 files changed, 15 insertions(+), 15 deletions(-)
builtin/clean.c +10 -10
@@ -75,7 +75,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix) dir.flags |=DIR_SHOW_IGNORED ;if (ignored && ignored_only) -die ("-x and -X cannot be used together" ); +die (_ ("-x and -X cannot be used together" ));if (!show_only && !force) die("clean.requireForce %s to true and neither -n nor -f given; "
@@ -87,7 +87,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix) dir.flags |=DIR_SHOW_OTHER_DIRECTORIES ;if (read_cache () <0 ) -die ("index file corrupt" ); +die (_ ("index file corrupt" ));if (!ignored)setup_standard_excludes (&dir);
@@ -146,20 +146,20 @@ int cmd_clean(int argc, const char **argv, const char *prefix) qname =quote_path_relative (directory.buf, directory.len, &buf, prefix);if (show_only && (remove_directories || (matches ==MATCHED_EXACTLY ))) { -printf ("Would remove %s\n" , qname); +printf (_ ("Would remove %s\n" ), qname); }else if (remove_directories || (matches ==MATCHED_EXACTLY )) {if (!quiet) -printf ("Removing %s\n" , qname); +printf (_ ("Removing %s\n" ), qname);if (remove_dir_recursively (&directory, rm_flags) !=0 ) { -warning ("failed to remove %s" , qname); +warning (_ ("failed to remove %s" ), qname); errors++; } }else if (show_only) { -printf ("Would not remove %s\n" , qname); +printf (_ ("Would not remove %s\n" ), qname); }else { -printf ("Not removing %s\n" , qname); +printf (_ ("Not removing %s\n" ), qname); }strbuf_reset (&directory); }else {
@@ -167,13 +167,13 @@ int cmd_clean(int argc, const char **argv, const char *prefix)continue ; qname =quote_path_relative (ent->name,-1 , &buf, prefix);if (show_only) { -printf ("Would remove %s\n" , qname); +printf (_ ("Would remove %s\n" ), qname);continue ; }else if (!quiet) { -printf ("Removing %s\n" , qname); +printf (_ ("Removing %s\n" ), qname); }if (unlink (ent->name) !=0 ) { -warning ("failed to remove %s" , qname); +warning (_ ("failed to remove %s" ), qname); errors++; } }
t/t7012-skip-worktree-writing.sh +2 -2
@@ -124,13 +124,13 @@ cat >expected <<EOF Would remove expected Would remove result EOF -test_expect_success 'git-clean, absent case' ' +test_expect_success C_LOCALE_OUTPUT 'git-clean, absent case' ' setup_absent && git clean -n > result && test_cmp expected result ' -test_expect_success 'git-clean, dirty case' ' +test_expect_success C_LOCALE_OUTPUT 'git-clean, dirty case' ' setup_dirty && git clean -n > result && test_cmp expected result
t/t7300-clean.sh +3 -3
@@ -110,7 +110,7 @@ test_expect_success 'git clean with prefix' ' ' -test_expect_success 'git clean with relative prefix' ' +test_expect_success C_LOCALE_OUTPUT 'git clean with relative prefix' ' mkdir -p build docs && touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
@@ -125,7 +125,7 @@ test_expect_success 'git clean with relative prefix' ' } ' -test_expect_success 'git clean with absolute path' ' +test_expect_success C_LOCALE_OUTPUT 'git clean with absolute path' ' mkdir -p build docs && touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
@@ -377,7 +377,7 @@ test_expect_success 'clean.requireForce and -f' ' ' -test_expect_success 'core.excludesfile' ' +test_expect_success C_LOCALE_OUTPUT 'core.excludesfile' ' echo excludes >excludes && echo included >included &&
Signature · 1 line
1.7.2.3
PATCH v4 63/73 gettextize: git-clean clean.requireForce messages
In reply to Junio C HamanoSplit up the "clean.requireForce set/defaults to true..." die() message to make it easier to translate.
--- builtin/clean.c | 11 ++++++++--- 1 files changed, 8 insertions(+), 3 deletions(-)
builtin/clean.c +8 -3
@@ -77,9 +77,14 @@ int cmd_clean(int argc, const char **argv, const char *prefix)if (ignored && ignored_only)die (_ ("-x and -X cannot be used together" )); -if (!show_only && !force) -die ("clean.requireForce %s to true and neither -n nor -f given; " -"refusing to clean" , config_set ?"set" :"defaults" ); +if (!show_only && !force) { +if (config_set) +die (_ ("clean.requireForce set to true and neither -n nor -f given; " +"refusing to clean" )); +else +die (_ ("clean.requireForce defaults to true and neither -n nor -f given; " +"refusing to clean" )); + }if (force >1 ) rm_flags =0 ;
Signature · 1 line
1.7.2.3
PATCH v4 64/73 gettextize: git-describe basic messages
In reply to Junio C Hamano--- builtin/describe.c | 36 ++++++++++++++++++------------------ t/t6120-describe.sh | 2 +- 2 files changed, 19 insertions(+), 19 deletions(-)
builtin/describe.c +18 -18
@@ -231,13 +231,13 @@ static void display_name(struct commit_name *n)if (n->prio ==2 && !n->tag) { n->tag =lookup_tag (n->sha1);if (!n->tag ||parse_tag (n->tag)) -die ("annotated tag %s not available" , n->path); +die (_ ("annotated tag %s not available" ), n->path); }if (n->tag && !n->name_checked) {if (!n->tag->tag) -die ("annotated tag %s has no embedded name" , n->path); +die (_ ("annotated tag %s has no embedded name" ), n->path);if (strcmp (n->tag->tag, all ? n->path +5 : n->path)) -warning ("tag '%s' is really '%s' here" , n->tag->tag, n->path); +warning (_ ("tag '%s' is really '%s' here" ), n->tag->tag, n->path); n->name_checked =1 ; }
@@ -264,10 +264,10 @@ static void describe(const char *arg, int last_one)unsigned int unannotated_cnt =0 ;if (get_sha1 (arg, sha1)) -die ("Not a valid object name %s" , arg); +die (_ ("Not a valid object name %s" ), arg); cmit =lookup_commit_reference (sha1);if (!cmit) -die ("%s is not a valid '%s' object" , arg, commit_type); +die (_ ("%s is not a valid '%s' object" ), arg, commit_type); n =find_commit_name (cmit->object.sha1);if (n && (tags || all || n->prio ==2 )) {
@@ -284,9 +284,9 @@ static void describe(const char *arg, int last_one) }if (!max_candidates) -die ("no tag exactly matches '%s'" ,sha1_to_hex (cmit->object.sha1)); +die (_ ("no tag exactly matches '%s'" ),sha1_to_hex (cmit->object.sha1));if (debug) -fprintf (stderr,"searching to describe %s\n" , arg); +fprintf (stderr,_ ("searching to describe %s\n" ), arg);if (!have_util) {for_each_hash (&names, set_util);
@@ -326,7 +326,7 @@ static void describe(const char *arg, int last_one) }if (annotated_cnt && !list) {if (debug) -fprintf (stderr,"finished search at %s\n" , +fprintf (stderr,_ ("finished search at %s\n" ),sha1_to_hex (c->object.sha1));break ; }
@@ -350,12 +350,12 @@ static void describe(const char *arg, int last_one)return ; }if (unannotated_cnt) -die ("No annotated tags can describe '%s'.\n" -"However, there were unannotated tags: try --tags." , +die (_ ("No annotated tags can describe '%s'.\n" +"However, there were unannotated tags: try --tags." ),sha1_to_hex (sha1));else -die ("No tags can describe '%s'.\n" -"Try --always, or create some tags." , +die (_ ("No tags can describe '%s'.\n" +"Try --always, or create some tags." ),sha1_to_hex (sha1)); }
@@ -375,11 +375,11 @@ static void describe(const char *arg, int last_one) prio_names[t->name->prio], t->depth, t->name->path); } -fprintf (stderr,"traversed %lu commits\n" , seen_commits); +fprintf (stderr,_ ("traversed %lu commits\n" ), seen_commits);if (gave_up_on) {fprintf (stderr, -"more than %i tags found; listed %i most recent\n" -"gave up search at %s\n" , +_ ("more than %i tags found; listed %i most recent\n" +"gave up search at %s\n" ), max_candidates, max_candidates,sha1_to_hex (gave_up_on->object.sha1)); }
@@ -429,7 +429,7 @@ int cmd_describe(int argc, const char **argv, const char *prefix) save_commit_buffer =0 ;if (longformat && abbrev ==0 ) -die ("--long is incompatible with --abbrev=0" ); +die (_ ("--long is incompatible with --abbrev=0" ));if (contains) {const char **args =xmalloc ((7 + argc) *sizeof (char *));
@@ -455,14 +455,14 @@ int cmd_describe(int argc, const char **argv, const char *prefix)init_hash (&names);for_each_rawref (get_name,NULL );if (!names.nr && !always) -die ("No names found, cannot describe anything." ); +die (_ ("No names found, cannot describe anything." ));if (argc ==0 ) {if (dirty && !cmd_diff_index (ARRAY_SIZE (diff_index_args) -1 , diff_index_args, prefix)) dirty =NULL ;describe ("HEAD" ,1 ); }else if (dirty) { -die ("--dirty is incompatible with committishes" ); +die (_ ("--dirty is incompatible with committishes" )); }else {while (argc-- >0 ) {describe (*argv++, argc ==0 );
t/t6120-describe.sh +1 -1
@@ -123,7 +123,7 @@ cat - >err.expect <<EOF warning: tag 'A' is really 'Q' here EOF check_describe A-* HEAD -test_expect_success 'warning was displayed for Q' ' +test_expect_success C_LOCALE_OUTPUT 'warning was displayed for Q' ' test_cmp err.expect err.actual ' test_expect_success 'rename tag Q back to A' '
Signature · 1 line
1.7.2.3
Re: [PATCH v4 64/73] gettextize: git-describe basic messages
Quoted 5 lines · Ævar Arnfjörð Bjarmason
if (
strcmp(n->tag->tag, all ? n->path + 5 : n->path))
- warning("tag '%s' is really '%s' here",n->tag->tag,n->path); + warning(_("tag '%s' is really '%s' here"),n->tag->tag,n->path);n->name_checked= 1;
}
Don't we need to use order notation to be able to change order of those two parameters, i.e. use
+ warning(_("tag '%1$s' is really '%2$s' here"), n->tag->tag, n->path);
Perhaps also some comment for translators describing placeholders?
Signature · 2 lines
Jakub Narebski Poland
Re: [PATCH v4 64/73] gettextize: git-describe basic messages
Quoted 4 lines · Jakub Narebski
Don't we need to use order notation to be able to change order of those two parameters, i.e. use
+
warning(_("tag '%1$s' is really '%2$s' here"), n->tag->tag, n->path);
Yes, translators to languages that want to swap orders would need to know about the placeholder notation; the canonical C locale messages you see in these patches do not have to have them, though.
Re: [PATCH v4 64/73] gettextize: git-describe basic messages
In reply to Jakub NarebskiQuoted 8 lines · Jakub Narebski
Quoted 5 lines · Ævar Arnfjörð Bjarmason
if (
strcmp(n->tag->tag, all ? n->path + 5 : n->path))
- warning("tag '%s' is really '%s' here",n->tag->tag,n->path); + warning(_("tag '%s' is really '%s' here"),n->tag->tag,n->path);n->name_checked= 1;
}
Quoted 6 lines
Don't we need to use order notation to be able to change order of those two parameters, i.e. use
+
warning(_("tag '%1$s' is really '%2$s' here"), n->tag->tag, n->path);Perhaps also some comment for translators describing placeholders?
No, the original string doesn't need those. But the translators can insert them in their PO file if they want.
PATCH v4 65/73 gettextize: git-gc basic messages
In reply to Junio C Hamano--- builtin/gc.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-)
builtin/gc.c +5 -5
@@ -60,7 +60,7 @@ static int gc_config(const char *var, const char *value, void *cb)if (value &&strcmp (value,"now" )) {unsigned long now =approxidate ("now" );if (approxidate (value) >= now) -return error ("Invalid %s: '%s'" , var, value); +return error (_ ("Invalid %s: '%s'" ), var, value); }return git_config_string (&prune_expire, var, value); }
@@ -75,7 +75,7 @@ static void append_option(const char **cmd, const char *opt, int max_length) ;if (i +2 >= max_length) -die ("Too many options specified" ); +die (_ ("Too many options specified" )); cmd[i++] = opt; cmd[i] =NULL ; }
@@ -100,7 +100,7 @@ static int too_many_loose_objects(void)return 0 ;if (sizeof (path) <=snprintf (path,sizeof (path),"%s/17" , objdir)) { -warning ("insanely long object directory %.*s" ,50 , objdir); +warning (_ ("insanely long object directory %.*s" ),50 , objdir);return 0 ; } dir =opendir (path);
@@ -251,8 +251,8 @@ int cmd_gc(int argc, const char **argv, const char *prefix)return error (FAILED_RUN , argv_rerere[0 ]);if (auto_gc &&too_many_loose_objects ()) -warning ("There are too many unreachable loose objects; " -"run 'git prune' to remove them." ); +warning (_ ("There are too many unreachable loose objects; " +"run 'git prune' to remove them." ));return 0 ; }
Signature · 1 line
1.7.2.3
PATCH v4 66/73 gettextize: git-gc "Auto packing the repository" message
In reply to Junio C HamanoSplit up the "Auto packing the repository" message into quiet and verbose variants to make translation easier.
--- builtin/gc.c | 14 +++++++------- 1 files changed, 7 insertions(+), 7 deletions(-)
builtin/gc.c +7 -7
@@ -219,13 +219,13 @@ int cmd_gc(int argc, const char **argv, const char *prefix)*/ if (!need_to_gc ())return 0 ; -fprintf (stderr, -"Auto packing the repository for optimum performance.%s\n" , - quiet - ?"" - : (" You may also\n" -"run \"git gc\" manually. See " -"\"git help gc\" for more information." )); +if (quiet) +fprintf (stderr,_ ("Auto packing the repository for optimum performance.\n" )); +else +fprintf (stderr, +_ ("Auto packing the repository for optimum performance. You may also\n" +"run \"git gc\" manually. See " +"\"git help gc\" for more information." )); }else append_option (argv_repack, prune_expire && !strcmp(prune_expire, "now")
Signature · 1 line
1.7.2.3
PATCH v4 67/73 gettextize: git-notes basic commands
In reply to Junio C Hamano--- builtin/notes.c | 106 +++++++++++++++++++++++++++--------------------------- 1 files changed, 53 insertions(+), 53 deletions(-)
builtin/notes.c +53 -53
@@ -146,13 +146,13 @@ static void write_commented_object(int fd, const unsigned char *object) show.err =0 ; show.git_cmd =1 ;if (start_command (&show)) -die ("unable to start 'show' for object '%s'" , +die (_ ("unable to start 'show' for object '%s'" ),sha1_to_hex (object));/* Open the output as FILE* so strbuf_getline() can be used. */ show_out =xfdopen (show.out,"r" );if (show_out ==NULL ) -die_errno ("can't fdopen 'show' output fd" ); +die_errno (_ ("can't fdopen 'show' output fd" ));/* Prepend "# " to each output line and write result to 'fd' */ while (strbuf_getline (&buf, show_out,'\n' ) !=EOF ) {
@@ -162,10 +162,10 @@ static void write_commented_object(int fd, const unsigned char *object) }strbuf_release (&buf);if (fclose (show_out)) -die_errno ("failed to close pipe to 'show' for object '%s'" , +die_errno (_ ("failed to close pipe to 'show' for object '%s'" ),sha1_to_hex (object));if (finish_command (&show)) -die ("failed to finish 'show' for object '%s'" , +die (_ ("failed to finish 'show' for object '%s'" ),sha1_to_hex (object)); }
@@ -182,7 +182,7 @@ static void create_note(const unsigned char *object, struct msg_arg *msg, path =git_pathdup ("NOTES_EDITMSG" ); fd =open (path,O_CREAT |O_TRUNC |O_WRONLY ,0600 );if (fd <0 ) -die_errno ("could not create file '%s'" , path); +die_errno (_ ("could not create file '%s'" ), path);if (msg->given)write_or_die (fd, msg->buf.buf, msg->buf.len);
@@ -196,8 +196,8 @@ static void create_note(const unsigned char *object, struct msg_arg *msg,strbuf_reset (&(msg->buf));if (launch_editor (path, &(msg->buf),NULL )) { -die ("Please supply the note contents using either -m" \ -" or -F option" ); +die (_ ("Please supply the note contents using either -m" \ +" or -F option" )); }stripspace (&(msg->buf),1 ); }
@@ -217,14 +217,14 @@ static void create_note(const unsigned char *object, struct msg_arg *msg, }if (!msg->buf.len) { -fprintf (stderr,"Removing note for object %s\n" , +fprintf (stderr,_ ("Removing note for object %s\n" ),sha1_to_hex (object));hashclr (result); }else {if (write_sha1_file (msg->buf.buf, msg->buf.len, blob_type, result)) { -error ("unable to write note object" ); +error (_ ("unable to write note object" ));if (path) -error ("The note contents has been left in %s" , +error (_ ("The note contents has been left in %s" ), path);exit (128 ); }
@@ -258,9 +258,9 @@ static int parse_file_arg(const struct option *opt, const char *arg, int unset)strbuf_addch (&(msg->buf),'\n' );if (!strcmp (arg,"-" )) {if (strbuf_read (&(msg->buf),0 ,1024 ) <0 ) -die_errno ("cannot read '%s'" , arg); +die_errno (_ ("cannot read '%s'" ), arg); }else if (strbuf_read_file (&(msg->buf), arg,1024 ) <0 ) -die_errno ("could not open or read '%s'" , arg); +die_errno (_ ("could not open or read '%s'" ), arg);stripspace (&(msg->buf),0 ); msg->given =1 ;
@@ -279,10 +279,10 @@ static int parse_reuse_arg(const struct option *opt, const char *arg, int unset)strbuf_addch (&(msg->buf),'\n' );if (get_sha1 (arg, object)) -die ("Failed to resolve '%s' as a valid ref." , arg); +die (_ ("Failed to resolve '%s' as a valid ref." ), arg);if (!(buf =read_sha1_file (object, &type, &len)) || !len) {free (buf); -die ("Failed to read object '%s'." , arg);; +die (_ ("Failed to read object '%s'." ), arg);; }strbuf_add (&(msg->buf), buf, len);free (buf);
@@ -306,7 +306,7 @@ void commit_notes(struct notes_tree *t, const char *msg)if (!t) t = &default_notes_tree;if (!t->initialized || !t->ref || !*t->ref) -die ("Cannot commit uninitialized/unreferenced notes tree" ); +die (_ ("Cannot commit uninitialized/unreferenced notes tree" ));if (!t->dirty)return ;/* don't have to commit an unchanged tree */
@@ -347,7 +347,7 @@ static int notes_rewrite_config(const char *k, const char *v, void *cb)config_error_nonbool (k); c->combine =parse_combine_notes_fn (v);if (!c->combine) { -error ("Bad notes.rewriteMode value: '%s'" , v); +error (_ ("Bad notes.rewriteMode value: '%s'" ), v);return 1 ; }return 0 ;
@@ -357,8 +357,8 @@ static int notes_rewrite_config(const char *k, const char *v, void *cb)if (!prefixcmp (v,"refs/notes/" ))string_list_add_refs_by_glob (c->refs, v);else -warning ("Refusing to rewrite notes in %s" -" (outside of refs/notes/)" , v); +warning (_ ("Refusing to rewrite notes in %s" +" (outside of refs/notes/)" ), v);return 0 ; }
@@ -446,13 +446,13 @@ int notes_copy_from_stdin(int force, const char *rewrite_cmd) split =strbuf_split (&buf,' ' );if (!split[0 ] || !split[1 ]) -die ("Malformed input line: '%s'." , buf.buf); +die (_ ("Malformed input line: '%s'." ), buf.buf);strbuf_rtrim (split[0 ]);strbuf_rtrim (split[1 ]);if (get_sha1 (split[0 ]->buf, from_obj)) -die ("Failed to resolve '%s' as a valid ref." , split[0 ]->buf); +die (_ ("Failed to resolve '%s' as a valid ref." ), split[0 ]->buf);if (get_sha1 (split[1 ]->buf, to_obj)) -die ("Failed to resolve '%s' as a valid ref." , split[1 ]->buf); +die (_ ("Failed to resolve '%s' as a valid ref." ), split[1 ]->buf);if (rewrite_cmd) err =copy_note_for_rewrite (c, from_obj, to_obj);
@@ -461,7 +461,7 @@ int notes_copy_from_stdin(int force, const char *rewrite_cmd) combine_notes_overwrite);if (err) { -error ("Failed to copy notes from '%s' to '%s'" , +error (_ ("Failed to copy notes from '%s' to '%s'" ), split[0 ]->buf, split[1 ]->buf); ret =1 ; }
@@ -505,20 +505,20 @@ static int list(int argc, const char **argv, const char *prefix) git_notes_list_usage, 0);if (1 < argc) { -error ("too many parameters" ); +error (_ ("too many parameters" ));usage_with_options (git_notes_list_usage, options); } t =init_notes_check ("list" );if (argc) {if (get_sha1 (argv[0 ], object)) -die ("Failed to resolve '%s' as a valid ref." , argv[0 ]); +die (_ ("Failed to resolve '%s' as a valid ref." ), argv[0 ]); note =get_note (t, object);if (note) {puts (sha1_to_hex (note)); retval =0 ; }else - retval =error ("No note found for object %s." , + retval =error (_ ("No note found for object %s." ),sha1_to_hex (object)); }else retval =for_each_note (t,0 , list_each_note,NULL );
@@ -557,26 +557,26 @@ static int add(int argc, const char **argv, const char *prefix) 0);if (1 < argc) { -error ("too many parameters" ); +error (_ ("too many parameters" ));usage_with_options (git_notes_add_usage, options); } object_ref = argc ? argv[0 ] :"HEAD" ;if (get_sha1 (object_ref, object)) -die ("Failed to resolve '%s' as a valid ref." , object_ref); +die (_ ("Failed to resolve '%s' as a valid ref." ), object_ref); t =init_notes_check ("add" ); note =get_note (t, object);if (note) {if (!force) { - retval =error ("Cannot add notes. Found existing notes " + retval =error (_ ("Cannot add notes. Found existing notes " "for object %s. Use '-f' to overwrite " -"existing notes" ,sha1_to_hex (object)); +"existing notes" ),sha1_to_hex (object)); goto out; } -fprintf (stderr,"Overwriting existing notes for object %s\n" , +fprintf (stderr,_ ("Overwriting existing notes for object %s\n" ),sha1_to_hex (object)); }
@@ -618,7 +618,7 @@ static int copy(int argc, const char **argv, const char *prefix)if (from_stdin || rewrite_cmd) {if (argc) { -error ("too many parameters" ); +error (_ ("too many parameters" ));usage_with_options (git_notes_copy_usage, options); }else {return notes_copy_from_stdin (force, rewrite_cmd);
@@ -626,41 +626,41 @@ static int copy(int argc, const char **argv, const char *prefix) }if (argc <2 ) { -error ("too few parameters" ); +error (_ ("too few parameters" ));usage_with_options (git_notes_copy_usage, options); }if (2 < argc) { -error ("too many parameters" ); +error (_ ("too many parameters" ));usage_with_options (git_notes_copy_usage, options); }if (get_sha1 (argv[0 ], from_obj)) -die ("Failed to resolve '%s' as a valid ref." , argv[0 ]); +die (_ ("Failed to resolve '%s' as a valid ref." ), argv[0 ]); object_ref =1 < argc ? argv[1 ] :"HEAD" ;if (get_sha1 (object_ref, object)) -die ("Failed to resolve '%s' as a valid ref." , object_ref); +die (_ ("Failed to resolve '%s' as a valid ref." ), object_ref); t =init_notes_check ("copy" ); note =get_note (t, object);if (note) {if (!force) { - retval =error ("Cannot copy notes. Found existing " + retval =error (_ ("Cannot copy notes. Found existing " "notes for object %s. Use '-f' to " -"overwrite existing notes" , +"overwrite existing notes" ),sha1_to_hex (object)); goto out; } -fprintf (stderr,"Overwriting existing notes for object %s\n" , +fprintf (stderr,_ ("Overwriting existing notes for object %s\n" ),sha1_to_hex (object)); } from_note =get_note (t, from_obj);if (!from_note) { - retval =error ("Missing notes on source object %s. Cannot " -"copy." ,sha1_to_hex (from_obj)); + retval =error (_ ("Missing notes on source object %s. Cannot " +"copy." ),sha1_to_hex (from_obj)); goto out; }
@@ -703,19 +703,19 @@ static int append_edit(int argc, const char **argv, const char *prefix) PARSE_OPT_KEEP_ARGV0);if (2 < argc) { -error ("too many parameters" ); +error (_ ("too many parameters" ));usage_with_options (usage, options); }if (msg.given && edit) -fprintf (stderr,"The -m/-F/-c/-C options have been deprecated " +fprintf (stderr,_ ("The -m/-F/-c/-C options have been deprecated " "for the 'edit' subcommand.\n" -"Please use 'git notes add -f -m/-F/-c/-C' instead.\n" ); +"Please use 'git notes add -f -m/-F/-c/-C' instead.\n" )); object_ref =1 < argc ? argv[1 ] :"HEAD" ;if (get_sha1 (object_ref, object)) -die ("Failed to resolve '%s' as a valid ref." , object_ref); +die (_ ("Failed to resolve '%s' as a valid ref." ), object_ref); t =init_notes_check (argv[0 ]); note =get_note (t, object);
@@ -750,20 +750,20 @@ static int show(int argc, const char **argv, const char *prefix) 0);if (1 < argc) { -error ("too many parameters" ); +error (_ ("too many parameters" ));usage_with_options (git_notes_show_usage, options); } object_ref = argc ? argv[0 ] :"HEAD" ;if (get_sha1 (object_ref, object)) -die ("Failed to resolve '%s' as a valid ref." , object_ref); +die (_ ("Failed to resolve '%s' as a valid ref." ), object_ref); t =init_notes_check ("show" ); note =get_note (t, object);if (!note) - retval =error ("No note found for object %s." , + retval =error (_ ("No note found for object %s." ),sha1_to_hex (object));else {const char *show_args[3 ] = {"show" ,sha1_to_hex (note),NULL };
@@ -961,22 +961,22 @@ static int remove_cmd(int argc, const char **argv, const char *prefix) git_notes_remove_usage, 0);if (1 < argc) { -error ("too many parameters" ); +error (_ ("too many parameters" ));usage_with_options (git_notes_remove_usage, options); } object_ref = argc ? argv[0 ] :"HEAD" ;if (get_sha1 (object_ref, object)) -die ("Failed to resolve '%s' as a valid ref." , object_ref); +die (_ ("Failed to resolve '%s' as a valid ref." ), object_ref); t =init_notes_check ("remove" ); retval =remove_note (t, object);if (retval) -fprintf (stderr,"Object %s has no note\n" ,sha1_to_hex (object)); +fprintf (stderr,_ ("Object %s has no note\n" ),sha1_to_hex (object));else { -fprintf (stderr,"Removing note for object %s\n" , +fprintf (stderr,_ ("Removing note for object %s\n" ),sha1_to_hex (object));commit_notes (t,"Notes removed by 'git notes remove'" );
@@ -999,7 +999,7 @@ static int prune(int argc, const char **argv, const char *prefix) 0);if (argc) { -error ("too many parameters" ); +error (_ ("too many parameters" ));usage_with_options (git_notes_prune_usage, options); }
@@ -1069,7 +1069,7 @@ int cmd_notes(int argc, const char **argv, const char *prefix)else if (!strcmp (argv[0 ],"get-ref" )) result =get_ref (argc, argv, prefix);else { - result =error ("Unknown subcommand: %s" , argv[0 ]); + result =error (_ ("Unknown subcommand: %s" ), argv[0 ]);usage_with_options (git_notes_usage, options); }
Signature · 1 line
1.7.2.3
PATCH v4 68/73 gettextize: git-notes GIT_NOTES_REWRITE_MODE error message
In reply to Junio C HamanoUse sprintf format for the error message that's displayed if GIT_NOTES_REWRITE_MODE is invalid, and leave a note in a TRANSLATORS comment indicating what the message means.
--- builtin/notes.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-)
builtin/notes.c +4 -2
@@ -382,8 +382,10 @@ struct notes_rewrite_cfg *init_copy_notes_for_rewrite(const char *cmd) c->mode_from_env =1 ; c->combine =parse_combine_notes_fn (rewrite_mode_env);if (!c->combine) -error ("Bad " GIT_NOTES_REWRITE_MODE_ENVIRONMENT -" value: '%s'" , rewrite_mode_env); +/* TRANSLATORS: The first %s is the name of the +environment variable, the second %s is its value */ +error (_ ("Bad %s value: '%s'" ),GIT_NOTES_REWRITE_MODE_ENVIRONMENT , + rewrite_mode_env); }if (rewrite_refs_env) { c->refs_from_env =1 ;
Signature · 1 line
1.7.2.3
PATCH v4 69/73 gettextize: git-revert basic messages
In reply to Junio C Hamano--- builtin/revert.c | 46 +++++++++++++++++++++++----------------------- 1 files changed, 23 insertions(+), 23 deletions(-)
builtin/revert.c +23 -23
@@ -96,7 +96,7 @@ static void parse_args(int argc, const char **argv) OPT_END(), };if (parse_options_concat (options,ARRAY_SIZE (options), cp_extra)) -die ("program error" ); +die (_ ("program error" )); } commit_argc = parse_options(argc, argv, NULL, options, usage_str,
@@ -168,7 +168,7 @@ static char *get_encoding(const char *message)const char *p = message, *eol;if (!p) -die ("Could not read commit message of %s" , +die (_ ("Could not read commit message of %s" ),sha1_to_hex (commit->object.sha1));while (*p && *p !='\n' ) {for (eol = p +1 ; *eol && *eol !='\n' ; eol++)
@@ -202,7 +202,7 @@ static void set_author_ident_env(const char *message) {const char *p = message;if (!p) -die ("Could not read commit message of %s" , +die (_ ("Could not read commit message of %s" ),sha1_to_hex (commit->object.sha1));while (*p && *p !='\n' ) {const char *eol;
@@ -216,7 +216,7 @@ static void set_author_ident_env(const char *message) line =xmemdupz (p, eol - p); email =strchr (line,'<' );if (!email) -die ("Could not extract author email from %s" , +die (_ ("Could not extract author email from %s" ),sha1_to_hex (commit->object.sha1));if (email == line) pend = line;
@@ -228,7 +228,7 @@ static void set_author_ident_env(const char *message) email++; timestamp =strchr (email,'>' );if (!timestamp) -die ("Could not extract author time from %s" , +die (_ ("Could not extract author time from %s" ),sha1_to_hex (commit->object.sha1)); *timestamp ='\0' ; for (timestamp++; *timestamp && isspace(*timestamp);
@@ -244,7 +244,7 @@ static void set_author_ident_env(const char *message)if (*p =='\n' ) p++; } -die ("No author information found in %s" , +die (_ ("No author information found in %s" ),sha1_to_hex (commit->object.sha1)); }
@@ -281,10 +281,10 @@ static void write_message(struct strbuf *msgbuf, const char *filename)int msg_fd =hold_lock_file_for_update (&msg_file, filename,LOCK_DIE_ON_ERROR );if (write_in_full (msg_fd, msgbuf->buf, msgbuf->len) <0 ) -die_errno ("Could not write to %s." , filename); +die_errno (_ ("Could not write to %s." ), filename);strbuf_release (msgbuf);if (commit_lock_file (&msg_file) <0 ) -die ("Error wrapping up %s" , filename); +die (_ ("Error wrapping up %s" ), filename); }static struct tree *empty_tree (void )
@@ -420,10 +420,10 @@ static int do_pick_commit(void)* to work on. */ if (write_cache_as_tree (head,0 ,NULL )) -die ("Your index file is unmerged." ); +die (_ ("Your index file is unmerged." )); }else {if (get_sha1 ("HEAD" , head)) -die ("You do not have a valid HEAD" ); +die (_ ("You do not have a valid HEAD" ));if (index_differs_from ("HEAD" ,0 ))die_dirty_index (me); }
@@ -431,7 +431,7 @@ static int do_pick_commit(void)if (!commit->parents) {if (action ==REVERT ) -die ("Cannot revert a root commit" ); +die (_ ("Cannot revert a root commit" )); parent =NULL ; }else if (commit->parents->next) {
@@ -440,7 +440,7 @@ static int do_pick_commit(void)struct commit_list *p;if (!mainline) -die ("Commit %s is a merge but no -m option was given." , +die (_ ("Commit %s is a merge but no -m option was given." ),sha1_to_hex (commit->object.sha1)); for (cnt = 1, p = commit->parents;
@@ -448,11 +448,11 @@ static int do_pick_commit(void) cnt++) p = p->next;if (cnt != mainline || !p) -die ("Commit %s does not have parent %d" , +die (_ ("Commit %s does not have parent %d" ),sha1_to_hex (commit->object.sha1), mainline); parent = p->item; }else if (0 < mainline) -die ("Mainline was specified but commit %s is not a merge." , +die (_ ("Mainline was specified but commit %s is not a merge." ),sha1_to_hex (commit->object.sha1));else parent = commit->parents->item;
@@ -465,7 +465,7 @@ static int do_pick_commit(void) me, sha1_to_hex(parent->object.sha1));if (get_message (commit->buffer, &msg) !=0 ) -die ("Cannot get commit message for %s" , +die (_ ("Cannot get commit message for %s" ),sha1_to_hex (commit->object.sha1));/*
@@ -556,10 +556,10 @@ static void prepare_revs(struct rev_info *revs)usage (*revert_or_cherry_pick_usage ());if (prepare_revision_walk (revs)) -die ("revision walk setup failed" ); +die (_ ("revision walk setup failed" ));if (!revs->commits) -die ("empty commit set passed" ); +die (_ ("empty commit set passed" )); }static void read_and_refresh_cache (const char *me)
@@ -567,12 +567,12 @@ static void read_and_refresh_cache(const char *me)static struct lock_file index_lock;int index_fd =hold_locked_index (&index_lock,0 );if (read_index_preload (&the_index,NULL ) <0 ) -die ("git %s: failed to read the index" , me); +die (_ ("git %s: failed to read the index" ), me);refresh_index (&the_index,REFRESH_QUIET |REFRESH_UNMERGED ,NULL ,NULL ,NULL );if (the_index.cache_changed) {if (write_index (&the_index, index_fd) ||commit_locked_index (&index_lock)) -die ("git %s: failed to refresh the index" , me); +die (_ ("git %s: failed to refresh the index" ), me); }rollback_lock_file (&index_lock); }
@@ -588,13 +588,13 @@ static int revert_or_cherry_pick(int argc, const char **argv)if (allow_ff) {if (signoff) -die ("cherry-pick --ff cannot be used with --signoff" ); +die (_ ("cherry-pick --ff cannot be used with --signoff" ));if (no_commit) -die ("cherry-pick --ff cannot be used with --no-commit" ); +die (_ ("cherry-pick --ff cannot be used with --no-commit" ));if (no_replay) -die ("cherry-pick --ff cannot be used with -x" ); +die (_ ("cherry-pick --ff cannot be used with -x" ));if (edit) -die ("cherry-pick --ff cannot be used with --edit" ); +die (_ ("cherry-pick --ff cannot be used with --edit" )); }read_and_refresh_cache (me);
Signature · 1 line
1.7.2.3
PATCH v4 70/73 gettextize: git-revert "Your local changes" message
In reply to Junio C HamanoTranslate the "Your local changes [...]" message without using the `me' variable, instead split up the two messages so translators can translate the whole messages as-is.
--- builtin/revert.c | 18 +++++++++++++----- t/t3501-revert-cherry-pick.sh | 2 +- 2 files changed, 14 insertions(+), 6 deletions(-)
builtin/revert.c +13 -5
@@ -302,11 +302,19 @@ static NORETURN void die_dirty_index(const char *me)if (read_cache_unmerged ()) {die_resolve_conflict (me); }else { -if (advice_commit_before_merge) -die ("Your local changes would be overwritten by %s.\n" -"Please, commit your changes or stash them to proceed." , me); -else -die ("Your local changes would be overwritten by %s.\n" , me); +if (advice_commit_before_merge) { +if (action ==REVERT ) +die (_ ("Your local changes would be overwritten by revert.\n" +"Please, commit your changes or stash them to proceed." )); +else +die (_ ("Your local changes would be overwritten by cherry-pick.\n" +"Please, commit your changes or stash them to proceed." )); + }else { +if (action ==REVERT ) +die (_ ("Your local changes would be overwritten by revert.\n" )); +else +die (_ ("Your local changes would be overwritten by cherry-pick.\n" )); + } } }
t/t3501-revert-cherry-pick.sh +1 -1
@@ -91,7 +91,7 @@ test_expect_success 'cherry-pick on stat-dirty working tree' ' ) ' -test_expect_success 'revert forbidden on dirty working tree' ' +test_expect_success C_LOCALE_OUTPUT 'revert forbidden on dirty working tree' ' echo content >extra_file && git add extra_file &&
Signature · 1 line
1.7.2.3
PATCH v4 71/73 gettextize: git-revert literal "me" messages
In reply to Junio C HamanoTranslate messages that use the `me' variable. These are all error messages referencing the command name, so the name shouldn't be translated.
--- builtin/revert.c | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-)
builtin/revert.c +5 -2
@@ -362,7 +362,8 @@ static int do_recursive_merge(struct commit *base, struct commit *next,if (active_cache_changed && (write_cache (index_fd, active_cache, active_nr) ||commit_locked_index (&index_lock))) -die ("%s: Unable to write new index file" , me); +/* TRANSLATORS: %s will be "revert" or "cherry-pick" */ +die (_ ("%s: Unable to write new index file" ), me);rollback_lock_file (&index_lock);if (!clean) {
@@ -469,7 +470,9 @@ static int do_pick_commit(void)return fast_forward_to (commit->object.sha1, head);if (parent &&parse_commit (parent) <0 ) -die ("%s: cannot parse parent commit %s" , +/* TRANSLATORS: The first %s will be "revert" or +"cherry-pick", the second %s a SHA1 */ +die (_ ("%s: cannot parse parent commit %s" ), me,sha1_to_hex (parent->object.sha1));if (get_message (commit->buffer, &msg) !=0 )
Signature · 1 line
1.7.2.3
PATCH v4 72/73 gettextize: git-revert split up "could not revert/apply" message
In reply to Junio C HamanoSplit up the "could not %s %s... %s" message into "could not revert %s... %s" and "could not apply %s... %s". This makes it easier for translators to understand the message.
--- builtin/revert.c | 5 +++-- t/t3507-cherry-pick-conflict.sh | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-)
builtin/revert.c +3 -2
@@ -536,8 +536,9 @@ static int do_pick_commit(void) }if (res) { -error ("could not %s %s... %s" , - action ==REVERT ?"revert" :"apply" , +error (action ==REVERT + ?_ ("could not revert %s... %s" ) + :_ ("could not apply %s... %s" ),find_unique_abbrev (commit->object.sha1,DEFAULT_ABBREV ), msg.subject);print_advice ();
t/t3507-cherry-pick-conflict.sh +1 -1
@@ -38,7 +38,7 @@ test_expect_success 'failed cherry-pick does not advance HEAD' ' test "$head" = "$newhead" ' -test_expect_success 'advice from failed cherry-pick' " +test_expect_success C_LOCALE_OUTPUT 'advice from failed cherry-pick' " git checkout -f initial^0 && git read-tree -u --reset HEAD && git clean -d -f -f -q -x &&
Signature · 1 line
1.7.2.3
PATCH v4 73/73 gettextize: git-shortlog basic messages
In reply to Junio C Hamano--- builtin/shortlog.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
builtin/shortlog.c +4 -4
@@ -158,7 +158,7 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit) buffer = eol; }if (!author) -die ("Missing author: %s" , +die (_ ("Missing author: %s" ),sha1_to_hex (commit->object.sha1));if (log->user_format) {struct pretty_print_context ctx = {0 };
@@ -181,7 +181,7 @@ static void get_from_rev(struct rev_info *rev, struct shortlog *log)struct commit *commit;if (prepare_revision_walk (rev)) -die ("revision walk setup failed" ); +die (_ ("revision walk setup failed" ));while ((commit =get_revision (rev)) !=NULL )shortlog_add_commit (log, commit); }
@@ -284,7 +284,7 @@ parse_done: argc =parse_options_end (&ctx);if (setup_revisions (argc, argv, &rev,NULL ) !=1 ) { -error ("unrecognized argument: %s" , argv[1 ]); +error (_ ("unrecognized argument: %s" ), argv[1 ]);usage_with_options (shortlog_usage, options); }
@@ -296,7 +296,7 @@ parse_done:add_head_to_pending (&rev);if (rev.pending.nr ==0 ) {if (isatty (0 )) -fprintf (stderr,"(reading log message from standard input)\n" ); +fprintf (stderr,_ ("(reading log message from standard input)\n" ));read_from_stdin (&log); }else
Signature · 1 line
1.7.2.3