Skip to contentSkip to conversation

No-op C gettext wrappers

PATCH Superseded Ævar Arnfjörð Bjarmason 6 participants 222 messages Jun 15, 2016 Kbuild Page 1 of 2

lore
Share & tools
lore
#0 lore raw

cover No-op C gettext wrappers

As discussed on-list previously I'm remaking the gettext series in a form that'll be easier to swallow. This series is what's at the start of my own ab/i18n branch hosted at git://github.com/avar/git.git.

It only does these:

* A skeleton no-op gettext.h wrapper that does nothing
* Marking up of the relevant source messages so they can be translated
* Marking up and changing tests that would break under GETTEXT_POISON=YesPlease

After this is in I'll submit similar no-op wrappers and gettextization of the *.sh and *.perl files I have gettextized in ab/i18n, after that I'll be trying to get the remaining bits of ab/i18n in, which'll be:

* The actual C, Shell and Perl gettext implementation + tests
* Documentation on how to translate things
* po/*.po files containing translations

Ævar Arnfjörð Bjarmason (72):
gettext.h: add no-op _() and N_() wrappers
cache.h: include gettext.h
t/test-lib.sh: add always-set NO_GETTEXT_POISON prerequisite
gettextize: git-init basic messages
gettextize: git-init "Initialized [...] repository" message
gettextize: git-clone basic messages
gettextize: git-clone "Cloning into" message
gettextize: git-add basic messages
gettextize: git-add "no files added" message
gettextize: git-add "Use -f if you really want" message
gettextize: git-add "pathspec [...] did not match" message
gettextize: git-add "remove '%s'" message
gettextize: git-add refresh_index message
gettextize: git-branch basic messages
gettextize: git-branch "remote branch '%s' not found" message
gettextize: git-branch "Deleted branch [...]" message
gettextize: git-branch "git branch -v" messages
gettextize: git-branch "(no branch)" message
gettextize: git-checkout basic messages
gettextize: git-checkout: our/their version message
gettextize: git-checkout describe_detached_head messages
gettextize: git-checkout "HEAD is now at" message
gettextize: git-checkout "Switched to a .. branch" message
gettextize: git-commit basic messages
gettextize: git-commit "middle of a merge" message
gettextize: git-commit formatting messages
gettextize: git-commit print_summary messages
gettextize: git-commit "enter the commit message" message
gettextize: git-commit advice messages
gettextize: git-diff basic messages
gettextize: git-fetch basic messages
gettextize: git-fetch formatting messages
gettextize: git-fetch update_local_ref messages
gettextize: git-fetch split up "(non-fast-forward)" message
gettextize: git-grep basic messages
gettextize: git-grep "--open-files-in-pager" message
gettextize: git-log basic messages
gettextize: git-log "--OPT does not make sense" messages
gettextize: git-merge basic messages
gettextize: git-merge "Updating %s..%s" message
gettextize: git-merge "You have not concluded your merge" messages
gettextize: git-merge "Wonderful" message
gettextize: git-mv basic messages
gettextize: git-mv "bad" messages
gettextize: git-rm basic messages
gettextize: git-reset basic messages
gettextize: git-reset reset_type_names messages
gettextize: git-reset "Unstaged changes after reset" message
gettextize: git-tag basic messages
gettextize: git-tag tag_template message
gettextize: git-push basic messages
gettextize: git-push "prevent you from losing" message
gettextize: git-status basic messages
gettextize: git-status "nothing to commit" messages
gettextize: git-status shortstatus messages
gettextize: git-status "Changes to be committed" message
gettextize: git-status "Initial commit" message
gettextize: git-status "renamed: " message
gettextize: git-archive basic messages
gettextize: git-bundle basic messages
gettextize: git-clean basic messages
gettextize: git-clean clean.requireForce messages
gettextize: git-describe basic messages
gettextize: git-gc basic messages
gettextize: git-gc "Auto packing the repository" message
gettextize: git-notes basic commands
gettextize: git-notes GIT_NOTES_REWRITE_MODE error message
gettextize: git-revert basic messages
gettextize: git-revert "Your local changes" message
gettextize: git-revert literal "me" messages
gettextize: git-revert split up "could not revert/apply" message
gettextize: git-shortlog basic messages

 builtin/add.c                    |   46 ++++++------
 builtin/archive.c                |   14 ++--
 builtin/branch.c                 |   69 ++++++++--------
 builtin/bundle.c                 |    6 +-
 builtin/checkout.c               |   93 +++++++++++-----------
 builtin/clean.c                  |   33 +++++---
 builtin/clone.c                  |   63 ++++++++-------
 builtin/commit.c                 |  162 +++++++++++++++++++-------------------
 builtin/describe.c               |   36 ++++----
 builtin/diff.c                   |   18 ++--
 builtin/fetch.c                  |   82 ++++++++++----------
 builtin/gc.c                     |   24 +++---
 builtin/grep.c                   |   34 ++++----
 builtin/init-db.c                |   58 +++++++------
 builtin/log.c                    |   68 ++++++++--------
 builtin/merge.c                  |  128 +++++++++++++++---------------
 builtin/mv.c                     |   32 ++++----
 builtin/notes.c                  |  112 +++++++++++++-------------
 builtin/push.c                   |   42 +++++-----
 builtin/reset.c                  |   42 +++++-----
 builtin/revert.c                 |   76 ++++++++++--------
 builtin/rm.c                     |   22 +++---
 builtin/shortlog.c               |    8 +-
 builtin/tag.c                    |   66 ++++++++--------
 cache.h                          |    1 +
 gettext.h                        |    9 ++
 t/lib-httpd.sh                   |    2 +-
 t/t0001-init.sh                  |    2 +-
 t/t1200-tutorial.sh              |    5 +-
 t/t2200-add-update.sh            |    2 +-
 t/t2204-add-ignored.sh           |   37 ++++++---
 t/t3030-merge-recursive.sh       |    2 +-
 t/t3200-branch.sh                |    2 +-
 t/t3203-branch-output.sh         |    2 +-
 t/t3501-revert-cherry-pick.sh    |    2 +-
 t/t3507-cherry-pick-conflict.sh  |    2 +-
 t/t3700-add.sh                   |   11 ++-
 t/t4001-diff-rename.sh           |    4 +-
 t/t4014-format-patch.sh          |    2 +-
 t/t5526-fetch-submodules.sh      |   40 ++++++++--
 t/t5541-http-push.sh             |    7 +-
 t/t5601-clone.sh                 |    2 +-
 t/t6040-tracking-info.sh         |    2 +-
 t/t6120-describe.sh              |    2 +-
 t/t7004-tag.sh                   |    1 +
 t/t7012-skip-worktree-writing.sh |    4 +-
 t/t7060-wtstatus.sh              |    2 +-
 t/t7102-reset.sh                 |    2 +-
 t/t7110-reset-merge.sh           |    6 +-
 t/t7201-co.sh                    |   10 +-
 t/t7300-clean.sh                 |    6 +-
 t/t7500-commit.sh                |    8 +-
 t/t7501-commit.sh                |    7 +-
 t/t7502-commit.sh                |   60 +++++++++------
 t/t7506-status-submodule.sh      |   28 +++---
 t/t7508-status.sh                |  115 +++++++++++++++------------
 t/t7600-merge.sh                 |    2 +-
 t/t7607-merge-overwrite.sh       |   10 ++-
 t/t7611-merge-abort.sh           |   20 ++++-
 t/t7811-grep-open.sh             |    2 +-
 t/test-lib.sh                    |    5 +
 wt-status.c                      |  116 ++++++++++++++--------------
 62 files changed, 1011 insertions(+), 865 deletions(-)
 create mode 100644 gettext.h
Signature · 1 line
1.7.2.3
#1 lore raw

PATCH 1/72 gettext.h: add no-op _() and N_() wrappers

Add a new header called gettext.h which is currently a no-op. To split up the gettext series I'm first submitting patches to gettextize the source tree before I add any of the Makefile and C changes needed to actually use them.

---
 gettext.h |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
 create mode 100644 gettext.h
gettext.h new file +9 -0
new file mode 100644
index 0000000..c68bbe9
@@ -0,0 +1,9 @@
+/*
+ * Copyright (c) 2010 Ævar Arnfjörð Bjarmason
+ *
+ * This is a skeleton no-op implementation of gettext for Git. It'll
+ * be replaced by something that uses libintl.h and wraps gettext() in
+ * a future patch series.
+ */
+#define N_(s) (s)
+#define _(s) (s)
Signature · 1 line
1.7.2.3
#2 lore raw

Re: [PATCH 01/72] gettext.h: add no-op _() and N_() wrappers

Hi Ævar,

Quoted 1 line · Ævar Arnfjörð Bjarmason

Add a new header called gettext.h which is currently a no-op.

Thanks. I'd suggest squashing this with patch #2 (#including gettext.h in cache.h).

gettext.h line 2

Quoted 5 lines
gettext.h new file +2 -0
@@ -0,0 +1,9 @@
+/*
+ * Copyright (c) 2010 Ævar Arnfjörð Bjarmason

Is such a simple header file copyrightable? But I don't mind.

gettext.h line 8

Quoted 6 lines
gettext.h new file +6 -0
+ *
+ * This is a skeleton no-op implementation of gettext for Git. It'll
+ * be replaced by something that uses libintl.h and wraps gettext() in
+ * a future patch series.
+ */
+#define N_(s) (s)

Might be nice to make this an inline function, for type safety.

gettext.h line 9

Quoted 1 line
gettext.h new file +1 -0
+#define _(s) (s)

This one can't be a function, though, since it needs to transform literals to literals.

Some possible tweaks:

- protect against double inclusion
- make _ into a function
- add a comment vaguely explaining N_
- avoid confusing errors if some other header has pre-defined _.

---
 gettext.h |   19 +++++++++++++++++--
 1 files changed, 17 insertions(+), 2 deletions(-)
gettext.h +17 -2
index c68bbe9..2f806cb 100644
@@ -1,3 +1,10 @@
+#ifndef GETTEXT_H
+#define GETTEXT_H
+
+#ifdef _
+#error "namespace conflict: '_' is pre-defined?"
+#endif
+
 /*
  * Copyright (c) 2010 Ævar Arnfjörð Bjarmason
  *
@@ -5,5 +12,13 @@
  * be replaced by something that uses libintl.h and wraps gettext() in
  * a future patch series.
  */
-#define N_(s) (s)
-#define _(s) (s)
+
+static inline const char *_(const char *msgid)
+{
+	return msgid;
+}
+
+/* Mark msgid for translation but do not translate it. */
+#define N_(msgid) (msgid)
+
+#endif
Signature · 1 line
1.7.4.1
#3 lore raw

Re: [PATCH 01/72] gettext.h: add no-op _() and N_() wrappers

Quoted 10 lines · Jonathan Nieder
Quoted 1 line · Ævar Arnfjörð Bjarmason

+#define N_(s) (s)

Might be nice to make this an inline function, for type safety.

Quoted 1 line

+#define _(s) (s)

This one can't be a function, though, since it needs to transform literals to literals.

...

gettext.h line 22

Quoted 10 lines
gettext.h +8 -2
-#define N_(s) (s)
-#define _(s) (s)
+
+static inline const char *_(const char *msgid)
+{
+       return msgid;
+}
+
+/* Mark msgid for translation but do not translate it. */
+#define N_(msgid) (msgid)

Isn't this the opposite of what you suggested above?

#4 lore raw

Re: [PATCH 01/72] gettext.h: add no-op _() and N_() wrappers

Quoted 11 lines · Erik Faye-Lund
Quoted 10 lines · Jonathan Nieder
Quoted 1 line · Ævar Arnfjörð Bjarmason

+#define N_(s) (s)

Might be nice to make this an inline function, for type safety.

Quoted 1 line

+#define _(s) (s)

This one can't be a function, though, since it needs to transform literals to literals.

[...]

Quoted 4 lines

gettext.h line 22

Quoted 2 lines
gettext.h +2 -0
+/* Mark msgid for translation but do not translate it. */
+#define N_(msgid) (msgid)

Isn't this the opposite of what you suggested above?

Agh. I mixed up the snippets from Ævar’s message.

N_ needs to take literals to literals, so even the non-stub version would be defined as

	#define N_(msgid) (msgid)

for use in contexts like

	const char *unpack_plumbing_errors[NB_UNPACK_TREES_ERROR_TYPES] = {
		/* ERROR_WOULD_OVERWRITE */
		N_("Entry '%s' would be overwritten by merge. Cannot merge."),

		/* ERROR_NOT_UPTODATE_FILE */
		N_("Entry '%s' not uptodate. Cannot merge."),
	[...]

Meanwhile, in the non-stub version, _ is a synonym for the gettext() function.

Sorry for the noise.
Jonathan

#5 lore raw

Re: [PATCH 01/72] gettext.h: add no-op _() and N_() wrappers

In reply to Jonathan Nieder
Quoted 62 lines · Jonathan Nieder
Quoted 1 line · Ævar Arnfjörð Bjarmason

Add a new header called gettext.h which is currently a no-op.

Thanks.  I'd suggest squashing this with patch #2 (#including gettext.h in cache.h).

gettext.h line 2

Quoted 5 lines
gettext.h new file +2 -0
@@ -0,0 +1,9 @@
+/*
+ * Copyright (c) 2010 Ævar Arnfjörð Bjarmason

Is such a simple header file copyrightable?  But I don't mind.

gettext.h line 8

Quoted 6 lines
gettext.h new file +6 -0
+ *
+ * This is a skeleton no-op implementation of gettext for Git. It'll
+ * be replaced by something that uses libintl.h and wraps gettext() in
+ * a future patch series.
+ */
+#define N_(s) (s)

Might be nice to make this an inline function, for type safety.

gettext.h line 9

Quoted 1 line
gettext.h new file +1 -0
+#define _(s) (s)

This one can't be a function, though, since it needs to transform literals to literals.

Some possible tweaks:

 - protect against double inclusion
 - make _ into a function
 - add a comment vaguely explaining N_
 - avoid confusing errors if some other header has pre-defined _.

---
 gettext.h |   19 +++++++++++++++++--

 1 files changed, 17 insertions(+), 2 deletions(-)
gettext.h +7 -2
index c68bbe9..2f806cb 100644
@@ -1,3 +1,10 @@
+#ifndef GETTEXT_H
+#define GETTEXT_H
+
+#ifdef _
+#error "namespace conflict: '_' is pre-defined?"
+#endif
+
  /*
  * Copyright (c) 2010 Ævar Arnfjörð Bjarmason
  *
@@ -5,5 +12,13 @@
  * be replaced by something that uses libintl.h and wraps gettext() in
  * a future patch series.
  */
-#define N_(s) (s)
-#define _(s) (s)

gettext.h line 24

Quoted 10 lines
gettext.h +10 -0
+
+static inline const char *_(const char *msgid)
+{
+       return msgid;
+}
+
+/* Mark msgid for translation but do not translate it. */
+#define N_(msgid) (msgid)
+
+#endif

Thanks for this. This was raised earlier in the discussion for this series (by you, IIRC). I've considered it, and while I see your point (type safety = good) I think I like my way of doing it better.

The _() macro/function is usually a macro and not a function. The good thing about this is that I can prove that it's a no-op on all compilers, whereas if it's an inline function (stupid) compilers will actually make it into a function, which'll result in overhead, which'll mean I can't advertise this series as a "no-op" anymore.

Check out some of the recent work in perl.git for reference. There's now a probe in perl which check is the compiler can *really* handle inline functions, and if not perl will fall back on using macros.

I'd rather not use inline functions for every string in Git without such a probe, especially since it's for a very marginal gain. Using _() for non-strings isn't going to make it past the list, and if it's used with e.g. multiple arguments compilers will already whine about it.

So that's why I didn't do it. But if everyone else feels strongly about it I'll change my mind, I don't care *that* much about it, but I'd prefer a macro.

#6 lore raw

Re: [PATCH 01/72] gettext.h: add no-op _() and N_() wrappers

Quoted 9 lines · Ævar Arnfjörð Bjarmason

Thanks for this. This was raised earlier in the discussion for this series (by you, IIRC). I've considered it, and while I see your point (type safety = good) I think I like my way of doing it better.

The _() macro/function is usually a macro and not a function. The good thing about this is that I can prove that it's a no-op on all compilers, whereas if it's an inline function (stupid) compilers will actually make it into a function, which'll result in overhead, which'll mean I can't advertise this series as a "no-op" anymore.

I hope we don't support (meaning "worry about") such stupid compilers?

At least I haven't seen this being a consideration in deciding whether to split out inline functions in the past. Perl is much more portable than git, and that seems perfectly fine to me.

Quoted 3 lines

So that's why I didn't do it. But if everyone else feels strongly about it I'll change my mind, I don't care *that* much about it, but I'd prefer a macro.

I think it's perfectly possible there's some aesthetic or functional reason to make this a macro instead of a function, and that would be fine with me. On the other hand, if there's no reason, then I do feel strongly about it, fwiw. New code should set a good example.

Thanks for your thoughtfulness.
Jonathan

#7 lore raw

PATCH 2/72 cache.h: include gettext.h

In reply to Ævar Arnfjörð Bjarmason

Change cache.h to include gettext.h. In previous incarnations of the gettext series I included gettext.h in builtin.h, then changed builtin/*.c files to include that when they didn't already.

It was pointed out by Junio and others that it makes more sense to have the inclusion here, since gettext is going to be used everywhere.

---
 cache.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
cache.h +1 -0
index 3abf895..a465f38 100644
@@ -5,6 +5,7 @@
 #include "strbuf.h"
 #include "hash.h"
 #include "advice.h"
+#include "gettext.h"
 
 #include SHA1_HEADER
 #ifndef git_SHA_CTX
Signature · 1 line
1.7.2.3
#8 lore raw

PATCH 3/72 t/test-lib.sh: add always-set NO_GETTEXT_POISON prerequisite

In reply to Ævar Arnfjörð Bjarmason

Add a new test prerequisite called NO_GETTEXT_POISON to t/test-lib.sh that's always set for now.

Some of the gettextize patches that'll follow this one will change their test outputs if a functioning gettext implementation with poison support is sitting on top of them, but for now I only have harmless no-op wrappers in gettext.h so NO_GETTEXT_POISON can be set all the time.

---
 t/test-lib.sh |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
t/test-lib.sh +5 -0
index 0fdc541..ffcfa2e 100644
@@ -1079,6 +1079,11 @@ esac
 test -z "$NO_PERL" && test_set_prereq PERL
 test -z "$NO_PYTHON" && test_set_prereq PYTHON
 
+# Always set the NO_GETTEXT_POISON prerequisite while we don't have a
+# real gettext implementation in Git. This will be replaced by
+# something that varies in a future patch series.
+test_set_prereq NO_GETTEXT_POISON
+
 # test whether the filesystem supports symbolic links
 ln -s x y 2>/dev/null && test -h y 2>/dev/null && test_set_prereq SYMLINKS
 rm -f y
Signature · 1 line
1.7.2.3
#9 lore raw

Re: [PATCH 03/72] t/test-lib.sh: add always-set NO_GETTEXT_POISON prerequisite

Hi Ævar,

Quoted 2 lines · Ævar Arnfjörð Bjarmason

Add a new test prerequisite called NO_GETTEXT_POISON to t/test-lib.sh that's always set for now.

Suppose I am writing a new family of tests. Which of them will need the NO_GETTEXT_POISON prerequisite? The name doesn't make it easy to guess.

If later the testsuite learns to take a --lang= option to test that git works correctly in my native language, I'd think this same prerequisite would be relevant for that, too. So maybe:

---
 t/test-lib.sh |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)
t/test-lib.sh +2 -4
index ffcfa2e..32004c1 100644
@@ -1079,10 +1079,8 @@ esac
 test -z "$NO_PERL" && test_set_prereq PERL
 test -z "$NO_PYTHON" && test_set_prereq PYTHON
 
-# Always set the NO_GETTEXT_POISON prerequisite while we don't have a
-# real gettext implementation in Git. This will be replaced by
-# something that varies in a future patch series.
-test_set_prereq NO_GETTEXT_POISON
+# We can rely on output using the C locale.
+test_set_prereq ENGLISH
 
 # test whether the filesystem supports symbolic links
 ln -s x y 2>/dev/null && test -h y 2>/dev/null && test_set_prereq SYMLINKS
Signature · 1 line
1.7.4.1
#10 lore raw

Re: [PATCH 03/72] t/test-lib.sh: add always-set NO_GETTEXT_POISON prerequisite

Quoted 10 lines · Jonathan Nieder

Hi Ævar,

Quoted 2 lines · Ævar Arnfjörð Bjarmason

Add a new test prerequisite called NO_GETTEXT_POISON to t/test-lib.sh that's always set for now.

Suppose I am writing a new family of tests.  Which of them will need the NO_GETTEXT_POISON prerequisite?  The name doesn't make it easy to guess.

You shouldn't worry about it for now. FWIW NO_GETTEXT_POISON is documented in po/README in a patch that I plan to submit later.

NO_GETTEXT_POISON is only relevant to people such as myself who are adding new translations to the source. I.e. changing "foo" to _("foo"). It's a sanity check to make sure that by doing so you're not changing some plumbing test, or at least have to realize what it is that you're changing.

It's not perfect since we don't have tests for everything, but it's helped me a few times.

Quoted 2 lines

If later the testsuite learns to take a --lang= option to test that git works correctly in my native language.

Yeah, I plan to add something like --lang later, but for now we have POISON :)

t/test-lib.sh esac · line 1083

Quoted 6 lines
t/test-lib.sh +2 -4
-# Always set the NO_GETTEXT_POISON prerequisite while we don't have a
-# real gettext implementation in Git. This will be replaced by
-# something that varies in a future patch series.
-test_set_prereq NO_GETTEXT_POISON
+# We can rely on output using the C locale.
+test_set_prereq ENGLISH

It's explicitly about tests that can't deal with poison, not non-English. See this comment in patch 28/72:

gettextize: git-commit "enter the commit message" message

Gettextize 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.

#11 lore raw

Re: [PATCH 03/72] t/test-lib.sh: add always-set NO_GETTEXT_POISON prerequisite

Quoted 9 lines · Ævar Arnfjörð Bjarmason

It's explicitly about tests that can't deal with poison, not non-English. See this comment in patch 28/72:

gettextize: git-commit "enter the commit message" message

Gettextize 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.

Shouldn't the functional part (the starting newline, opening # marks) be untranslatable then, to avoid making a trap for translators? Such a fix could happen at any time, and until then, we could skip those tests in the non-English case.

Since that codepath requires human intervention anyway (which is generally slow), I can't imagine doing that would hurt runtime performance enough to matter.

But I do get your point --- perhaps in some other circumstance we have to rely on some intelligence by the translator for correct behavior. So maybe it means something along the lines of

test_set_prereq SANE_TRANSLATION

?

#12 lore raw

Re: [PATCH 03/72] t/test-lib.sh: add always-set NO_GETTEXT_POISON prerequisite

Quoted 12 lines · Jonathan Nieder
Quoted 9 lines · Ævar Arnfjörð Bjarmason

It's explicitly about tests that can't deal with poison, not non-English. See this comment in patch  28/72:

    gettextize: git-commit "enter the commit message" message

    Gettextize 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.

Quoted 4 lines

Shouldn't the functional part (the starting newline, opening # marks) be untranslatable then, to avoid making a trap for translators?  Such a fix could happen at any time, and until then, we could skip those tests in the non-English case.

I'm aiming to make this as minimal as possible, so I'm not going to change the code to start constructing string buffers where we previously had literals in this iteration.

And the trap is minimimal, sinc msgfmt --check will warn if the structure of the newlines in the translation is different.

Quoted 9 lines

Since that codepath requires human intervention anyway (which is generally slow), I can't imagine doing that would hurt runtime performance enough to matter.

But I do get your point --- perhaps in some other circumstance we have to rely on some intelligence by the translator for correct behavior. So maybe it means something along the lines of

       test_set_prereq SANE_TRANSLATION

Well, the feature I have is to inject garbage into the gettext strings in an effort to smoke out when I break the plumbing. So I think given that functionality calling it NO_GETTEXT_POISON makes sense.

But I plan to add something to smoke other languages etc. later. Then I might name that other prerequisite something else.

#13 lore raw

Re: [PATCH 03/72] t/test-lib.sh: add always-set NO_GETTEXT_POISON prerequisite

Quoted 6 lines · Ævar Arnfjörð Bjarmason

Well, the feature I have is to inject garbage into the gettext strings in an effort to smoke out when I break the plumbing. So I think given that functionality calling it NO_GETTEXT_POISON makes sense.

But I plan to add something to smoke other languages etc. later. Then I might name that other prerequisite something else.

On second thought, another possibility would be _two_ prerequisites, one NO_GETTEXT_POISON one and one ENGLISH one. The weird edge cases could require NO_GETTEXT_POISON, causing the reader to look to t/README to figure out what is going on. The others would just use ENGLISH.

Does that sound reasonable?

#14 lore raw

Re: [PATCH 03/72] t/test-lib.sh: add always-set NO_GETTEXT_POISON prerequisite

Quoted 9 lines · Jonathan Nieder
Quoted 6 lines · Ævar Arnfjörð Bjarmason

Well, the feature I have is to inject garbage into the gettext strings in an effort to smoke out when I break the plumbing. So I think given that functionality calling it NO_GETTEXT_POISON makes sense.

But I plan to add something to smoke other languages etc. later. Then I might name that other prerequisite something else.

Quoted 7 lines

On second thought, another possibility would be _two_ prerequisites, one NO_GETTEXT_POISON one and one ENGLISH one.  The weird edge cases could require NO_GETTEXT_POISON, causing the reader to look to t/README to figure out what is going on.  The others would just use ENGLISH.

Does that sound reasonable?

Yes, I suggested implementing that in the "enter the commit message" patch, but since we don't have a 100% translation yet I was going to wait until then.

It's also a very low priority, the point of these tests is to make sure I don't make a plumbing message translatable. The things that start failing under a testing mode like ENGLISH are by definition a subset of the things that'll start failing under NO_GETTEXT_POISON. So there's not a lot of incentive for me to implement that.

The only reason I can think of to have it is to make sure that messages like the "enter the commit message" ones have the correct newlines in all languages, but msgfmt --check catches that anyway, or to somehow test Git's output in different languages, but I'd rather do that differently (not test output, but behavior).

So given all of the above I might never get around to implementing it.

#15 lore raw

Re: [PATCH 03/72] t/test-lib.sh: add always-set NO_GETTEXT_POISON prerequisite

Quoted 7 lines · Ævar Arnfjörð Bjarmason

The only reason I can think of to have it is to make sure that messages like the "enter the commit message" ones have the correct newlines in all languages, but msgfmt --check catches that anyway, or to somehow test Git's output in different languages, but I'd rather do that differently (not test output, but behavior).

So given all of the above I might never get around to implementing it.

I guess I'm confused. I've been saying (repeatedly, and probably annoyingly) that anyone seeing the NO_GETTEXT_POISON prereq for the first time isn't going to have any clue what it means. I think that's a problem. Do you not think so?

#16 lore raw

Re: [PATCH 03/72] t/test-lib.sh: add always-set NO_GETTEXT_POISON prerequisite

In reply to Ævar Arnfjörð Bjarmason
Quoted 8 lines · Ævar Arnfjörð Bjarmason

You shouldn't worry about it for now. FWIW NO_GETTEXT_POISON is documented in po/README in a patch that I plan to submit later.

NO_GETTEXT_POISON is only relevant to people such as myself who are adding new translations to the source. I.e. changing "foo" to _("foo"). It's a sanity check to make sure that by doing so you're not changing some plumbing test, or at least have to realize what it is that you're changing.

I also had the same reaction to NO_GETTEXT_POISON as Jonathan, and your above argument is not quite right.

GETTEXT_POISON _is_ relevant to people like you who are working on the i18n part of the system. It is a debugging aid to make sure that you are not marking plumbing messages that should never be translated.

But you cannot say NO_GETTEXT_POISON is not relevant to others; everybody else who is not actively working on i18n needs to be aware of it, and needs to be careful when writing his tests. When your test depends on output from Porcelain (which is not something we should encourage, but that is a separate matter), you need to mark that test as "this test will be broken under GETTEXT_POISON build".

"This test requires NO_GETTEXT_POISON pre-requisite, which is only true when git is built without GETTEXT_POISON" makes logical sense as a statement, but it feels somewhat a roundabout way to explain it.

This is somewhat a tangent, but I've been wondering if it might be a better design to make GETTEXT_POISON a runtime thing. When git is run with GIT_LOCALE=POISON, "_(msg)" will all result in gibberish or rot13, and instead of building a special test-only binary, always compile i18n version of git that way.

#17 lore raw

PATCH 4/72 gettextize: git-init basic messages

In reply to Ævar Arnfjörð Bjarmason

Change the user visible strings in init-db.c to use gettext localizations. This only converts messages which needed to be changed from "foo" to _("foo"), and didn't need any TRANSLATORS comments.

I haven't marked the messages in init_db_usage or init_db_options for translation, since that would require additional changes in parse-options.c. Those can be done later.

---
 builtin/init-db.c |   48 ++++++++++++++++++++++++------------------------
 1 files changed, 24 insertions(+), 24 deletions(-)
builtin/init-db.c +24 -24
index 4f5348e..35f9f13 100644
@@ -31,7 +31,7 @@ static void safe_create_dir(const char *dir, int share)
 		}
 	}
 	else if (share && adjust_shared_perm(dir))
-		die("Could not make %s writable by group", dir);
+		die(_("Could not make %s writable by group"), dir);
 }
 
 static void copy_templates_1(char *path, int baselen,
@@ -58,25 +58,25 @@ static void copy_templates_1(char *path, int baselen,
 		namelen = strlen(de->d_name);
 		if ((PATH_MAX <= baselen + namelen) ||
 		    (PATH_MAX <= template_baselen + namelen))
-			die("insanely long template name %s", de->d_name);
+			die(_("insanely long template name %s"), de->d_name);
 		memcpy(path + baselen, de->d_name, namelen+1);
 		memcpy(template + template_baselen, de->d_name, namelen+1);
 		if (lstat(path, &st_git)) {
 			if (errno != ENOENT)
-				die_errno("cannot stat '%s'", path);
+				die_errno(_("cannot stat '%s'"), path);
 		}
 		else
 			exists = 1;
 
 		if (lstat(template, &st_template))
-			die_errno("cannot stat template '%s'", template);
+			die_errno(_("cannot stat template '%s'"), template);
 
 		if (S_ISDIR(st_template.st_mode)) {
 			DIR *subdir = opendir(template);
 			int baselen_sub = baselen + namelen;
 			int template_baselen_sub = template_baselen + namelen;
 			if (!subdir)
-				die_errno("cannot opendir '%s'", template);
+				die_errno(_("cannot opendir '%s'"), template);
 			path[baselen_sub++] =
 				template[template_baselen_sub++] = '/';
 			path[baselen_sub] =
@@ -93,20 +93,20 @@ static void copy_templates_1(char *path, int baselen,
 			int len;
 			len = readlink(template, lnk, sizeof(lnk));
 			if (len < 0)
-				die_errno("cannot readlink '%s'", template);
+				die_errno(_("cannot readlink '%s'"), template);
 			if (sizeof(lnk) <= len)
-				die("insanely long symlink %s", template);
+				die(_("insanely long symlink %s"), template);
 			lnk[len] = 0;
 			if (symlink(lnk, path))
-				die_errno("cannot symlink '%s' '%s'", lnk, path);
+				die_errno(_("cannot symlink '%s' '%s'"), lnk, path);
 		}
 		else if (S_ISREG(st_template.st_mode)) {
 			if (copy_file(path, template, st_template.st_mode))
-				die_errno("cannot copy '%s' to '%s'", template,
+				die_errno(_("cannot copy '%s' to '%s'"), template,
 					  path);
 		}
 		else
-			error("ignoring template %s", template);
+			error(_("ignoring template %s"), template);
 	}
 }
 
@@ -129,7 +129,7 @@ static void copy_templates(const char *template_dir)
 		return;
 	template_len = strlen(template_dir);
 	if (PATH_MAX <= (template_len+strlen("/config")))
-		die("insanely long template path %s", template_dir);
+		die(_("insanely long template path %s"), template_dir);
 	strcpy(template_path, template_dir);
 	if (template_path[template_len-1] != '/') {
 		template_path[template_len++] = '/';
@@ -137,7 +137,7 @@ static void copy_templates(const char *template_dir)
 	}
 	dir = opendir(template_path);
 	if (!dir) {
-		warning("templates not found %s", template_dir);
+		warning(_("templates not found %s"), template_dir);
 		return;
 	}
 
@@ -150,8 +150,8 @@ static void copy_templates(const char *template_dir)
 
 	if (repository_format_version &&
 	    repository_format_version != GIT_REPO_VERSION) {
-		warning("not copying templates of "
-			"a wrong format version %d from '%s'",
+		warning(_("not copying templates of "
+			"a wrong format version %d from '%s'"),
 			repository_format_version,
 			template_dir);
 		closedir(dir);
@@ -188,7 +188,7 @@ static int create_default_files(const char *template_path)
 	int filemode;
 
 	if (len > sizeof(path)-50)
-		die("insane git directory %s", git_dir);
+		die(_("insane git directory %s"), git_dir);
 	memcpy(path, git_dir, len);
 
 	if (len && path[len-1] != '/')
@@ -346,7 +346,7 @@ int init_db(const char *template_dir, unsigned int flags)
 		else if (shared_repository == PERM_EVERYBODY)
 			sprintf(buf, "%d", OLD_PERM_EVERYBODY);
 		else
-			die("oops");
+			die(_("oops"));
 		git_config_set("core.sharedrepository", buf);
 		git_config_set("receive.denyNonFastforwards", "true");
 	}
@@ -375,7 +375,7 @@ static int guess_repository_type(const char *git_dir)
 	if (!strcmp(".", git_dir))
 		return 1;
 	if (!getcwd(cwd, sizeof(cwd)))
-		die_errno("cannot tell cwd");
+		die_errno(_("cannot tell cwd"));
 	if (!strcmp(git_dir, cwd))
 		return 1;
 	/*
@@ -450,18 +450,18 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
 					errno = EEXIST;
 					/* fallthru */
 				case -1:
-					die_errno("cannot mkdir %s", argv[0]);
+					die_errno(_("cannot mkdir %s"), argv[0]);
 					break;
 				default:
 					break;
 				}
 				shared_repository = saved;
 				if (mkdir(argv[0], 0777) < 0)
-					die_errno("cannot mkdir %s", argv[0]);
+					die_errno(_("cannot mkdir %s"), argv[0]);
 				mkdir_tried = 1;
 				goto retry;
 			}
-			die_errno("cannot chdir to %s", argv[0]);
+			die_errno(_("cannot chdir to %s"), argv[0]);
 		}
 	} else if (0 < argc) {
 		usage(init_db_usage[0]);
@@ -483,8 +483,8 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
 	git_dir = getenv(GIT_DIR_ENVIRONMENT);
 	work_tree = getenv(GIT_WORK_TREE_ENVIRONMENT);
 	if ((!git_dir || is_bare_repository_cfg == 1) && work_tree)
-		die("%s (or --work-tree=<directory>) not allowed without "
-		    "specifying %s (or --git-dir=<directory>)",
+		die(_("%s (or --work-tree=<directory>) not allowed without "
+			  "specifying %s (or --git-dir=<directory>)"),
 		    GIT_WORK_TREE_ENVIRONMENT,
 		    GIT_DIR_ENVIRONMENT);
 
@@ -509,14 +509,14 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
 		if (!git_work_tree_cfg) {
 			git_work_tree_cfg = xcalloc(PATH_MAX, 1);
 			if (!getcwd(git_work_tree_cfg, PATH_MAX))
-				die_errno ("Cannot access current working directory");
+				die_errno (_("Cannot access current working directory"));
 		}
 		if (work_tree)
 			set_git_work_tree(make_absolute_path(work_tree));
 		else
 			set_git_work_tree(git_work_tree_cfg);
 		if (access(get_git_work_tree(), X_OK))
-			die_errno ("Cannot access work tree '%s'",
+			die_errno (_("Cannot access work tree '%s'"),
 				   get_git_work_tree());
 	}
 	else {
Signature · 1 line
1.7.2.3
#18 lore raw

Re: [PATCH 04/72] gettextize: git-init basic messages

One more comment. (The gettextization so far looks good to me.)

builtin/init-db.c static void safe_create_dir(const char *dir, int share) · line 34

Quoted 8 lines · Ævar Arnfjörð Bjarmason
builtin/init-db.c +1 -1
@@ -31,7 +31,7 @@ static void safe_create_dir(const char *dir, int share)
 		}
 	}
 	else if (share && adjust_shared_perm(dir))
-		die("Could not make %s writable by group", dir);
+		die(_("Could not make %s writable by group"), dir);

Hmm, forgot to include something like the following in the reply to patch 1.

builtin/init-db.c int init_db(const char *template_dir, unsigned int flags) · line 349

Quoted 6 lines
builtin/init-db.c +1 -1
@@ -346,7 +346,7 @@ int init_db(const char *template_dir, unsigned int flags)
 		else if (shared_repository == PERM_EVERYBODY)
 			sprintf(buf, "%d", OLD_PERM_EVERYBODY);
 		else
-			die("oops");
+			die(_("oops"));

(Not related to this series, but that seems like a pretty unhelpful error message.)

---
 gettext.h |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
gettext.h +3 -1
index 2f806cb..2bd70d4 100644
@@ -5,6 +5,8 @@
 #error "namespace conflict: _ is pre-defined?"
 #endif
 
+#define FORMAT_PRESERVING(n) __attribute__((format_arg(n)))
+
 /*
  * Copyright (c) 2010 Ævar Arnfjörð Bjarmason
  *
@@ -13,7 +15,7 @@
  * a future patch series.
  */
 
-static inline const char *_(const char *msgid)
+static inline FORMAT_PRESERVING(1) const char *_(const char *msgid)
 {
 	return msgid;
 }
Signature · 1 line
1.7.4.1
#19 lore raw

PATCH 5/72 gettextize: git-init "Initialized [...] repository" message

In reply to Ævar Arnfjörð Bjarmason

Change the git-init "Initialized empty Git repository" message and its variants to use gettext.

This is one of the messages that could do with splitting up, I had a WIP patch to do that that began like this:

    const char *reinit_shared   = _("Reinitialized existing shared Git repository in %s\n");
    const char *init_shared	    = _("Initialized empty shared Git repository in %s\n");
    const char *reinit_noshared = _("Reinitialized existing Git repository in %s\n");
    const char *init_noshared   = _("Initialized empty Git repository in %s\n");

But in the first round of gettextization I'm aiming to keep code changes to a minimum for ease of review.

We can solicit input from translators about which messages that use too much sprintf-ing are troublesome, and change those later.

Note that the TRANSLATORS comment doesn't use the usual Git style. This is because everything from "/* TRANSLATORS: " to "*/" will extracted as-is xgettext(1) and presented to translators, including newlines and leading "*"'s. There seems to be no way to change that, short of patching xgettext itself.

---
 builtin/init-db.c |   10 +++++++---
 t/t0001-init.sh   |    2 +-
 2 files changed, 8 insertions(+), 4 deletions(-)
builtin/init-db.c +7 -3
index 35f9f13..67462ad 100644
@@ -354,9 +354,13 @@ int init_db(const char *template_dir, unsigned int flags)
 	if (!(flags & INIT_DB_QUIET)) {
 		const char *git_dir = get_git_dir();
 		int len = strlen(git_dir);
-		printf("%s%s Git repository in %s%s\n",
-		       reinit ? "Reinitialized existing" : "Initialized empty",
-		       shared_repository ? " shared" : "",
+
+		/* TRANSLATORS: The first '%s' is either "Reinitialized
+		   existing" or "Initialized empty", the second " shared" or
+		   "", and the last '%s%s' is the verbatim directory name. */
+		printf(_("%s%s Git repository in %s%s\n"),
+		       reinit ? _("Reinitialized existing") : _("Initialized empty"),
+		       shared_repository ? _(" shared") : "",
 		       git_dir, len && git_dir[len-1] != '/' ? "/" : "");
 	}
 
t/t0001-init.sh +1 -1
index f684993..4235ad4 100755
@@ -180,7 +180,7 @@ test_expect_success 'GIT_DIR & GIT_WORK_TREE (2)' '
 	fi
 '
 
-test_expect_success 'reinit' '
+test_expect_success NO_GETTEXT_POISON 'reinit' '
 
 	(
 		sane_unset GIT_CONFIG GIT_WORK_TREE GIT_CONFIG &&
Signature · 1 line
1.7.2.3
#20 lore raw

PATCH 6/72 gettextize: git-clone basic messages

In reply to Ævar Arnfjörð Bjarmason
---
 builtin/clone.c |   54 +++++++++++++++++++++++++++---------------------------
 1 files changed, 27 insertions(+), 27 deletions(-)
builtin/clone.c +27 -27
index 60d9a64..f46d09b 100644
@@ -208,7 +208,7 @@ static void setup_reference(const char *repo)
 	if (is_directory(mkpath("%s/.git/objects", ref_git)))
 		ref_git = mkpath("%s/.git", ref_git);
 	else if (!is_directory(mkpath("%s/objects", ref_git)))
-		die("reference repository '%s' is not a local directory.",
+		die(_("reference repository '%s' is not a local directory."),
 		    option_reference);
 
 	ref_git_copy = xstrdup(ref_git);
@@ -235,15 +235,15 @@ static void copy_or_link_directory(struct strbuf *src, struct strbuf *dest)
 
 	dir = opendir(src->buf);
 	if (!dir)
-		die_errno("failed to open '%s'", src->buf);
+		die_errno(_("failed to open '%s'"), src->buf);
 
 	if (mkdir(dest->buf, 0777)) {
 		if (errno != EEXIST)
-			die_errno("failed to create directory '%s'", dest->buf);
+			die_errno(_("failed to create directory '%s'"), dest->buf);
 		else if (stat(dest->buf, &buf))
-			die_errno("failed to stat '%s'", dest->buf);
+			die_errno(_("failed to stat '%s'"), dest->buf);
 		else if (!S_ISDIR(buf.st_mode))
-			die("%s exists and is not a directory", dest->buf);
+			die(_("%s exists and is not a directory"), dest->buf);
 	}
 
 	strbuf_addch(src, '/');
@@ -257,7 +257,7 @@ static void copy_or_link_directory(struct strbuf *src, struct strbuf *dest)
 		strbuf_setlen(dest, dest_len);
 		strbuf_addstr(dest, de->d_name);
 		if (stat(src->buf, &buf)) {
-			warning ("failed to stat %s\n", src->buf);
+			warning (_("failed to stat %s\n"), src->buf);
 			continue;
 		}
 		if (S_ISDIR(buf.st_mode)) {
@@ -267,16 +267,16 @@ static void copy_or_link_directory(struct strbuf *src, struct strbuf *dest)
 		}
 
 		if (unlink(dest->buf) && errno != ENOENT)
-			die_errno("failed to unlink '%s'", dest->buf);
+			die_errno(_("failed to unlink '%s'"), dest->buf);
 		if (!option_no_hardlinks) {
 			if (!link(src->buf, dest->buf))
 				continue;
 			if (option_local)
-				die_errno("failed to create link '%s'", dest->buf);
+				die_errno(_("failed to create link '%s'"), dest->buf);
 			option_no_hardlinks = 1;
 		}
 		if (copy_file_with_time(dest->buf, src->buf, 0666))
-			die_errno("failed to copy file to '%s'", dest->buf);
+			die_errno(_("failed to copy file to '%s'"), dest->buf);
 	}
 	closedir(dir);
 }
@@ -305,7 +305,7 @@ static const struct ref *clone_local(const char *src_repo,
 	ret = transport_get_remote_refs(transport);
 	transport_disconnect(transport);
 	if (0 <= option_verbosity)
-		printf("done.\n");
+		printf(_("done.\n"));
 	return ret;
 }
 
@@ -387,11 +387,11 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 			     builtin_clone_usage, 0);
 
 	if (argc > 2)
-		usage_msg_opt("Too many arguments.",
+		usage_msg_opt(_("Too many arguments."),
 			builtin_clone_usage, builtin_clone_options);
 
 	if (argc == 0)
-		usage_msg_opt("You must specify a repository to clone.",
+		usage_msg_opt(_("You must specify a repository to clone."),
 			builtin_clone_usage, builtin_clone_options);
 
 	if (option_mirror)
@@ -399,7 +399,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 
 	if (option_bare) {
 		if (option_origin)
-			die("--bare and --origin %s options are incompatible.",
+			die(_("--bare and --origin %s options are incompatible."),
 			    option_origin);
 		option_no_checkout = 1;
 	}
@@ -418,7 +418,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 		repo = repo_name;
 	is_local = path && !is_bundle;
 	if (is_local && option_depth)
-		warning("--depth is ignored in local clones; use file:// instead.");
+		warning(_("--depth is ignored in local clones; use file:// instead."));
 
 	if (argc == 2)
 		dir = xstrdup(argv[1]);
@@ -428,8 +428,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 
 	dest_exists = !stat(dir, &buf);
 	if (dest_exists && !is_empty_dir(dir))
-		die("destination path '%s' already exists and is not "
-			"an empty directory.", dir);
+		die(_("destination path '%s' already exists and is not "
+			"an empty directory."), dir);
 
 	strbuf_addf(&reflog_msg, "clone: from %s", repo);
 
@@ -438,7 +438,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 	else {
 		work_tree = getenv("GIT_WORK_TREE");
 		if (work_tree && !stat(work_tree, &buf))
-			die("working tree '%s' already exists.", work_tree);
+			die(_("working tree '%s' already exists."), work_tree);
 	}
 
 	if (option_bare || work_tree)
@@ -451,10 +451,10 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 	if (!option_bare) {
 		junk_work_tree = work_tree;
 		if (safe_create_leading_directories_const(work_tree) < 0)
-			die_errno("could not create leading directories of '%s'",
+			die_errno(_("could not create leading directories of '%s'"),
 				  work_tree);
 		if (!dest_exists && mkdir(work_tree, 0755))
-			die_errno("could not create work tree dir '%s'.",
+			die_errno(_("could not create work tree dir '%s'."),
 				  work_tree);
 		set_git_work_tree(work_tree);
 	}
@@ -465,7 +465,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 	setenv(CONFIG_ENVIRONMENT, mkpath("%s/config", git_dir), 1);
 
 	if (safe_create_leading_directories_const(git_dir) < 0)
-		die("could not create leading directories of '%s'", git_dir);
+		die(_("could not create leading directories of '%s'"), git_dir);
 	set_git_dir(make_absolute_path(git_dir));
 
 	if (0 <= option_verbosity)
@@ -527,7 +527,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 		transport = transport_get(remote, remote->url[0]);
 
 		if (!transport->get_refs_list || !transport->fetch)
-			die("Don't know how to clone %s", transport->url);
+			die(_("Don't know how to clone %s"), transport->url);
 
 		transport_set_option(transport, TRANS_OPT_KEEP, "yes");
 
@@ -566,8 +566,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 			strbuf_release(&head);
 
 			if (!our_head_points_at) {
-				warning("Remote branch %s not found in "
-					"upstream %s, using HEAD instead",
+				warning(_("Remote branch %s not found in "
+					"upstream %s, using HEAD instead"),
 					option_branch, option_origin);
 				our_head_points_at = remote_head_points_at;
 			}
@@ -576,7 +576,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 			our_head_points_at = remote_head_points_at;
 	}
 	else {
-		warning("You appear to have cloned an empty repository.");
+		warning(_("You appear to have cloned an empty repository."));
 		our_head_points_at = NULL;
 		remote_head_points_at = NULL;
 		remote_head = NULL;
@@ -618,8 +618,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 	} else {
 		/* Nothing to checkout out */
 		if (!option_no_checkout)
-			warning("remote HEAD refers to nonexistent ref, "
-				"unable to checkout.\n");
+			warning(_("remote HEAD refers to nonexistent ref, "
+				"unable to checkout.\n"));
 		option_no_checkout = 1;
 	}
 
@@ -655,7 +655,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 
 		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"));
 
 		err |= run_hook(NULL, "post-checkout", sha1_to_hex(null_sha1),
 				sha1_to_hex(our_head_points_at->old_sha1), "1",
Signature · 1 line
1.7.2.3
#21 lore raw

PATCH 7/72 gettextize: git-clone "Cloning into" message

In reply to Ævar Arnfjörð Bjarmason

Split up the "Cloning into %s" and "Cloning into bare repository %s" messages to make them easier to translate.

---
 builtin/clone.c  |    9 ++++++---
 t/t5601-clone.sh |    2 +-
 2 files changed, 7 insertions(+), 4 deletions(-)
builtin/clone.c +6 -3
index f46d09b..dffcf80 100644
@@ -468,9 +468,12 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 		die(_("could not create leading directories of '%s'"), git_dir);
 	set_git_dir(make_absolute_path(git_dir));
 
-	if (0 <= option_verbosity)
-		printf("Cloning into %s%s...\n",
-		       option_bare ? "bare repository " : "", dir);
+	if (0 <= option_verbosity) {
+		if (option_bare)
+			printf(_("Cloning into bare repository %s\n"), dir);
+		else
+			printf(_("Cloning into %s\n"), dir);
+	}
 	init_db(option_template, INIT_DB_QUIET);
 
 	/*
t/t5601-clone.sh +1 -1
index 987e0c8..ecb499d 100755
@@ -31,7 +31,7 @@ test_expect_success 'clone with excess parameters (2)' '
 
 '
 
-test_expect_success 'output from clone' '
+test_expect_success NO_GETTEXT_POISON 'output from clone' '
 	rm -fr dst &&
 	git clone -n "file://$(pwd)/src" dst >output &&
 	test $(grep Clon output | wc -l) = 1
Signature · 1 line
1.7.2.3
#22 lore raw

Re: [PATCH 07/72] gettextize: git-clone "Cloning into" message

Quoted 5 lines · Ævar Arnfjörð Bjarmason
builtin/clone.c +0 -0
@@ -468,9 +468,12 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 		die(_("could not create leading directories of '%s'"), git_dir);
 	set_git_dir(make_absolute_path(git_dir));

builtin/clone.c int cmd_clone(int argc, const char **argv, const char *prefix) · line 476

Quoted 10 lines
builtin/clone.c +6 -3
 
-	if (0 <= option_verbosity)
-		printf("Cloning into %s%s...\n",
-		       option_bare ? "bare repository " : "", dir);
+	if (0 <= option_verbosity) {
+		if (option_bare)
+			printf(_("Cloning into bare repository %s\n"), dir);
+		else
+			printf(_("Cloning into %s\n"), dir);
+	}

An ellipsis seems to have been lost. I wonder if there is some easy (automated, ideally) way to check these patches.

#23 lore raw

PATCH 8/72 gettextize: git-add basic messages

In reply to Ævar Arnfjörð Bjarmason
---
 builtin/add.c |   36 ++++++++++++++++++------------------
 1 files changed, 18 insertions(+), 18 deletions(-)
builtin/add.c +18 -18
index 42c906e..a9a78f4 100644
@@ -38,7 +38,7 @@ static void update_callback(struct diff_queue_struct *q,
 		const char *path = p->one->path;
 		switch (p->status) {
 		default:
-			die("unexpected diff status %c", p->status);
+			die(_("unexpected diff status %c"), p->status);
 		case DIFF_STATUS_UNMERGED:
 			/*
 			 * ADD_CACHE_IGNORE_REMOVAL is unset if "git
@@ -64,7 +64,7 @@ static void update_callback(struct diff_queue_struct *q,
 		case DIFF_STATUS_TYPE_CHANGED:
 			if (add_file_to_index(&the_index, path, data->flags)) {
 				if (!(data->flags & ADD_CACHE_IGNORE_ERRORS))
-					die("updating files failed");
+					die(_("updating files failed"));
 				data->add_errors++;
 			}
 			break;
@@ -172,7 +172,7 @@ static void treat_gitlinks(const char **pathspec)
 					/* strip trailing slash */
 					pathspec[j] = xstrndup(ce->name, len);
 				else
-					die ("Path '%s' is in submodule '%.*s'",
+					die (_("Path '%s' is in submodule '%.*s'"),
 						pathspec[j], len, ce->name);
 			}
 		}
@@ -191,7 +191,7 @@ static void refresh(int verbose, const char **pathspec)
 		      pathspec, seen, "Unstaged changes after refreshing the index:");
 	for (i = 0; i < specs; i++) {
 		if (!seen[i])
-			die("pathspec '%s' did not match any files", pathspec[i]);
+			die(_("pathspec '%s' did not match any files"), pathspec[i]);
 	}
         free(seen);
 }
@@ -205,7 +205,7 @@ static const char **validate_pathspec(int argc, const char **argv, const char *p
 		for (p = pathspec; *p; p++) {
 			if (has_symlink_leading_path(*p, strlen(*p))) {
 				int len = prefix ? strlen(prefix) : 0;
-				die("'%s' is beyond a symbolic link", *p + len);
+				die(_("'%s' is beyond a symbolic link"), *p + len);
 			}
 		}
 	}
@@ -272,7 +272,7 @@ static int edit_patch(int argc, const char **argv, const char *prefix)
 	git_config(git_diff_basic_config, NULL); /* no "diff" UI options */
 
 	if (read_cache() < 0)
-		die ("Could not read the index");
+		die (_("Could not read the index"));
 
 	init_revisions(&rev, prefix);
 	rev.diffopt.context = 7;
@@ -281,24 +281,24 @@ static int edit_patch(int argc, const char **argv, const char *prefix)
 	rev.diffopt.output_format = DIFF_FORMAT_PATCH;
 	out = open(file, O_CREAT | O_WRONLY, 0644);
 	if (out < 0)
-		die ("Could not open '%s' for writing.", file);
+		die (_("Could not open '%s' for writing."), file);
 	rev.diffopt.file = xfdopen(out, "w");
 	rev.diffopt.close_file = 1;
 	if (run_diff_files(&rev, 0))
-		die ("Could not write patch");
+		die (_("Could not write patch"));
 
 	launch_editor(file, NULL, NULL);
 
 	if (stat(file, &st))
-		die_errno("Could not stat '%s'", file);
+		die_errno(_("Could not stat '%s'"), file);
 	if (!st.st_size)
-		die("Empty patch. Aborted.");
+		die(_("Empty patch. Aborted."));
 
 	memset(&child, 0, sizeof(child));
 	child.git_cmd = 1;
 	child.argv = apply_argv;
 	if (run_command(&child))
-		die ("Could not apply '%s'", file);
+		die (_("Could not apply '%s'"), file);
 
 	unlink(file);
 	return 0;
@@ -354,7 +354,7 @@ static int add_files(struct dir_struct *dir, int flags)
 	for (i = 0; i < dir->nr; i++)
 		if (add_file_to_cache(dir->entries[i]->name, flags)) {
 			if (!ignore_add_errors)
-				die("adding files failed");
+				die(_("adding files failed"));
 			exit_status = 1;
 		}
 	return exit_status;
@@ -386,9 +386,9 @@ int cmd_add(int argc, const char **argv, const char *prefix)
 	argv++;
 
 	if (addremove && take_worktree_changes)
-		die("-A and -u are mutually incompatible");
+		die(_("-A and -u are mutually incompatible"));
 	if (!show_only && ignore_missing)
-		die("Option --ignore-missing can only be used together with --dry-run");
+		die(_("Option --ignore-missing can only be used together with --dry-run"));
 	if ((addremove || take_worktree_changes) && !argc) {
 		static const char *here[2] = { ".", NULL };
 		argc = 1;
@@ -408,14 +408,14 @@ int cmd_add(int argc, const char **argv, const char *prefix)
 		  ? ADD_CACHE_IGNORE_REMOVAL : 0));
 
 	if (require_pathspec && argc == 0) {
-		fprintf(stderr, "Nothing specified, nothing added.\n");
-		fprintf(stderr, "Maybe you wanted to say 'git add .'?\n");
+		fprintf(stderr, _("Nothing specified, nothing added.\n"));
+		fprintf(stderr, _("Maybe you wanted to say 'git add .'?\n"));
 		return 0;
 	}
 	pathspec = validate_pathspec(argc, argv, prefix);
 
 	if (read_cache() < 0)
-		die("index file corrupt");
+		die(_("index file corrupt"));
 	treat_gitlinks(pathspec);
 
 	if (add_new_files) {
@@ -467,7 +467,7 @@ int cmd_add(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 exit_status;
Signature · 1 line
1.7.2.3
#24 lore raw

PATCH 9/72 gettextize: git-add "no files added" message

In reply to Ævar Arnfjörð Bjarmason
---
 builtin/add.c  |    2 +-
 t/t3700-add.sh |    5 ++++-
 2 files changed, 5 insertions(+), 2 deletions(-)
builtin/add.c +1 -1
index a9a78f4..df56429 100644
@@ -348,7 +348,7 @@ static int add_files(struct dir_struct *dir, int flags)
 		for (i = 0; i < dir->ignored_nr; i++)
 			fprintf(stderr, "%s\n", dir->ignored[i]->name);
 		fprintf(stderr, "Use -f if you really want to add them.\n");
-		die("no files added");
+		die(_("no files added"));
 	}
 
 	for (i = 0; i < dir->nr; i++)
t/t3700-add.sh +4 -1
index ec71083..d4fc563 100755
@@ -283,7 +283,10 @@ add 'track-this'
 EOF
 
 test_expect_success 'git add --dry-run --ignore-missing of non-existing file' '
-	test_must_fail git add --dry-run --ignore-missing track-this ignored-file >actual.out 2>actual.err &&
+	test_must_fail git add --dry-run --ignore-missing track-this ignored-file >actual.out 2>actual.err
+'
+
+test_expect_success NO_GETTEXT_POISON 'git add --dry-run --ignore-missing of non-existing file output' '
 	test_cmp expect.out actual.out &&
 	test_cmp expect.err actual.err
 '
Signature · 1 line
1.7.2.3
#25 lore raw

PATCH 10/72 gettextize: git-add "Use -f if you really want" message

In reply to Ævar Arnfjörð Bjarmason

Gettextize the "Use -f if you really want to add them.\n" message. Tests in t2204-add-ignored.sh and t3700-add.sh explicitly checked for this message. Split the tests that did so up and skip portion that calls grep on this message under GETTEXT_POISON=YesPlease.

---
 builtin/add.c          |    2 +-
 t/t2204-add-ignored.sh |   37 +++++++++++++++++++++++++------------
 2 files changed, 26 insertions(+), 13 deletions(-)
builtin/add.c +1 -1
index df56429..fe4ac49 100644
@@ -347,7 +347,7 @@ static int add_files(struct dir_struct *dir, int flags)
 		fprintf(stderr, ignore_error);
 		for (i = 0; i < dir->ignored_nr; i++)
 			fprintf(stderr, "%s\n", dir->ignored[i]->name);
-		fprintf(stderr, "Use -f if you really want to add them.\n");
+		fprintf(stderr, _("Use -f if you really want to add them.\n"));
 		die(_("no files added"));
 	}
 
t/t2204-add-ignored.sh +25 -12
index 24afdab..be66e2d 100755
@@ -31,18 +31,21 @@ do
 		rm -f .git/index &&
 		test_must_fail git add "$i" 2>err &&
 		git ls-files "$i" >out &&
-		! test -s out &&
-		grep -e "Use -f if" err &&
-		cat err
+		! test -s out
+	'
+
+	test_expect_success NO_GETTEXT_POISON "complaints for ignored $i output" '
+		grep -e "Use -f if" err
 	'
 
 	test_expect_success "complaints for ignored $i with unignored file" '
 		rm -f .git/index &&
 		test_must_fail git add "$i" file 2>err &&
 		git ls-files "$i" >out &&
-		! test -s out &&
-		grep -e "Use -f if" err &&
-		cat err
+		! test -s out
+	'
+	test_expect_success NO_GETTEXT_POISON "complaints for ignored $i with unignored file output" '
+		grep -e "Use -f if" err
 	'
 done
 
@@ -54,9 +57,14 @@ do
 			cd dir &&
 			test_must_fail git add "$i" 2>err &&
 			git ls-files "$i" >out &&
-			! test -s out &&
-			grep -e "Use -f if" err &&
-			cat err
+			! test -s out
+		)
+	'
+
+	test_expect_success NO_GETTEXT_POISON "complaints for ignored $i in dir output" '
+		(
+			cd dir &&
+			grep -e "Use -f if" err
 		)
 	'
 done
@@ -69,9 +77,14 @@ do
 			cd sub &&
 			test_must_fail git add "$i" 2>err &&
 			git ls-files "$i" >out &&
-			! test -s out &&
-			grep -e "Use -f if" err &&
-			cat err
+			! test -s out
+		)
+	'
+
+	test_expect_success NO_GETTEXT_POISON "complaints for ignored $i in sub output" '
+		(
+			cd sub &&
+			grep -e "Use -f if" err
 		)
 	'
 done
Signature · 1 line
1.7.2.3
#26 lore raw

PATCH 11/72 gettextize: git-add "pathspec [...] did not match" message

In reply to Ævar Arnfjörð Bjarmason

Gettextize the "pathspec '%s' did not match any files" message. A test in t3700-add.sh explicitly checked for this message. Change it to skip under GETTEXT_POISON=YesPlease.

---
 builtin/add.c  |    2 +-
 t/t3700-add.sh |    6 +++++-
 2 files changed, 6 insertions(+), 2 deletions(-)
builtin/add.c +1 -1
index fe4ac49..b3640c5 100644
@@ -451,7 +451,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
 					if (excluded(&dir, pathspec[i], &dtype))
 						dir_add_ignored(&dir, pathspec[i], strlen(pathspec[i]));
 				} else
-					die("pathspec '%s' did not match any files",
+					die(_("pathspec '%s' did not match any files"),
 					    pathspec[i]);
 			}
 		}
t/t3700-add.sh +5 -1
index d4fc563..9507191 100755
@@ -269,7 +269,11 @@ test_expect_success 'git add --dry-run of existing changed file' "
 test_expect_success 'git add --dry-run of non-existing file' "
 	echo ignored-file >>.gitignore &&
 	test_must_fail git add --dry-run track-this ignored-file >actual 2>&1 &&
-	echo \"fatal: pathspec 'ignored-file' did not match any files\" | test_cmp - actual
+	echo \"fatal: pathspec 'ignored-file' did not match any files\" >expect
+"
+
+test_expect_success NO_GETTEXT_POISON 'git add --dry-run of an existing file output' "
+	test_cmp expect actual
 "
 
 cat >expect.err <<\EOF
Signature · 1 line
1.7.2.3
#27 lore raw

PATCH 12/72 gettextize: git-add "remove '%s'" message

In reply to Ævar Arnfjörð Bjarmason

Gettextize the "remove '%s'\n" message. A test in t2200-add-update.sh explicitly checked for this message. Change it to skip under GETTEXT_POISON=YesPlease.

---
 builtin/add.c         |    2 +-
 t/t2200-add-update.sh |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
builtin/add.c +1 -1
index b3640c5..e399d19 100644
@@ -74,7 +74,7 @@ static void update_callback(struct diff_queue_struct *q,
 			if (!(data->flags & ADD_CACHE_PRETEND))
 				remove_file_from_index(&the_index, path);
 			if (data->flags & (ADD_CACHE_PRETEND|ADD_CACHE_VERBOSE))
-				printf("remove '%s'\n", path);
+				printf(_("remove '%s'\n"), path);
 			break;
 		}
 	}
t/t2200-add-update.sh +1 -1
index 0692427..64182d9 100755
@@ -111,7 +111,7 @@ test_expect_success 'touch and then add explicitly' '
 
 '
 
-test_expect_success 'add -n -u should not add but just report' '
+test_expect_success NO_GETTEXT_POISON 'add -n -u should not add but just report' '
 
 	(
 		echo "add '\''check'\''" &&
Signature · 1 line
1.7.2.3
#28 lore raw

PATCH 13/72 gettextize: git-add refresh_index message

In reply to Ævar Arnfjörð Bjarmason
---
 builtin/add.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
builtin/add.c +1 -1
index e399d19..3e75460 100644
@@ -188,7 +188,7 @@ static void refresh(int verbose, const char **pathspec)
 		/* nothing */;
 	seen = xcalloc(specs, 1);
 	refresh_index(&the_index, verbose ? REFRESH_IN_PORCELAIN : REFRESH_QUIET,
-		      pathspec, seen, "Unstaged changes after refreshing the index:");
+		      pathspec, seen, _("Unstaged changes after refreshing the index:"));
 	for (i = 0; i < specs; i++) {
 		if (!seen[i])
 			die(_("pathspec '%s' did not match any files"), pathspec[i]);
Signature · 1 line
1.7.2.3
#29 lore raw

PATCH 14/72 gettextize: git-branch basic messages

In reply to Ævar Arnfjörð Bjarmason
---
 builtin/branch.c |   56 +++++++++++++++++++++++++++---------------------------
 1 files changed, 28 insertions(+), 28 deletions(-)
builtin/branch.c +28 -28
index 9e546e4..6695db4 100644
@@ -133,12 +133,12 @@ static int branch_merged(int kind, const char *name,
 	if ((head_rev != reference_rev) &&
 	    in_merge_bases(rev, &head_rev, 1) != merged) {
 		if (merged)
-			warning("deleting branch '%s' that has been merged to\n"
-				"         '%s', but it is not yet merged to HEAD.",
+			warning(_("deleting branch '%s' that has been merged to\n"
+				"         '%s', but it is not yet merged to HEAD."),
 				name, reference_name);
 		else
-			warning("not deleting branch '%s' that is not yet merged to\n"
-				"         '%s', even though it is merged to HEAD.",
+			warning(_("not deleting branch '%s' that is not yet merged to\n"
+				"         '%s', even though it is merged to HEAD."),
 				name, reference_name);
 	}
 	return merged;
@@ -165,19 +165,19 @@ static int delete_branches(int argc, const char **argv, int force, int kinds)
 		remote = "";
 		break;
 	default:
-		die("cannot use -a with -d");
+		die(_("cannot use -a with -d"));
 	}
 
 	if (!force) {
 		head_rev = lookup_commit_reference(head_sha1);
 		if (!head_rev)
-			die("Couldn't look up commit object for HEAD");
+			die(_("Couldn't look up commit object for HEAD"));
 	}
 	for (i = 0; i < argc; i++, strbuf_release(&bname)) {
 		strbuf_branchname(&bname, argv[i]);
 		if (kinds == REF_LOCAL_BRANCH && !strcmp(head, bname.buf)) {
-			error("Cannot delete the branch '%s' "
-			      "which you are currently on.", bname.buf);
+			error(_("Cannot delete the branch '%s' "
+			      "which you are currently on."), bname.buf);
 			ret = 1;
 			continue;
 		}
@@ -186,7 +186,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds)
 
 		name = xstrdup(mkpath(fmt, bname.buf));
 		if (!resolve_ref(name, sha1, 1, NULL)) {
-			error("%sbranch '%s' not found.",
+			error(_("%sbranch '%s' not found."),
 					remote, bname.buf);
 			ret = 1;
 			continue;
@@ -194,21 +194,21 @@ static int delete_branches(int argc, const char **argv, int force, int kinds)
 
 		rev = lookup_commit_reference(sha1);
 		if (!rev) {
-			error("Couldn't look up commit object for '%s'", name);
+			error(_("Couldn't look up commit object for '%s'"), name);
 			ret = 1;
 			continue;
 		}
 
 		if (!force && !branch_merged(kinds, bname.buf, rev, head_rev)) {
-			error("The branch '%s' is not fully merged.\n"
+			error(_("The branch '%s' is not fully merged.\n"
 			      "If you are sure you want to delete it, "
-			      "run 'git branch -D %s'.", bname.buf, bname.buf);
+			      "run 'git branch -D %s'."), bname.buf, bname.buf);
 			ret = 1;
 			continue;
 		}
 
 		if (delete_ref(name, sha1, 0)) {
-			error("Error deleting %sbranch '%s'", remote,
+			error(_("Error deleting %sbranch '%s'"), remote,
 			      bname.buf);
 			ret = 1;
 		} else {
@@ -218,7 +218,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds)
 			       find_unique_abbrev(sha1, DEFAULT_ABBREV));
 			strbuf_addf(&buf, "branch.%s", bname.buf);
 			if (git_config_rename_section(buf.buf, NULL) < 0)
-				warning("Update of config-file failed");
+				warning(_("Update of config-file failed"));
 			strbuf_release(&buf);
 		}
 	}
@@ -300,7 +300,7 @@ static int append_ref(const char *refname, const unsigned char *sha1, int flags,
 	if (ref_list->verbose || ref_list->with_commit || merge_filter != NO_FILTER) {
 		commit = lookup_commit_reference_gently(sha1, 1);
 		if (!commit) {
-			cb->ret = error("branch '%s' does not point at a commit", refname);
+			cb->ret = error(_("branch '%s' does not point at a commit"), refname);
 			return 0;
 		}
 
@@ -535,7 +535,7 @@ static int print_ref_list(int kinds, int detached, int verbose, int abbrev, stru
 	free_ref_list(&ref_list);
 
 	if (cb.ret)
-		error("some refs could not be read");
+		error(_("some refs could not be read"));
 
 	return cb.ret;
 }
@@ -548,7 +548,7 @@ static void rename_branch(const char *oldname, const char *newname, int force)
 	int recovery = 0;
 
 	if (!oldname)
-		die("cannot rename the current branch while not on any.");
+		die(_("cannot rename the current branch while not on any."));
 
 	if (strbuf_check_branch_ref(&oldref, oldname)) {
 		/*
@@ -558,35 +558,35 @@ static void rename_branch(const char *oldname, const char *newname, int force)
 		if (resolve_ref(oldref.buf, sha1, 1, NULL))
 			recovery = 1;
 		else
-			die("Invalid branch name: '%s'", oldname);
+			die(_("Invalid branch name: '%s'"), oldname);
 	}
 
 	if (strbuf_check_branch_ref(&newref, newname))
-		die("Invalid branch name: '%s'", newname);
+		die(_("Invalid branch name: '%s'"), newname);
 
 	if (resolve_ref(newref.buf, sha1, 1, NULL) && !force)
-		die("A branch named '%s' already exists.", newref.buf + 11);
+		die(_("A branch named '%s' already exists."), newref.buf + 11);
 
 	strbuf_addf(&logmsg, "Branch: renamed %s to %s",
 		 oldref.buf, newref.buf);
 
 	if (rename_ref(oldref.buf, newref.buf, logmsg.buf))
-		die("Branch rename failed");
+		die(_("Branch rename failed"));
 	strbuf_release(&logmsg);
 
 	if (recovery)
-		warning("Renamed a misnamed branch '%s' away", oldref.buf + 11);
+		warning(_("Renamed a misnamed branch '%s' away"), oldref.buf + 11);
 
 	/* no need to pass logmsg here as HEAD didn't really move */
 	if (!strcmp(oldname, head) && create_symref("HEAD", newref.buf, NULL))
-		die("Branch renamed to %s, but HEAD is not updated!", newname);
+		die(_("Branch renamed to %s, but HEAD is not updated!"), newname);
 
 	strbuf_addf(&oldsection, "branch.%s", oldref.buf + 11);
 	strbuf_release(&oldref);
 	strbuf_addf(&newsection, "branch.%s", newref.buf + 11);
 	strbuf_release(&newref);
 	if (git_config_rename_section(oldsection.buf, newsection.buf) < 0)
-		die("Branch is renamed, but update of config-file failed");
+		die(_("Branch is renamed, but update of config-file failed"));
 	strbuf_release(&oldsection);
 	strbuf_release(&newsection);
 }
@@ -601,7 +601,7 @@ static int opt_parse_merge_filter(const struct option *opt, const char *arg, int
 	if (!arg)
 		arg = "HEAD";
 	if (get_sha1(arg, merge_filter_ref))
-		die("malformed object name %s", arg);
+		die(_("malformed object name %s"), arg);
 	return 0;
 }
 
@@ -675,13 +675,13 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
 
 	head = resolve_ref("HEAD", head_sha1, 0, NULL);
 	if (!head)
-		die("Failed to resolve HEAD as a valid ref.");
+		die(_("Failed to resolve HEAD as a valid ref."));
 	head = xstrdup(head);
 	if (!strcmp(head, "HEAD")) {
 		detached = 1;
 	} else {
 		if (prefixcmp(head, "refs/heads/"))
-			die("HEAD not found below refs/heads!");
+			die(_("HEAD not found below refs/heads!"));
 		head += 11;
 	}
 	hashcpy(merge_filter_ref, head_sha1);
@@ -701,7 +701,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
 		rename_branch(argv[0], argv[1], rename > 1);
 	else if (argc <= 2) {
 		if (kinds != REF_LOCAL_BRANCH)
-			die("-a and -r options to 'git branch' do not make sense with a branch name");
+			die(_("-a and -r options to 'git branch' do not make sense with a branch name"));
 		create_branch(head, argv[0], (argc == 2) ? argv[1] : head,
 			      force_create, reflog, track);
 	} else
Signature · 1 line
1.7.2.3
#30 lore raw

PATCH 15/72 gettextize: git-branch "remote branch '%s' not found" message

In reply to Ævar Arnfjörð Bjarmason

This could be done better by splitting it up, but it would change too much code, which I'm trying to avoid at this point. Instead add a TRANSLATORS comment to explain what "remote " does.

---
 builtin/branch.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
builtin/branch.c +2 -1
index 6695db4..e9d8a5a 100644
@@ -157,7 +157,8 @@ static int delete_branches(int argc, const char **argv, int force, int kinds)
 	switch (kinds) {
 	case REF_REMOTE_BRANCH:
 		fmt = "refs/remotes/%s";
-		remote = "remote ";
+		/* TRANSLATORS: This is "remote " in "remote branch '%s' not found" */
+		remote = _("remote ");
 		force = 1;
 		break;
 	case REF_LOCAL_BRANCH:
Signature · 1 line
1.7.2.3
#31 lore raw

PATCH 16/72 gettextize: git-branch "Deleted branch [...]" message

In reply to Ævar Arnfjörð Bjarmason

Gettextize the "Deleted %sbranch %s (was %s).\n" messages. test in t3200-branch.sh explicitly checked for this message. Change it to skip under GETTEXT_POISON=YesPlease.

---
 builtin/branch.c  |    2 +-
 t/t3200-branch.sh |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
builtin/branch.c +1 -1
index e9d8a5a..d276681 100644
@@ -214,7 +214,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds)
 			ret = 1;
 		} else {
 			struct strbuf buf = STRBUF_INIT;
-			printf("Deleted %sbranch %s (was %s).\n", remote,
+			printf(_("Deleted %sbranch %s (was %s).\n"), remote,
 			       bname.buf,
 			       find_unique_abbrev(sha1, DEFAULT_ABBREV));
 			strbuf_addf(&buf, "branch.%s", bname.buf);
t/t3200-branch.sh +1 -1
index f308235..04997cf 100755
@@ -203,7 +203,7 @@ test_expect_success 'test deleting branch deletes branch config' \
      test -z "$(git config branch.my7.remote)" &&
      test -z "$(git config branch.my7.merge)"'
 
-test_expect_success 'test deleting branch without config' \
+test_expect_success NO_GETTEXT_POISON 'test deleting branch without config' \
     'git branch my7 s &&
      sha1=$(git rev-parse my7 | cut -c 1-7) &&
      test "$(git branch -d my7 2>&1)" = "Deleted branch my7 (was $sha1)."'
Signature · 1 line
1.7.2.3
#32 lore raw

PATCH 17/72 gettextize: git-branch "git branch -v" messages

In reply to Ævar Arnfjörð Bjarmason

Make the "git branch -v" messages translatable, e.g.:

5054b57 [ahead 8] branch error fixup

This is possibly a plumbing message.

---
 builtin/branch.c         |    6 +++---
 t/t6040-tracking-info.sh |    2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)
builtin/branch.c +3 -3
index d276681..4c1a256 100644
@@ -373,11 +373,11 @@ static void fill_tracking_info(struct strbuf *stat, const char *branch_name,
 		strbuf_addf(stat, "%s: ",
 			shorten_unambiguous_ref(branch->merge[0]->dst, 0));
 	if (!ours)
-		strbuf_addf(stat, "behind %d] ", theirs);
+		strbuf_addf(stat, _("behind %d] "), theirs);
 	else if (!theirs)
-		strbuf_addf(stat, "ahead %d] ", ours);
+		strbuf_addf(stat, _("ahead %d] "), ours);
 	else
-		strbuf_addf(stat, "ahead %d, behind %d] ", ours, theirs);
+		strbuf_addf(stat, _("ahead %d, behind %d] "), ours, theirs);
 }
 
 static int matches_merge_filter(struct commit *commit)
t/t6040-tracking-info.sh +1 -1
index 1e0447f..d508a19 100755
@@ -42,7 +42,7 @@ b3 behind 1
 b4 ahead 2
 EOF
 
-test_expect_success 'branch -v' '
+test_expect_success NO_GETTEXT_POISON 'branch -v' '
 	(
 		cd test &&
 		git branch -v
Signature · 1 line
1.7.2.3
#33 lore raw

PATCH 18/72 gettextize: git-branch "(no branch)" message

In reply to Ævar Arnfjörð Bjarmason

Gettextize 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
index 4c1a256..244589e 100644
@@ -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
index 6028748..cf04bb2 100755
@@ -72,7 +72,7 @@ cat >expect <<'EOF'
   branch-two
   master
 EOF
-test_expect_success 'git branch shows detached HEAD properly' '
+test_expect_success NO_GETTEXT_POISON 'git branch shows detached HEAD properly' '
 	git checkout HEAD^0 &&
 	git branch >actual &&
 	test_cmp expect actual
Signature · 1 line
1.7.2.3
#34 lore raw

PATCH 19/72 gettextize: git-checkout basic messages

In reply to Ævar Arnfjörð Bjarmason
---
 builtin/checkout.c |   68 ++++++++++++++++++++++++++--------------------------
 1 files changed, 34 insertions(+), 34 deletions(-)
builtin/checkout.c +34 -34
index cd7f56e..b5060ab 100644
@@ -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
#35 lore raw

PATCH 20/72 gettextize: git-checkout: our/their version message

In reply to Ævar Arnfjörð Bjarmason

Split 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
index b5060ab..7ba0788 100644
@@ -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
#36 lore raw

PATCH 21/72 gettextize: git-checkout describe_detached_head messages

In reply to Ævar Arnfjörð Bjarmason
---
 builtin/checkout.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
builtin/checkout.c +1 -1
index 7ba0788..698ac63 100644
@@ -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
#37 lore raw

PATCH 22/72 gettextize: git-checkout "HEAD is now at" message

In reply to Ævar Arnfjörð Bjarmason

Gettextize 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
index 698ac63..f833330 100644
@@ -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
index 1337fa5..fe7536b 100755
@@ -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 NO_GETTEXT_POISON '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 NO_GETTEXT_POISON '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 NO_GETTEXT_POISON '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 NO_GETTEXT_POISON '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 NO_GETTEXT_POISON '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
#38 lore raw

PATCH 23/72 gettextize: git-checkout "Switched to a .. branch" message

In reply to Ævar Arnfjörð Bjarmason

Split 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
index f833330..2bb7759 100644
@@ -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
#39 lore raw

PATCH 24/72 gettextize: git-commit basic messages

In reply to Ævar Arnfjörð Bjarmason
---
 builtin/commit.c |  118 +++++++++++++++++++++++++++---------------------------
 1 files changed, 59 insertions(+), 59 deletions(-)
builtin/commit.c +59 -59
index d7f55e3..c57f603 100644
@@ -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, int
 		refresh_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, int
 		if (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, int
 
 	discard_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, int
 
 	if (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
#40 lore raw

PATCH 25/72 gettextize: git-commit "middle of a merge" message

In reply to Ævar Arnfjörð Bjarmason

Gettextize 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
index c57f603..0198e90 100644
@@ -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
index 70cdd8e..8e54f0c 100755
@@ -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 NO_GETTEXT_POISON '"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 NO_GETTEXT_POISON '"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 NO_GETTEXT_POISON '--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
#41 lore raw

PATCH 26/72 gettextize: git-commit formatting messages

In reply to Ævar Arnfjörð Bjarmason
---
 builtin/commit.c  |   12 ++++++------
 t/t7502-commit.sh |    4 ++--
 2 files changed, 8 insertions(+), 8 deletions(-)
builtin/commit.c +6 -6
index 0198e90..c7c6c59 100644
@@ -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
index 50da034..9204a4d 100755
@@ -234,7 +234,7 @@ echo "#
 # Author:    $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>
 #" >> expect
 
-test_expect_success 'author different from committer' '
+test_expect_success NO_GETTEXT_POISON '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 NO_GETTEXT_POISON 'committer is automatic' '
 
 	echo >>negative &&
 	(
Signature · 1 line
1.7.2.3
#42 lore raw

PATCH 27/72 gettextize: git-commit print_summary messages

In reply to Ævar Arnfjörð Bjarmason

Gettextize 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
index c7c6c59..c90a8cf 100644
@@ -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
index 9204a4d..298f7d9 100755
@@ -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 NO_GETTEXT_POISON
+	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
#43 lore raw

PATCH 28/72 gettextize: git-commit "enter the commit message" message

In reply to Ævar Arnfjörð Bjarmason

Gettextize 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
index c90a8cf..ac8da45 100644
@@ -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
index 162527c..70dfc88 100755
@@ -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 NO_GETTEXT_POISON '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 NO_GETTEXT_POISON '-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 NO_GETTEXT_POISON '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 NO_GETTEXT_POISON '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
index 298f7d9..6586355 100755
@@ -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 NO_GETTEXT_POISON 'cleanup commit messages (strip,-F,-e): output' '
+	test_cmp expect actual
 '
 
 echo "#
@@ -244,7 +246,10 @@ test_expect_success NO_GETTEXT_POISON '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 NO_GETTEXT_POISON 'author different from committer: output' '
 	test_cmp expect actual
 '
 
@@ -264,7 +269,10 @@ test_expect_success NO_GETTEXT_POISON '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 NO_GETTEXT_POISON 'committer is automatic: output' '
 	test_cmp expect actual
 '
 
Signature · 1 line
1.7.2.3
#44 lore raw

PATCH 29/72 gettextize: git-commit advice messages

In reply to Ævar Arnfjörð Bjarmason
---
 builtin/commit.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
builtin/commit.c +6 -6
index ac8da45..df881d5 100644
@@ -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
#45 lore raw

PATCH 30/72 gettextize: git-diff basic messages

In reply to Ævar Arnfjörð Bjarmason
---
 builtin/diff.c |   18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)
builtin/diff.c +9 -9
index 42822cd..0034273 100644
@@ -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 **argv
 		else 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
#46 lore raw

PATCH 31/72 gettextize: git-fetch basic messages

In reply to Ævar Arnfjörð Bjarmason
---
 builtin/fetch.c |   46 +++++++++++++++++++++++-----------------------
 1 files changed, 23 insertions(+), 23 deletions(-)
builtin/fetch.c +23 -23
index 357f3cd..c27c3e9 100644
@@ -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
#47 lore raw

PATCH 32/72 gettextize: git-fetch formatting messages

In reply to Ævar Arnfjörð Bjarmason

Translate 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
index c27c3e9..0a73dff 100644
@@ -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
index a5f4585..617ce67 100755
@@ -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 NO_GETTEXT_POISON "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 NO_GETTEXT_POISON "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 NO_GETTEXT_POISON "--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 NO_GETTEXT_POISON "--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 NO_GETTEXT_POISON "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 NO_GETTEXT_POISON "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 NO_GETTEXT_POISON "--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
#48 lore raw

PATCH 33/72 gettextize: git-fetch update_local_ref messages

In reply to Ævar Arnfjörð Bjarmason

Translate 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
index 0a73dff..4f622fd 100644
@@ -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
#49 lore raw

PATCH 34/72 gettextize: git-fetch split up "(non-fast-forward)" message

In reply to Ævar Arnfjörð Bjarmason

Split 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
index 4f622fd..ee2c5f5 100644
@@ -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
#50 lore raw

PATCH 35/72 gettextize: git-grep basic messages

In reply to Ævar Arnfjörð Bjarmason
---
 builtin/grep.c |   32 ++++++++++++++++----------------
 1 files changed, 16 insertions(+), 16 deletions(-)
builtin/grep.c +16 -16
index fdf7131..d35b76c 100644
@@ -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
#51 lore raw

PATCH 36/72 gettextize: git-grep "--open-files-in-pager" message

In reply to Ævar Arnfjörð Bjarmason

Gettextize 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
index d35b76c..dfc32fb 100644
@@ -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
index 568a6f2..3aa544c 100755
@@ -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 NO_GETTEXT_POISON '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
#52 lore raw

PATCH 37/72 gettextize: git-log basic messages

In reply to Ævar Arnfjörð Bjarmason
---
 builtin/log.c |   62 ++++++++++++++++++++++++++++----------------------------
 1 files changed, 31 insertions(+), 31 deletions(-)
builtin/log.c +31 -31
index d8c6c28..b36a01e 100644
@@ -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 cha
 	unsigned 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 cha
 	add_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
#53 lore raw

PATCH 38/72 gettextize: git-log "--OPT does not make sense" messages

In reply to Ævar Arnfjörð Bjarmason

Gettextize 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
index b36a01e..853f5d0 100644
@@ -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
index 027c13d..3b182f5 100755
@@ -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 NO_GETTEXT_POISON '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
#54 lore raw

PATCH 39/72 gettextize: git-merge basic messages

In reply to Ævar Arnfjörð Bjarmason
---
 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
index 8c58c3c..0be4dfa 100644
@@ -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, &not_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 *remote
 		return -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
index 5f731a1..ccd5a56 100755
@@ -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 NO_GETTEXT_POISON '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
index 61890bc..760271c 100755
@@ -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 NO_GETTEXT_POISON '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 NO_GETTEXT_POISON '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
#55 lore raw

PATCH 40/72 gettextize: git-merge "Updating %s..%s" message

In reply to Ævar Arnfjörð Bjarmason

Gettextize 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
index 0be4dfa..4f6b34f 100644
@@ -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
index bfa2c21..fb02cac 100755
@@ -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 NO_GETTEXT_POISON 'git resolve output' '
 	test_cmp resolve.expect resolve.output
 '
 
Signature · 1 line
1.7.2.3
#56 lore raw

PATCH 41/72 gettextize: git-merge "You have not concluded your merge" messages

In reply to Ævar Arnfjörð Bjarmason

Gettextize 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
index 34794f8..d441036 100755
@@ -312,7 +312,7 @@ test_expect_success 'merge-recursive result' '
 
 '
 
-test_expect_success 'fail if the index has unresolved entries' '
+test_expect_success NO_GETTEXT_POISON 'fail if the index has unresolved entries' '
 
 	rm -fr [abcd] &&
 	git checkout -f "$c1" &&
Signature · 1 line
1.7.2.3
#57 lore raw

PATCH 42/72 gettextize: git-merge "Wonderful" message

In reply to Ævar Arnfjörð Bjarmason

Gettextize 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
index 4f6b34f..f998206 100644
@@ -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
index b147a1b..3aafdda 100755
@@ -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 NO_GETTEXT_POISON '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
#58 lore raw

PATCH 43/72 gettextize: git-mv basic messages

In reply to Ævar Arnfjörð Bjarmason
---
 builtin/mv.c |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)
builtin/mv.c +8 -8
index 93e8995..18a2218 100644
@@ -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
#59 lore raw

PATCH 44/72 gettextize: git-mv "bad" messages

In reply to Ævar Arnfjörð Bjarmason

Gettextize 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
index 18a2218..40f33ca 100644
@@ -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
#60 lore raw

PATCH 45/72 gettextize: git-rm basic messages

In reply to Ævar Arnfjörð Bjarmason

Make 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
index ff491d7..90c8a50 100644
@@ -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
#61 lore raw

PATCH 46/72 gettextize: git-reset basic messages

In reply to Ævar Arnfjörð Bjarmason
---
 builtin/reset.c |   26 +++++++++++++-------------
 1 files changed, 13 insertions(+), 13 deletions(-)
builtin/reset.c +13 -13
index 5de2bce..0823955 100644
@@ -92,20 +92,20 @@ static int reset_index_file(const unsigned char *sha1, int reset_type, int quiet
 	if (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
#62 lore raw

PATCH 47/72 gettextize: git-reset reset_type_names messages

In reply to Ævar Arnfjörð Bjarmason

Make 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
index 0823955..1465174 100644
@@ -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
#63 lore raw

PATCH 48/72 gettextize: git-reset "Unstaged changes after reset" message

In reply to Ævar Arnfjörð Bjarmason

Gettextize 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
index 1465174..1fe5b0f 100644
@@ -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
index b8cf260..1370949 100755
@@ -423,7 +423,7 @@ Unstaged changes after reset:
 M	file2
 EOF
 
-test_expect_success '--mixed refreshes the index' '
+test_expect_success NO_GETTEXT_POISON '--mixed refreshes the index' '
 	echo 123 >> file2 &&
 	git reset --mixed HEAD > output &&
 	test_cmp expect output
Signature · 1 line
1.7.2.3
#64 lore raw

PATCH 49/72 gettextize: git-tag basic messages

In reply to Ævar Arnfjörð Bjarmason
---
 builtin/tag.c |   60 ++++++++++++++++++++++++++++----------------------------
 1 files changed, 30 insertions(+), 30 deletions(-)
builtin/tag.c +30 -30
index 246a2bc..4bed7c2 100644
@@ -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
#65 lore raw

PATCH 50/72 gettextize: git-tag tag_template message

In reply to Ævar Arnfjörð Bjarmason

Mark 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
index 4bed7c2..4242e27 100644
@@ -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
index 3e7baaf..99d1fbc 100755
@@ -1121,6 +1121,7 @@ test_expect_success \
 '
 
 test_expect_success \
+	NO_GETTEXT_POISON \
 	'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
#66 lore raw

PATCH 51/72 gettextize: git-push basic messages

In reply to Ævar Arnfjörð Bjarmason
---
 builtin/push.c |   38 +++++++++++++++++++-------------------
 1 files changed, 19 insertions(+), 19 deletions(-)
builtin/push.c +19 -19
index e655eb7..513bc57 100644
@@ -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
#67 lore raw

PATCH 52/72 gettextize: git-push "prevent you from losing" message

In reply to Ævar Arnfjörð Bjarmason

Gettextize 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
index 513bc57..8c8d8c7 100644
@@ -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
index 3f24384..0f0b35a 100644
@@ -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 NO_GETTEXT_POISON '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
index b0c2a2c..b341d8b 100755
@@ -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 NO_GETTEXT_POISON '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
#68 lore raw

PATCH 53/72 gettextize: git-status basic messages

In reply to Ævar Arnfjörð Bjarmason

Gettextize 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 NO_GETTEXT_POISON 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
index fcac472..7205154 100755
@@ -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 NO_GETTEXT_POISON 'M/D conflict does not segfault' '
 	mkdir mdconflict &&
 	(
 		cd mdconflict &&
t/t7506-status-submodule.sh +10 -10
index 3d4f85d..74e0f6f 100755
@@ -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 NO_GETTEXT_POISON '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 NO_GETTEXT_POISON '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 NO_GETTEXT_POISON '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 NO_GETTEXT_POISON '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 NO_GETTEXT_POISON '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 NO_GETTEXT_POISON '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 NO_GETTEXT_POISON '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 NO_GETTEXT_POISON '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 NO_GETTEXT_POISON '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 NO_GETTEXT_POISON '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
#69 lore raw

PATCH 54/72 gettextize: git-status "nothing to commit" messages

In reply to Ævar Arnfjörð Bjarmason

Gettextize 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
index 74e0f6f..2347451 100755
@@ -20,12 +20,12 @@ test_expect_success 'setup' '
 	git commit -m "Add submodule sub"
 '
 
-test_expect_success 'status clean' '
+test_expect_success NO_GETTEXT_POISON 'status clean' '
 	git status >output &&
 	grep "nothing to commit" output
 '
 
-test_expect_success 'commit --dry-run -a clean' '
+test_expect_success NO_GETTEXT_POISON '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 NO_GETTEXT_POISON '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 NO_GETTEXT_POISON '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
index f369eba..a975d07 100644
@@ -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
#70 lore raw

PATCH 55/72 gettextize: git-status shortstatus messages

In reply to Ævar Arnfjörð Bjarmason

Make 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
index a975d07..fc38ac2 100644
@@ -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
#71 lore raw

PATCH 56/72 gettextize: git-status "Changes to be committed" message

In reply to Ævar Arnfjörð Bjarmason

Gettextize 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
index 6586355..d7c4280 100755
@@ -384,66 +384,66 @@ try_commit () {
 
 try_commit_status_combo () {
 
-	test_expect_success 'commit' '
+	test_expect_success NO_GETTEXT_POISON 'commit' '
 		clear_config commit.status &&
 		try_commit "" &&
 		grep "^# Changes to be committed:" .git/COMMIT_EDITMSG
 	'
 
-	test_expect_success 'commit' '
+	test_expect_success NO_GETTEXT_POISON 'commit' '
 		clear_config commit.status &&
 		try_commit "" &&
 		grep "^# Changes to be committed:" .git/COMMIT_EDITMSG
 	'
 
-	test_expect_success 'commit --status' '
+	test_expect_success NO_GETTEXT_POISON '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 NO_GETTEXT_POISON '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 NO_GETTEXT_POISON '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 NO_GETTEXT_POISON '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 NO_GETTEXT_POISON '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 NO_GETTEXT_POISON '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 NO_GETTEXT_POISON '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 NO_GETTEXT_POISON '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
index fc38ac2..c6295f9 100644
@@ -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
#72 lore raw

PATCH 57/72 gettextize: git-status "Initial commit" message

In reply to Ævar Arnfjörð Bjarmason

Gettextize 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
index 8980738..9f6e852 100755
@@ -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 NO_GETTEXT_POISON \
+	"Constructing initial commit" \
+	"git status | grep 'Initial commit'"
 
 test_expect_success \
 	"fail initial amend" \
wt-status.c +1 -1
index c6295f9..ad6ef7a 100644
@@ -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
#73 lore raw

PATCH 58/72 gettextize: git-status "renamed: " message

In reply to Ævar Arnfjörð Bjarmason

Gettextize 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
index 71bac83..d42c077 100755
@@ -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 NO_GETTEXT_POISON '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 NO_GETTEXT_POISON  '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
index ad6ef7a..ed6bedd 100644
@@ -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
#74 lore raw

PATCH 59/72 gettextize: git-archive basic messages

In reply to Ævar Arnfjörð Bjarmason
---
 builtin/archive.c |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)
builtin/archive.c +7 -7
index 6a887f5..b14eaba 100644
@@ -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
#75 lore raw

PATCH 60/72 gettextize: git-bundle basic messages

In reply to Ævar Arnfjörð Bjarmason
---
 builtin/bundle.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
builtin/bundle.c +3 -3
index 9b87fb9..81046a9 100644
@@ -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
#76 lore raw

PATCH 61/72 gettextize: git-clean basic messages

In reply to Ævar Arnfjörð Bjarmason
---
 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
index 4a312ab..2d0054b 100644
@@ -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
index 582d0b5..6fccd91 100755
@@ -124,13 +124,13 @@ cat >expected <<EOF
 Would remove expected
 Would remove result
 EOF
-test_expect_success 'git-clean, absent case' '
+test_expect_success NO_GETTEXT_POISON 'git-clean, absent case' '
 	setup_absent &&
 	git clean -n > result &&
 	test_cmp expected result
 '
 
-test_expect_success 'git-clean, dirty case' '
+test_expect_success NO_GETTEXT_POISON 'git-clean, dirty case' '
 	setup_dirty &&
 	git clean -n > result &&
 	test_cmp expected result
t/t7300-clean.sh +3 -3
index 02f67b7..70d8168 100755
@@ -110,7 +110,7 @@ test_expect_success 'git clean with prefix' '
 
 '
 
-test_expect_success 'git clean with relative prefix' '
+test_expect_success NO_GETTEXT_POISON '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 NO_GETTEXT_POISON '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 NO_GETTEXT_POISON 'core.excludesfile' '
 
 	echo excludes >excludes &&
 	echo included >included &&
Signature · 1 line
1.7.2.3
#77 lore raw

PATCH 62/72 gettextize: git-clean clean.requireForce messages

In reply to Ævar Arnfjörð Bjarmason

Split 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
index 2d0054b..75697f7 100644
@@ -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
#78 lore raw

PATCH 63/72 gettextize: git-describe basic messages

In reply to Ævar Arnfjörð Bjarmason
---
 builtin/describe.c  |   36 ++++++++++++++++++------------------
 t/t6120-describe.sh |    2 +-
 2 files changed, 19 insertions(+), 19 deletions(-)
builtin/describe.c +18 -18
index 342129f..037691e 100644
@@ -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
index 876d1ab..210b9a2 100755
@@ -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 NO_GETTEXT_POISON '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
#79 lore raw

PATCH 64/72 gettextize: git-gc basic messages

In reply to Ævar Arnfjörð Bjarmason
---
 builtin/gc.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
builtin/gc.c +5 -5
index 1a80702..a2be62a 100644
@@ -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
#80 lore raw

PATCH 65/72 gettextize: git-gc "Auto packing the repository" message

In reply to Ævar Arnfjörð Bjarmason

Split 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
index a2be62a..ff5f73b 100644
@@ -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
#81 lore raw

PATCH 66/72 gettextize: git-notes basic commands

In reply to Ævar Arnfjörð Bjarmason
---
 builtin/notes.c |  106 +++++++++++++++++++++++++++---------------------------
 1 files changed, 53 insertions(+), 53 deletions(-)
builtin/notes.c +53 -53
index 4d5556e..4c6cf85 100644
@@ -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
#82 lore raw

PATCH 67/72 gettextize: git-notes GIT_NOTES_REWRITE_MODE error message

In reply to Ævar Arnfjörð Bjarmason

Use 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
index 4c6cf85..a0aa995 100644
@@ -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
#83 lore raw

PATCH 68/72 gettextize: git-revert basic messages

In reply to Ævar Arnfjörð Bjarmason
---
 builtin/revert.c |   46 +++++++++++++++++++++++-----------------------
 1 files changed, 23 insertions(+), 23 deletions(-)
builtin/revert.c +23 -23
index dc1b702..1ca08da 100644
@@ -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
#84 lore raw

PATCH 69/72 gettextize: git-revert "Your local changes" message

In reply to Ævar Arnfjörð Bjarmason

Translate 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
index 1ca08da..02c23c9 100644
@@ -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
index 0439544..76d3252 100755
@@ -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 NO_GETTEXT_POISON 'revert forbidden on dirty working tree' '
 
 	echo content >extra_file &&
 	git add extra_file &&
Signature · 1 line
1.7.2.3
#85 lore raw

PATCH 70/72 gettextize: git-revert literal "me" messages

In reply to Ævar Arnfjörð Bjarmason

Translate 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
index 02c23c9..b0a5ffb 100644
@@ -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
#86 lore raw

PATCH 71/72 gettextize: git-revert split up "could not revert/apply" message

In reply to Ævar Arnfjörð Bjarmason

Split 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
index b0a5ffb..98dfd4d 100644
@@ -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
index 607bf25..bf664ec 100755
@@ -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 NO_GETTEXT_POISON '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
#87 lore raw

PATCH 72/72 gettextize: git-shortlog basic messages

In reply to Ævar Arnfjörð Bjarmason
---
 builtin/shortlog.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
builtin/shortlog.c +4 -4
index 1a21e4b..f5efc67 100644
@@ -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
#88 lore raw

v2 cover No-op C gettext wrappers

In reply to Ævar Arnfjörð Bjarmason

Hi,

Quoted 2 lines · Ævar Arnfjörð Bjarmason

As discussed on-list previously I'm remaking the gettext series in a form that'll be easier to swallow.

Here's a reroll of the skeleton gettext.h wrapper as requested. I'll send some gettextization patches in a separate series, time permitting.

Changes from v1:

- renamed NO_GETTEXT_POISON prereq to C_LOCALE_OUTPUT. This should make it possible to reuse that prereq is the test suite ever learns a --lang option. Hopefully this will also make it easier for authors of new tests to tell whether that prereq needs to be set.
- GETTEXT_POISON can be enabled or disabled at runtime
- _() is an inline function to catch misuses like

const char *some_strings[] = { _("foo"), _("bar"), _("baz") };
- combined some patches, tweaked commit messages

Thoughts welcome, as always.
Jonathan Nieder (1):
tests: let GETTEXT_POISON be disabled at run time

Ævar Arnfjörð Bjarmason (2):
i18n: add no-op _() and N_() wrappers
tests: add GETTEXT_POISON to simulate unfriendly translator

 Makefile      |    9 +++++++++
 cache.h       |    1 +
 gettext.c     |   14 ++++++++++++++
 gettext.h     |   32 ++++++++++++++++++++++++++++++++
 t/test-lib.sh |    9 +++++++++
 5 files changed, 65 insertions(+), 0 deletions(-)
 create mode 100644 gettext.c
 create mode 100644 gettext.h
#89 lore raw

PATCH v2 1/3 i18n: add no-op _() and N_() wrappers

From: Ævar Arnfjörð Bjarmason <[email protected]>

The _ function is meant to be used to translate strings into the user's chosen language.

The N_ macro is a marker for xgettext to find translatable strings in contexts where a function call cannot be used directly, like so:

	const char *unpack_plumbing_errors[NB_UNPACK_TREES_ERROR_TYPES] = {
		/* ERROR_WOULD_OVERWRITE */
		N_("Entry '%s' would be overwritten by merge. Cannot merge."),
	[...]

Its result is still untranslated and should be fed to _ before it is printed.

Making _ a function and N_ a macro avoids the temptation to use _("foo") instead of N_("foo") as a string literal.

Define these in a new gettext.h and include it in cache.h, so they can be used everywhere. They just return their argument for now. To split up the gettext series I'm first submitting patches to gettextize the source tree before I add any of the Makefile and C changes needed to actually use translations.

---
 Makefile  |    1 +
 cache.h   |    1 +
 gettext.h |   26 ++++++++++++++++++++++++++
 3 files changed, 28 insertions(+), 0 deletions(-)
 create mode 100644 gettext.h
Makefile +1 -0
index ade7923..c153f45 100644
@@ -515,6 +515,7 @@ LIB_H += diff.h
 LIB_H += dir.h
 LIB_H += exec_cmd.h
 LIB_H += fsck.h
+LIB_H += gettext.h
 LIB_H += git-compat-util.h
 LIB_H += graph.h
 LIB_H += grep.h
cache.h +1 -0
index 3abf895..a465f38 100644
@@ -5,6 +5,7 @@
 #include "strbuf.h"
 #include "hash.h"
 #include "advice.h"
+#include "gettext.h"
 
 #include SHA1_HEADER
 #ifndef git_SHA_CTX
gettext.h new file +26 -0
new file mode 100644
index 0000000..dc44825
@@ -0,0 +1,26 @@
+#ifndef GETTEXT_H
+#define GETTEXT_H
+
+/*
+ * Copyright (c) 2010 Ævar Arnfjörð Bjarmason
+ *
+ * This is a skeleton no-op implementation of gettext for Git.
+ * You can replace it with something that uses libintl.h and wraps
+ * gettext() to try out the translations.
+ */
+
+#ifdef _
+#error "namespace conflict: '_' is pre-defined?"
+#endif
+
+#define FORMAT_PRESERVING(n) __attribute__((format_arg(n)))
+
+static inline FORMAT_PRESERVING(1) const char *_(const char *msgid)
+{
+	return msgid;
+}
+
+/* Mark msgid for translation but do not translate it. */
+#define N_(msgid) (msgid)
+
+#endif
Signature · 1 line
1.7.4.1
#90 lore raw

PATCH v2 2/3 tests: add GETTEXT_POISON to simulate unfriendly translator

In reply to Jonathan Nieder

From: Ævar Arnfjörð Bjarmason <[email protected]>

Add a new GETTEXT_POISON Makefile parameter. When it is set, every invocation of _(s) will return a nonsense string instead of 's' or an actual translation of 's'. By setting this parameter, we can make sure that none of the strings marked for translation are functionally important.

When tests are checking specific (US English) output from Git, they should add a C_LOCALE_OUTPUT prerequisite. Running through tests in this way can help to find messages that should not be translated because they are part of the git plumbing.

The poison string is "# GETTEXT POISON #", so it is still a valid comment that is safe to put at the end of the message shown by 'git commit --amend' and so on. That simplifies life until git can learn to add the "# " comment markers itself instead of relying on translators to remember them.

---
 Makefile      |    7 +++++++
 gettext.h     |    8 +++++++-
 t/test-lib.sh |    3 +++
 3 files changed, 17 insertions(+), 1 deletions(-)
Makefile +7 -0
index c153f45..c348bb7 100644
@@ -216,6 +216,9 @@ all::
 #
 # Define NO_REGEX if you have no or inferior regex support in your C library.
 #
+# Define GETTEXT_POISON if you are debugging the choice of strings marked
+# for translation.  This will turn all strings that use gettext into gibberish.
+#
 # Define JSMIN to point to JavaScript minifier that functions as
 # a filter to have gitweb.js minified.
 #
@@ -1370,6 +1373,9 @@ endif
 ifdef NO_SYMLINK_HEAD
 	BASIC_CFLAGS += -DNO_SYMLINK_HEAD
 endif
+ifdef GETTEXT_POISON
+	BASIC_CFLAGS += -DGETTEXT_POISON
+endif
 ifdef NO_STRCASESTR
 	COMPAT_CFLAGS += -DNO_STRCASESTR
 	COMPAT_OBJS += compat/strcasestr.o
@@ -2089,6 +2095,7 @@ endif
 ifdef GIT_TEST_CMP_USE_COPIED_CONTEXT
 	@echo GIT_TEST_CMP_USE_COPIED_CONTEXT=YesPlease >>$@
 endif
+	@echo GETTEXT_POISON=\''$(subst ','\'',$(subst ','\'',$(GETTEXT_POISON)))'\' >>$@
 
 ### Detect Tck/Tk interpreter path changes
 ifndef NO_TCLTK
gettext.h +7 -1
index dc44825..6daa57c 100644
@@ -15,9 +15,15 @@
 
 #define FORMAT_PRESERVING(n) __attribute__((format_arg(n)))
 
+#ifdef GETTEXT_POISON
+#define use_poison() 1
+#else
+#define use_poison() 0
+#endif
+
 static inline FORMAT_PRESERVING(1) const char *_(const char *msgid)
 {
-	return msgid;
+	return use_poison() ? "# GETTEXT POISON #" : msgid;
 }
 
 /* Mark msgid for translation but do not translate it. */
t/test-lib.sh +3 -0
index 0fdc541..0840e4a 100644
@@ -1079,6 +1079,9 @@ esac
 test -z "$NO_PERL" && test_set_prereq PERL
 test -z "$NO_PYTHON" && test_set_prereq PYTHON
 
+# Can we rely on git's output in the C locale?
+test -z "$GETTEXT_POISON" && test_set_prereq C_LOCALE_OUTPUT
+
 # test whether the filesystem supports symbolic links
 ln -s x y 2>/dev/null && test -h y 2>/dev/null && test_set_prereq SYMLINKS
 rm -f y
Signature · 1 line
1.7.4.1
#91 lore raw

PATCH v2 3/3 tests: let GETTEXT_POISON be disabled at run time

In reply to Jonathan Nieder

Do not poison translations unless the GIT_GETTEXT_POISON environment variable is set. This way, a copy of git with GETTEXT_POISON set is still generally usable and testers can avoid building two copies of git to compare behavior with and without poison.

---
Thanks again for your help. Hopefully that turned out okay. Please feel free to ack or complain to indicate either way.

 Makefile      |    1 +
 gettext.c     |   14 ++++++++++++++
 gettext.h     |    2 +-
 t/test-lib.sh |    8 +++++++-
 4 files changed, 23 insertions(+), 2 deletions(-)
 create mode 100644 gettext.c
Makefile +1 -0
index c348bb7..142ed86 100644
@@ -1374,6 +1374,7 @@ ifdef NO_SYMLINK_HEAD
 	BASIC_CFLAGS += -DNO_SYMLINK_HEAD
 endif
 ifdef GETTEXT_POISON
+	LIB_OBJS += gettext.o
 	BASIC_CFLAGS += -DGETTEXT_POISON
 endif
 ifdef NO_STRCASESTR
gettext.c new file +14 -0
new file mode 100644
index 0000000..9688c8b
@@ -0,0 +1,14 @@
+/*
+ * Copyright (c) 2010 Ævar Arnfjörð Bjarmason
+ */
+
+#include "git-compat-util.h"
+#include "gettext.h"
+
+int use_poison(void)
+{
+	static int poison_requested = -1;
+	if (poison_requested == -1)
+		poison_requested = getenv("GIT_GETTEXT_POISON") ? 1 : 0;
+	return poison_requested;
+}
gettext.h +1 -1
index 6daa57c..051bf11 100644
@@ -16,7 +16,7 @@
 #define FORMAT_PRESERVING(n) __attribute__((format_arg(n)))
 
 #ifdef GETTEXT_POISON
-#define use_poison() 1
+extern int use_poison(void);
 #else
 #define use_poison() 0
 #endif
t/test-lib.sh +7 -1
index 0840e4a..f4c1e04 100644
@@ -1080,7 +1080,13 @@ test -z "$NO_PERL" && test_set_prereq PERL
 test -z "$NO_PYTHON" && test_set_prereq PYTHON
 
 # Can we rely on git's output in the C locale?
-test -z "$GETTEXT_POISON" && test_set_prereq C_LOCALE_OUTPUT
+if test -n "$GETTEXT_POISON"
+then
+	GIT_GETTEXT_POISON=YesPlease
+	export GIT_GETTEXT_POISON
+else
+	test_set_prereq C_LOCALE_OUTPUT
+fi
 
 # test whether the filesystem supports symbolic links
 ln -s x y 2>/dev/null && test -h y 2>/dev/null && test_set_prereq SYMLINKS
Signature · 1 line
1.7.4.1
#92 lore raw

v3 cover Mark "init", "clone", and "add" output for translation

In reply to Jonathan Nieder

Hi again,

To make the primitives introduced by v2 more concrete, here's a series including a few gettextization patches. I don't plan to send more of these unless there is some agreement that the basic structure is right. Maybe by next time I'll hunker down and write myself a tool to check that a commit only inserts "_("-")" pairs (maybe using diff --word-diff?)

This series still includes the skeleton gettext.h wrapper.

Changes from v1:

- clearer commit messages, hopefully
- clearer documentation for GETTEXT_POISON in the makefile

Please feel free to try it out, complain, ack, send patches, and so on.

Jonathan Nieder (2):
i18n: do not poison translations unless GIT_GETTEXT_POISON envvar is
set
update-index --refresh --porcelain: add missing const

Ævar Arnfjörð Bjarmason (13):
i18n: add no-op _() and N_() wrappers
tests: add GETTEXT_POISON to simulate unfriendly translator
Makefile: "pot" target to extract messages marked for translation
init: mark basic messages for translation
init: mark "Initialized [...] repository" for translation
clone: mark basic messages for translation
clone: split "Cloning into" message into two
clone: mark "Cloning into" message for translation
add: mark basic messages for translation
add: mark "The following paths are ignored" for translation
add: mark "did not match any files" for translation add -u --verbose: mark "remove '%s'" for translation add --refresh --verbose: mark "Unstaged changes" heading for
translation

 Makefile               |   27 ++++++++++++++++++++
 builtin/add.c          |   50 +++++++++++++++++++-------------------
 builtin/clone.c        |   63 +++++++++++++++++++++++++----------------------
 builtin/init-db.c      |   58 ++++++++++++++++++++++++-------------------
 cache.h                |    3 +-
 gettext.c              |   14 ++++++++++
 gettext.h              |   32 ++++++++++++++++++++++++
 po/.gitignore          |    1 +
 read-cache.c           |    4 +-
 t/t0001-init.sh        |    2 +-
 t/t2200-add-update.sh  |    2 +-
 t/t2204-add-ignored.sh |   37 +++++++++++++++++++---------
 t/t3700-add.sh         |   13 +++++++--
 t/t5601-clone.sh       |    2 +-
 t/test-lib.sh          |    9 +++++++
 15 files changed, 215 insertions(+), 102 deletions(-)
 create mode 100644 gettext.c
 create mode 100644 gettext.h
 create mode 100644 po/.gitignore
#93 lore raw

PATCH v3 1/15 i18n: add no-op _() and N_() wrappers

From: Ævar Arnfjörð Bjarmason <[email protected]>

The _ function is for translating strings into the user's chosen language. The N_ macro just marks translatable strings for the xgettext(1) tool without translating them; it is intended for use in contexts where a function call cannot be used. So, for example:

	fprintf(stderr, _("Expansion of alias '%s' failed; "
		"'%s' is not a git command\n"),
		cmd, argv[0]);

and

	const char *unpack_plumbing_errors[NB_UNPACK_TREES_ERROR_TYPES] = {
		/* ERROR_WOULD_OVERWRITE */
		N_("Entry '%s' would be overwritten by merge. Cannot merge."),
	[...]

Define such _ and N_ in a new gettext.h and include it in cache.h, so they can be used everywhere. Each just returns its argument for now. _ is a function rather than a macro like N_ to avoid the temptation to use _("foo") as a string literal (which would be a compile-time error once _(s) expands to an expression for the translation of s).

---
 Makefile  |    1 +
 cache.h   |    1 +
 gettext.h |   26 ++++++++++++++++++++++++++
 3 files changed, 28 insertions(+), 0 deletions(-)
 create mode 100644 gettext.h
Makefile +1 -0
index ade7923..c153f45 100644
@@ -515,6 +515,7 @@ LIB_H += diff.h
 LIB_H += dir.h
 LIB_H += exec_cmd.h
 LIB_H += fsck.h
+LIB_H += gettext.h
 LIB_H += git-compat-util.h
 LIB_H += graph.h
 LIB_H += grep.h
cache.h +1 -0
index 3abf895..a465f38 100644
@@ -5,6 +5,7 @@
 #include "strbuf.h"
 #include "hash.h"
 #include "advice.h"
+#include "gettext.h"
 
 #include SHA1_HEADER
 #ifndef git_SHA_CTX
gettext.h new file +26 -0
new file mode 100644
index 0000000..dc44825
@@ -0,0 +1,26 @@
+#ifndef GETTEXT_H
+#define GETTEXT_H
+
+/*
+ * Copyright (c) 2010 Ævar Arnfjörð Bjarmason
+ *
+ * This is a skeleton no-op implementation of gettext for Git.
+ * You can replace it with something that uses libintl.h and wraps
+ * gettext() to try out the translations.
+ */
+
+#ifdef _
+#error "namespace conflict: '_' is pre-defined?"
+#endif
+
+#define FORMAT_PRESERVING(n) __attribute__((format_arg(n)))
+
+static inline FORMAT_PRESERVING(1) const char *_(const char *msgid)
+{
+	return msgid;
+}
+
+/* Mark msgid for translation but do not translate it. */
+#define N_(msgid) (msgid)
+
+#endif
Signature · 1 line
1.7.4.1
#94 lore raw

PATCH v3 2/15 tests: add GETTEXT_POISON to simulate unfriendly translator

In reply to Jonathan Nieder

From: Ævar Arnfjörð Bjarmason <[email protected]>

Add a new GETTEXT_POISON compile-time parameter to make _(msg) always return gibberish. So now you can run

make GETTEXT_POISON=YesPlease

to get a copy of git that functions correctly (one hopes) but produces output that is in nobody's native language at all.

This is a debugging aid for people who are working on the i18n part of the system, to make sure that they are not marking plumbing messages that should never be translated with _().

As new strings get marked for translation, naturally a number of tests will be broken in this mode. Tests that depend on output from Porcelain will need to be marked with the new C_LOCALE_OUTPUT test prerequisite. Newly failing tests that do not depend on output from Porcelain would be bugs due to messages that should not have been marked for translation.

---
 Makefile      |    7 +++++++
 gettext.h     |    8 +++++++-
 t/test-lib.sh |    3 +++
 3 files changed, 17 insertions(+), 1 deletions(-)
Makefile +7 -0
index c153f45..c348bb7 100644
@@ -216,6 +216,9 @@ all::
 #
 # Define NO_REGEX if you have no or inferior regex support in your C library.
 #
+# Define GETTEXT_POISON if you are debugging the choice of strings marked
+# for translation.  This will turn all strings that use gettext into gibberish.
+#
 # Define JSMIN to point to JavaScript minifier that functions as
 # a filter to have gitweb.js minified.
 #
@@ -1370,6 +1373,9 @@ endif
 ifdef NO_SYMLINK_HEAD
 	BASIC_CFLAGS += -DNO_SYMLINK_HEAD
 endif
+ifdef GETTEXT_POISON
+	BASIC_CFLAGS += -DGETTEXT_POISON
+endif
 ifdef NO_STRCASESTR
 	COMPAT_CFLAGS += -DNO_STRCASESTR
 	COMPAT_OBJS += compat/strcasestr.o
@@ -2089,6 +2095,7 @@ endif
 ifdef GIT_TEST_CMP_USE_COPIED_CONTEXT
 	@echo GIT_TEST_CMP_USE_COPIED_CONTEXT=YesPlease >>$@
 endif
+	@echo GETTEXT_POISON=\''$(subst ','\'',$(subst ','\'',$(GETTEXT_POISON)))'\' >>$@
 
 ### Detect Tck/Tk interpreter path changes
 ifndef NO_TCLTK
gettext.h +7 -1
index dc44825..68e3a19 100644
@@ -15,9 +15,15 @@
 
 #define FORMAT_PRESERVING(n) __attribute__((format_arg(n)))
 
+#ifdef GETTEXT_POISON
+#define use_poison() 1
+#else
+#define use_poison() 0
+#endif
+
 static inline FORMAT_PRESERVING(1) const char *_(const char *msgid)
 {
-	return msgid;
+	return use_poison() ? "Malkovich" : msgid;
 }
 
 /* Mark msgid for translation but do not translate it. */
t/test-lib.sh +3 -0
index 0fdc541..0840e4a 100644
@@ -1079,6 +1079,9 @@ esac
 test -z "$NO_PERL" && test_set_prereq PERL
 test -z "$NO_PYTHON" && test_set_prereq PYTHON
 
+# Can we rely on git's output in the C locale?
+test -z "$GETTEXT_POISON" && test_set_prereq C_LOCALE_OUTPUT
+
 # test whether the filesystem supports symbolic links
 ln -s x y 2>/dev/null && test -h y 2>/dev/null && test_set_prereq SYMLINKS
 rm -f y
Signature · 1 line
1.7.4.1
#95 lore raw

Re: [PATCH 02/15] tests: add GETTEXT_POISON to simulate unfriendly translator

Quoted 5 lines · Jonathan Nieder

 static inline FORMAT_PRESERVING(1) const char *_(const char *msgid) {
-       return msgid;
+       return use_poison() ? "Malkovich" : msgid;
 }

Why did you change this from "# GETTEXT POISON #" to "Malkovich"?

The reason it started with a "#" is because many rebase tests were broken otherwise.

The reason it was in all caps was so that when I run the tests in debug mode it's really easy to see at a glance if I'm encountering these strings.

Do those tests still pass with this new string, and is there any reason to change this?

#96 lore raw

Re: [PATCH 02/15] tests: add GETTEXT_POISON to simulate unfriendly translator

Hi Ævar,

Quoted 1 line · Ævar Arnfjörð Bjarmason

Why did you change this from "# GETTEXT POISON #" to "Malkovich"?

I forgot to mention that change in the cover letter --- thanks for a reminder.

Quoted 2 lines

Do those tests still pass with this new string, and is there any reason to change this?

Yes, all the tests in this series still pass (on this machine, at least). Which is why I changed it --- it is a lot easier to explain having the '#' at the beginning and end of a magic string as part of a patch that would break tests without that change.

Of course the specific string is arbitrary. All caps sounds fine to me, too.

Hope that helps,
Jonathan

#97 lore raw

PATCH v3 3/15 i18n: do not poison translations unless GIT_GETTEXT_POISON envvar is set

In reply to Jonathan Nieder

Tweak the GETTEXT_POISON facility so it is activated at run time instead of compile time. If the GIT_GETTEXT_POISON environment variable is set, _(msg) will result in gibberish as before; but if the GIT_GETTEXT_POISON variable is not set, it will return the message for human-readable output. So the behavior of mistranslated and untranslated git can be compared without rebuilding git in between.

For simplicity we always set the GIT_GETTEXT_POISON variable in tests.

This does not affect builds without the GETTEXT_POISON compile-time option set, so non-i18n git will not be slowed down.

---
 Makefile      |    5 ++++-
 gettext.c     |   14 ++++++++++++++
 gettext.h     |    2 +-
 t/test-lib.sh |    8 +++++++-
 4 files changed, 26 insertions(+), 3 deletions(-)
 create mode 100644 gettext.c
Makefile +4 -1
index c348bb7..4e9d935 100644
@@ -217,7 +217,9 @@ all::
 # Define NO_REGEX if you have no or inferior regex support in your C library.
 #
 # Define GETTEXT_POISON if you are debugging the choice of strings marked
-# for translation.  This will turn all strings that use gettext into gibberish.
+# for translation.  In a GETTEXT_POISON build, you can turn all strings marked
+# for translation into gibberish by setting the GIT_GETTEXT_POISON variable
+# (to any value) in your environment.
 #
 # Define JSMIN to point to JavaScript minifier that functions as
 # a filter to have gitweb.js minified.
@@ -1374,6 +1376,7 @@ ifdef NO_SYMLINK_HEAD
 	BASIC_CFLAGS += -DNO_SYMLINK_HEAD
 endif
 ifdef GETTEXT_POISON
+	LIB_OBJS += gettext.o
 	BASIC_CFLAGS += -DGETTEXT_POISON
 endif
 ifdef NO_STRCASESTR
gettext.c new file +14 -0
new file mode 100644
index 0000000..9688c8b
@@ -0,0 +1,14 @@
+/*
+ * Copyright (c) 2010 Ævar Arnfjörð Bjarmason
+ */
+
+#include "git-compat-util.h"
+#include "gettext.h"
+
+int use_poison(void)
+{
+	static int poison_requested = -1;
+	if (poison_requested == -1)
+		poison_requested = getenv("GIT_GETTEXT_POISON") ? 1 : 0;
+	return poison_requested;
+}
gettext.h +1 -1
index 68e3a19..4d2338b 100644
@@ -16,7 +16,7 @@
 #define FORMAT_PRESERVING(n) __attribute__((format_arg(n)))
 
 #ifdef GETTEXT_POISON
-#define use_poison() 1
+extern int use_poison(void);
 #else
 #define use_poison() 0
 #endif
t/test-lib.sh +7 -1
index 0840e4a..f4c1e04 100644
@@ -1080,7 +1080,13 @@ test -z "$NO_PERL" && test_set_prereq PERL
 test -z "$NO_PYTHON" && test_set_prereq PYTHON
 
 # Can we rely on git's output in the C locale?
-test -z "$GETTEXT_POISON" && test_set_prereq C_LOCALE_OUTPUT
+if test -n "$GETTEXT_POISON"
+then
+	GIT_GETTEXT_POISON=YesPlease
+	export GIT_GETTEXT_POISON
+else
+	test_set_prereq C_LOCALE_OUTPUT
+fi
 
 # test whether the filesystem supports symbolic links
 ln -s x y 2>/dev/null && test -h y 2>/dev/null && test_set_prereq SYMLINKS
Signature · 1 line
1.7.4.1
#98 lore raw

PATCH v3 4/15 Makefile: "pot" target to extract messages marked for translation

In reply to Jonathan Nieder

From: Ævar Arnfjörð Bjarmason <[email protected]>
Date: Tue, 31 Aug 2010 16:35:16 +0000

Add rules to generate a template (po/git.pot) listing messages marked for translation in the C portion of git.

To get started translating, just run "make pot".

---
 Makefile      |   16 ++++++++++++++++
 po/.gitignore |    1 +
 2 files changed, 17 insertions(+), 0 deletions(-)
 create mode 100644 po/.gitignore
Makefile +16 -0
index 4e9d935..1cc6c60 100644
@@ -321,6 +321,7 @@ INSTALL = install
 RPMBUILD = rpmbuild
 TCL_PATH = tclsh
 TCLTK_PATH = wish
+XGETTEXT = xgettext
 PTHREAD_LIBS = -lpthread
 PTHREAD_CFLAGS =
 GCOV = gcov
@@ -1590,6 +1591,7 @@ ifndef V
 	QUIET_BUILT_IN = @echo '   ' BUILTIN $@;
 	QUIET_GEN      = @echo '   ' GEN $@;
 	QUIET_LNCP     = @echo '   ' LN/CP $@;
+	QUIET_XGETTEXT = @echo '   ' XGETTEXT $@;
 	QUIET_GCOV     = @echo '   ' GCOV $@;
 	QUIET_SUBDIR0  = +@subdir=
 	QUIET_SUBDIR1  = ;$(NO_SUBDIR) echo '   ' SUBDIR $$subdir; \
@@ -2057,6 +2059,20 @@ info:
 pdf:
 	$(MAKE) -C Documentation pdf
 
+XGETTEXT_FLAGS = \
+	--force-po \
+	--add-comments \
+	--msgid-bugs-address="Git Mailing List <[email protected]>" \
+	--from-code=UTF-8
+XGETTEXT_FLAGS_C = $(XGETTEXT_FLAGS) --keyword=_ --keyword=N_ --language=C
+LOCALIZED_C := $(C_OBJ:o=c)
+
+po/git.pot: $(LOCALIZED_C)
+	$(QUIET_XGETTEXT)$(XGETTEXT) -o$@+ $(XGETTEXT_FLAGS_C) $(LOCALIZED_C) && \
+	mv $@+ $@
+
+pot: po/git.pot
+
 $(ETAGS_TARGET): FORCE
 	$(RM) $(ETAGS_TARGET)
 	$(FIND) . -name '*.[hcS]' -print | xargs etags -a -o $(ETAGS_TARGET)
po/.gitignore new file +1 -0
new file mode 100644
index 0000000..a242a86
@@ -0,0 +1 @@
+/git.pot
Signature · 1 line
1.7.4.1
#99 lore raw

Re: [PATCH 04/15] Makefile: "pot" target to extract messages marked for translation

Quoted 5 lines · Jonathan Nieder

From: Ævar Arnfjörð Bjarmason <[email protected]>
Date: Tue, 31 Aug 2010 16:35:16 +0000

Add rules to generate a template (po/git.pot) listing messages marked for translation in the C portion of git.

Can we please not apply this? I have a series of patches for this that I'm submitting later, it's easier for me if don't have conflicts with stuff like this.

I don't think it's a big deal that we have _() C translations in the source for some time without the capability to generate POT files from them.

#100 lore raw

Re: [PATCH 04/15] Makefile: "pot" target to extract messages marked for translation

Quoted 6 lines · Ævar Arnfjörð Bjarmason
Quoted 2 lines · Jonathan Nieder

Add rules to generate a template (po/git.pot) listing messages marked for translation in the C portion of git.

Can we please not apply this?

I included it in the series because I used it to test, for what it's worth.

I also think it could be useful to translators, so they could work against git.git directly once it has enough translatable strings. That sounds valuable to me.

But I have no strong preference about what actually gets applied to git.git in this case.

#101 lore raw

Re: [PATCH 04/15] Makefile: "pot" target to extract messages marked for translation

Quoted 6 lines · Jonathan Nieder
Quoted 5 lines · Ævar Arnfjörð Bjarmason
Quoted 2 lines · Jonathan Nieder

Add rules to generate a template (po/git.pot) listing messages marked for translation in the C portion of git.

Quoted 8 lines
Quoted 1 line

Can we please not apply this?

I included it in the series because I used it to test, for what it's worth.

I also think it could be useful to translators, so they could work against git.git directly once it has enough translatable strings. That sounds valuable to me.

Yeah it's valuable, but I'm just optimizing this for the time I can spent on it, I already have a patch series that has these things. It's much easier if I can:

1. Apply C translations
2. Apply Shell translations
3. Apply Translation documentation / po/* stuff

Then later:

4. Add actual gettext support

But not have to deal with bits of #3 while I do #1 and #2. That's all.

Since hopefully we'll get to #3 relatively quickly I think that's OK.

#102 lore raw

PATCH v3 5/15 init: mark basic messages for translation

In reply to Jonathan Nieder

From: Ævar Arnfjörð Bjarmason <[email protected]>
Date: Sat, 28 Aug 2010 15:04:43 +0000

Change the user visible strings in init-db.c to use gettext localizations. This only converts messages which needed to be changed from "foo" to _("foo"), and didn't need any TRANSLATORS comments.

I haven't marked the messages in init_db_usage or init_db_options for translation, since that would require additional changes in parse-options.c. Those can be done later.

---
 builtin/init-db.c |   46 +++++++++++++++++++++++-----------------------
 1 files changed, 23 insertions(+), 23 deletions(-)
builtin/init-db.c +23 -23
index 4f5348e..f7ddf5b 100644
@@ -31,7 +31,7 @@ static void safe_create_dir(const char *dir, int share)
 		}
 	}
 	else if (share && adjust_shared_perm(dir))
-		die("Could not make %s writable by group", dir);
+		die(_("Could not make %s writable by group"), dir);
 }
 
 static void copy_templates_1(char *path, int baselen,
@@ -58,25 +58,25 @@ static void copy_templates_1(char *path, int baselen,
 		namelen = strlen(de->d_name);
 		if ((PATH_MAX <= baselen + namelen) ||
 		    (PATH_MAX <= template_baselen + namelen))
-			die("insanely long template name %s", de->d_name);
+			die(_("insanely long template name %s"), de->d_name);
 		memcpy(path + baselen, de->d_name, namelen+1);
 		memcpy(template + template_baselen, de->d_name, namelen+1);
 		if (lstat(path, &st_git)) {
 			if (errno != ENOENT)
-				die_errno("cannot stat '%s'", path);
+				die_errno(_("cannot stat '%s'"), path);
 		}
 		else
 			exists = 1;
 
 		if (lstat(template, &st_template))
-			die_errno("cannot stat template '%s'", template);
+			die_errno(_("cannot stat template '%s'"), template);
 
 		if (S_ISDIR(st_template.st_mode)) {
 			DIR *subdir = opendir(template);
 			int baselen_sub = baselen + namelen;
 			int template_baselen_sub = template_baselen + namelen;
 			if (!subdir)
-				die_errno("cannot opendir '%s'", template);
+				die_errno(_("cannot opendir '%s'"), template);
 			path[baselen_sub++] =
 				template[template_baselen_sub++] = '/';
 			path[baselen_sub] =
@@ -93,20 +93,20 @@ static void copy_templates_1(char *path, int baselen,
 			int len;
 			len = readlink(template, lnk, sizeof(lnk));
 			if (len < 0)
-				die_errno("cannot readlink '%s'", template);
+				die_errno(_("cannot readlink '%s'"), template);
 			if (sizeof(lnk) <= len)
-				die("insanely long symlink %s", template);
+				die(_("insanely long symlink %s"), template);
 			lnk[len] = 0;
 			if (symlink(lnk, path))
-				die_errno("cannot symlink '%s' '%s'", lnk, path);
+				die_errno(_("cannot symlink '%s' '%s'"), lnk, path);
 		}
 		else if (S_ISREG(st_template.st_mode)) {
 			if (copy_file(path, template, st_template.st_mode))
-				die_errno("cannot copy '%s' to '%s'", template,
+				die_errno(_("cannot copy '%s' to '%s'"), template,
 					  path);
 		}
 		else
-			error("ignoring template %s", template);
+			error(_("ignoring template %s"), template);
 	}
 }
 
@@ -129,7 +129,7 @@ static void copy_templates(const char *template_dir)
 		return;
 	template_len = strlen(template_dir);
 	if (PATH_MAX <= (template_len+strlen("/config")))
-		die("insanely long template path %s", template_dir);
+		die(_("insanely long template path %s"), template_dir);
 	strcpy(template_path, template_dir);
 	if (template_path[template_len-1] != '/') {
 		template_path[template_len++] = '/';
@@ -137,7 +137,7 @@ static void copy_templates(const char *template_dir)
 	}
 	dir = opendir(template_path);
 	if (!dir) {
-		warning("templates not found %s", template_dir);
+		warning(_("templates not found %s"), template_dir);
 		return;
 	}
 
@@ -150,8 +150,8 @@ static void copy_templates(const char *template_dir)
 
 	if (repository_format_version &&
 	    repository_format_version != GIT_REPO_VERSION) {
-		warning("not copying templates of "
-			"a wrong format version %d from '%s'",
+		warning(_("not copying templates of "
+			"a wrong format version %d from '%s'"),
 			repository_format_version,
 			template_dir);
 		closedir(dir);
@@ -188,7 +188,7 @@ static int create_default_files(const char *template_path)
 	int filemode;
 
 	if (len > sizeof(path)-50)
-		die("insane git directory %s", git_dir);
+		die(_("insane git directory %s"), git_dir);
 	memcpy(path, git_dir, len);
 
 	if (len && path[len-1] != '/')
@@ -375,7 +375,7 @@ static int guess_repository_type(const char *git_dir)
 	if (!strcmp(".", git_dir))
 		return 1;
 	if (!getcwd(cwd, sizeof(cwd)))
-		die_errno("cannot tell cwd");
+		die_errno(_("cannot tell cwd"));
 	if (!strcmp(git_dir, cwd))
 		return 1;
 	/*
@@ -450,18 +450,18 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
 					errno = EEXIST;
 					/* fallthru */
 				case -1:
-					die_errno("cannot mkdir %s", argv[0]);
+					die_errno(_("cannot mkdir %s"), argv[0]);
 					break;
 				default:
 					break;
 				}
 				shared_repository = saved;
 				if (mkdir(argv[0], 0777) < 0)
-					die_errno("cannot mkdir %s", argv[0]);
+					die_errno(_("cannot mkdir %s"), argv[0]);
 				mkdir_tried = 1;
 				goto retry;
 			}
-			die_errno("cannot chdir to %s", argv[0]);
+			die_errno(_("cannot chdir to %s"), argv[0]);
 		}
 	} else if (0 < argc) {
 		usage(init_db_usage[0]);
@@ -483,8 +483,8 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
 	git_dir = getenv(GIT_DIR_ENVIRONMENT);
 	work_tree = getenv(GIT_WORK_TREE_ENVIRONMENT);
 	if ((!git_dir || is_bare_repository_cfg == 1) && work_tree)
-		die("%s (or --work-tree=<directory>) not allowed without "
-		    "specifying %s (or --git-dir=<directory>)",
+		die(_("%s (or --work-tree=<directory>) not allowed without "
+			  "specifying %s (or --git-dir=<directory>)"),
 		    GIT_WORK_TREE_ENVIRONMENT,
 		    GIT_DIR_ENVIRONMENT);
 
@@ -509,14 +509,14 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
 		if (!git_work_tree_cfg) {
 			git_work_tree_cfg = xcalloc(PATH_MAX, 1);
 			if (!getcwd(git_work_tree_cfg, PATH_MAX))
-				die_errno ("Cannot access current working directory");
+				die_errno (_("Cannot access current working directory"));
 		}
 		if (work_tree)
 			set_git_work_tree(make_absolute_path(work_tree));
 		else
 			set_git_work_tree(git_work_tree_cfg);
 		if (access(get_git_work_tree(), X_OK))
-			die_errno ("Cannot access work tree '%s'",
+			die_errno (_("Cannot access work tree '%s'"),
 				   get_git_work_tree());
 	}
 	else {
Signature · 1 line
1.7.4.1
#103 lore raw

PATCH v3 6/15 init: mark "Initialized [...] repository" for translation

In reply to Jonathan Nieder

From: Ævar Arnfjörð Bjarmason <[email protected]>
Date: Sat, 28 Aug 2010 15:32:15 +0000

These messages could benefit from splitting up. An earlier version of this patch began like this:

    const char *reinit_shared   = _("Reinitialized existing shared Git repository in %s\n");
    const char *init_shared     = _("Initialized empty shared Git repository in %s\n");
    const char *reinit_noshared = _("Reinitialized existing Git repository in %s\n");
    const char *init_noshared   = _("Initialized empty Git repository in %s\n");

But in the first round of gettextization I'm aiming to keep code changes to a minimum for ease of review. So just add a comment explaining to translators how the sprintf format gets used so they can cope for now if the language's grammar allows.

---
I heard a rumor that this style of TRANSLATORS comment doesn't pass unscathed through xgettext, but when I tried it with "make pot" it worked okay. Ideas?

 builtin/init-db.c |   12 +++++++++---
 t/t0001-init.sh   |    2 +-
 2 files changed, 10 insertions(+), 4 deletions(-)
builtin/init-db.c +9 -3
index f7ddf5b..e0e5ce3 100644
@@ -354,9 +354,15 @@ int init_db(const char *template_dir, unsigned int flags)
 	if (!(flags & INIT_DB_QUIET)) {
 		const char *git_dir = get_git_dir();
 		int len = strlen(git_dir);
-		printf("%s%s Git repository in %s%s\n",
-		       reinit ? "Reinitialized existing" : "Initialized empty",
-		       shared_repository ? " shared" : "",
+
+		/*
+		 * TRANSLATORS: The first '%s' is either "Reinitialized
+		 * existing" or "Initialized empty", the second " shared" or
+		 * "", and the last '%s%s' is the verbatim directory name.
+		 */
+		printf(_("%s%s Git repository in %s%s\n"),
+		       reinit ? _("Reinitialized existing") : _("Initialized empty"),
+		       shared_repository ? _(" shared") : "",
 		       git_dir, len && git_dir[len-1] != '/' ? "/" : "");
 	}
 
t/t0001-init.sh +1 -1
index f684993..dd4c00d 100755
@@ -180,7 +180,7 @@ test_expect_success 'GIT_DIR & GIT_WORK_TREE (2)' '
 	fi
 '
 
-test_expect_success 'reinit' '
+test_expect_success C_LOCALE_OUTPUT 'reinit' '
 
 	(
 		sane_unset GIT_CONFIG GIT_WORK_TREE GIT_CONFIG &&
Signature · 1 line
1.7.4.1
#104 lore raw

PATCH v3 7/15 clone: mark basic messages for translation

In reply to Jonathan Nieder

From: Ævar Arnfjörð Bjarmason <[email protected]>
Date: Wed, 1 Sep 2010 15:44:13 +0000

---
 builtin/clone.c |   54 +++++++++++++++++++++++++++---------------------------
 1 files changed, 27 insertions(+), 27 deletions(-)
builtin/clone.c +27 -27
index 60d9a64..f46d09b 100644
@@ -208,7 +208,7 @@ static void setup_reference(const char *repo)
 	if (is_directory(mkpath("%s/.git/objects", ref_git)))
 		ref_git = mkpath("%s/.git", ref_git);
 	else if (!is_directory(mkpath("%s/objects", ref_git)))
-		die("reference repository '%s' is not a local directory.",
+		die(_("reference repository '%s' is not a local directory."),
 		    option_reference);
 
 	ref_git_copy = xstrdup(ref_git);
@@ -235,15 +235,15 @@ static void copy_or_link_directory(struct strbuf *src, struct strbuf *dest)
 
 	dir = opendir(src->buf);
 	if (!dir)
-		die_errno("failed to open '%s'", src->buf);
+		die_errno(_("failed to open '%s'"), src->buf);
 
 	if (mkdir(dest->buf, 0777)) {
 		if (errno != EEXIST)
-			die_errno("failed to create directory '%s'", dest->buf);
+			die_errno(_("failed to create directory '%s'"), dest->buf);
 		else if (stat(dest->buf, &buf))
-			die_errno("failed to stat '%s'", dest->buf);
+			die_errno(_("failed to stat '%s'"), dest->buf);
 		else if (!S_ISDIR(buf.st_mode))
-			die("%s exists and is not a directory", dest->buf);
+			die(_("%s exists and is not a directory"), dest->buf);
 	}
 
 	strbuf_addch(src, '/');
@@ -257,7 +257,7 @@ static void copy_or_link_directory(struct strbuf *src, struct strbuf *dest)
 		strbuf_setlen(dest, dest_len);
 		strbuf_addstr(dest, de->d_name);
 		if (stat(src->buf, &buf)) {
-			warning ("failed to stat %s\n", src->buf);
+			warning (_("failed to stat %s\n"), src->buf);
 			continue;
 		}
 		if (S_ISDIR(buf.st_mode)) {
@@ -267,16 +267,16 @@ static void copy_or_link_directory(struct strbuf *src, struct strbuf *dest)
 		}
 
 		if (unlink(dest->buf) && errno != ENOENT)
-			die_errno("failed to unlink '%s'", dest->buf);
+			die_errno(_("failed to unlink '%s'"), dest->buf);
 		if (!option_no_hardlinks) {
 			if (!link(src->buf, dest->buf))
 				continue;
 			if (option_local)
-				die_errno("failed to create link '%s'", dest->buf);
+				die_errno(_("failed to create link '%s'"), dest->buf);
 			option_no_hardlinks = 1;
 		}
 		if (copy_file_with_time(dest->buf, src->buf, 0666))
-			die_errno("failed to copy file to '%s'", dest->buf);
+			die_errno(_("failed to copy file to '%s'"), dest->buf);
 	}
 	closedir(dir);
 }
@@ -305,7 +305,7 @@ static const struct ref *clone_local(const char *src_repo,
 	ret = transport_get_remote_refs(transport);
 	transport_disconnect(transport);
 	if (0 <= option_verbosity)
-		printf("done.\n");
+		printf(_("done.\n"));
 	return ret;
 }
 
@@ -387,11 +387,11 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 			     builtin_clone_usage, 0);
 
 	if (argc > 2)
-		usage_msg_opt("Too many arguments.",
+		usage_msg_opt(_("Too many arguments."),
 			builtin_clone_usage, builtin_clone_options);
 
 	if (argc == 0)
-		usage_msg_opt("You must specify a repository to clone.",
+		usage_msg_opt(_("You must specify a repository to clone."),
 			builtin_clone_usage, builtin_clone_options);
 
 	if (option_mirror)
@@ -399,7 +399,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 
 	if (option_bare) {
 		if (option_origin)
-			die("--bare and --origin %s options are incompatible.",
+			die(_("--bare and --origin %s options are incompatible."),
 			    option_origin);
 		option_no_checkout = 1;
 	}
@@ -418,7 +418,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 		repo = repo_name;
 	is_local = path && !is_bundle;
 	if (is_local && option_depth)
-		warning("--depth is ignored in local clones; use file:// instead.");
+		warning(_("--depth is ignored in local clones; use file:// instead."));
 
 	if (argc == 2)
 		dir = xstrdup(argv[1]);
@@ -428,8 +428,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 
 	dest_exists = !stat(dir, &buf);
 	if (dest_exists && !is_empty_dir(dir))
-		die("destination path '%s' already exists and is not "
-			"an empty directory.", dir);
+		die(_("destination path '%s' already exists and is not "
+			"an empty directory."), dir);
 
 	strbuf_addf(&reflog_msg, "clone: from %s", repo);
 
@@ -438,7 +438,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 	else {
 		work_tree = getenv("GIT_WORK_TREE");
 		if (work_tree && !stat(work_tree, &buf))
-			die("working tree '%s' already exists.", work_tree);
+			die(_("working tree '%s' already exists."), work_tree);
 	}
 
 	if (option_bare || work_tree)
@@ -451,10 +451,10 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 	if (!option_bare) {
 		junk_work_tree = work_tree;
 		if (safe_create_leading_directories_const(work_tree) < 0)
-			die_errno("could not create leading directories of '%s'",
+			die_errno(_("could not create leading directories of '%s'"),
 				  work_tree);
 		if (!dest_exists && mkdir(work_tree, 0755))
-			die_errno("could not create work tree dir '%s'.",
+			die_errno(_("could not create work tree dir '%s'."),
 				  work_tree);
 		set_git_work_tree(work_tree);
 	}
@@ -465,7 +465,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 	setenv(CONFIG_ENVIRONMENT, mkpath("%s/config", git_dir), 1);
 
 	if (safe_create_leading_directories_const(git_dir) < 0)
-		die("could not create leading directories of '%s'", git_dir);
+		die(_("could not create leading directories of '%s'"), git_dir);
 	set_git_dir(make_absolute_path(git_dir));
 
 	if (0 <= option_verbosity)
@@ -527,7 +527,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 		transport = transport_get(remote, remote->url[0]);
 
 		if (!transport->get_refs_list || !transport->fetch)
-			die("Don't know how to clone %s", transport->url);
+			die(_("Don't know how to clone %s"), transport->url);
 
 		transport_set_option(transport, TRANS_OPT_KEEP, "yes");
 
@@ -566,8 +566,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 			strbuf_release(&head);
 
 			if (!our_head_points_at) {
-				warning("Remote branch %s not found in "
-					"upstream %s, using HEAD instead",
+				warning(_("Remote branch %s not found in "
+					"upstream %s, using HEAD instead"),
 					option_branch, option_origin);
 				our_head_points_at = remote_head_points_at;
 			}
@@ -576,7 +576,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 			our_head_points_at = remote_head_points_at;
 	}
 	else {
-		warning("You appear to have cloned an empty repository.");
+		warning(_("You appear to have cloned an empty repository."));
 		our_head_points_at = NULL;
 		remote_head_points_at = NULL;
 		remote_head = NULL;
@@ -618,8 +618,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 	} else {
 		/* Nothing to checkout out */
 		if (!option_no_checkout)
-			warning("remote HEAD refers to nonexistent ref, "
-				"unable to checkout.\n");
+			warning(_("remote HEAD refers to nonexistent ref, "
+				"unable to checkout.\n"));
 		option_no_checkout = 1;
 	}
 
@@ -655,7 +655,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 
 		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"));
 
 		err |= run_hook(NULL, "post-checkout", sha1_to_hex(null_sha1),
 				sha1_to_hex(our_head_points_at->old_sha1), "1",
Signature · 1 line
1.7.4.1
#105 lore raw

PATCH v3 8/15 clone: split "Cloning into" message into two

In reply to Jonathan Nieder

From: Ævar Arnfjörð Bjarmason <[email protected]>
Date: Wed, 1 Sep 2010 15:54:30 +0000

Separate the "Cloning into %s" and "Cloning into bare repository %s" messages to make them easier to translate. No noticeable change intended.

---
 builtin/clone.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)
builtin/clone.c +6 -3
index f46d09b..db0240d 100644
@@ -468,9 +468,12 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 		die(_("could not create leading directories of '%s'"), git_dir);
 	set_git_dir(make_absolute_path(git_dir));
 
-	if (0 <= option_verbosity)
-		printf("Cloning into %s%s...\n",
-		       option_bare ? "bare repository " : "", dir);
+	if (0 <= option_verbosity) {
+		if (option_bare)
+			printf("Cloning into bare repository %s...\n", dir);
+		else
+			printf("Cloning into %s...\n", dir);
+	}
 	init_db(option_template, INIT_DB_QUIET);
 
 	/*
Signature · 1 line
1.7.4.1
#106 lore raw

PATCH v3 9/15 clone: mark "Cloning into" message for translation

In reply to Jonathan Nieder

From: Ævar Arnfjörð Bjarmason <[email protected]>
Date: Wed, 1 Sep 2010 15:54:30 +0000

---
 builtin/clone.c  |    4 ++--
 t/t5601-clone.sh |    2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
builtin/clone.c +2 -2
index db0240d..b9394c4 100644
@@ -470,9 +470,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 
 	if (0 <= option_verbosity) {
 		if (option_bare)
-			printf("Cloning into bare repository %s...\n", dir);
+			printf(_("Cloning into bare repository %s...\n"), dir);
 		else
-			printf("Cloning into %s...\n", dir);
+			printf(_("Cloning into %s...\n"), dir);
 	}
 	init_db(option_template, INIT_DB_QUIET);
 
t/t5601-clone.sh +1 -1
index 987e0c8..9e6fa3b 100755
@@ -31,7 +31,7 @@ test_expect_success 'clone with excess parameters (2)' '
 
 '
 
-test_expect_success 'output from clone' '
+test_expect_success C_LOCALE_OUTPUT 'output from clone' '
 	rm -fr dst &&
 	git clone -n "file://$(pwd)/src" dst >output &&
 	test $(grep Clon output | wc -l) = 1
Signature · 1 line
1.7.4.1
#107 lore raw

PATCH v3 10/15 add: mark basic messages for translation

In reply to Jonathan Nieder

From: Ævar Arnfjörð Bjarmason <[email protected]>
Date: Wed, 1 Sep 2010 18:40:13 +0000

---
 builtin/add.c |   36 ++++++++++++++++++------------------
 1 files changed, 18 insertions(+), 18 deletions(-)
builtin/add.c +18 -18
index 42c906e..a9a78f4 100644
@@ -38,7 +38,7 @@ static void update_callback(struct diff_queue_struct *q,
 		const char *path = p->one->path;
 		switch (p->status) {
 		default:
-			die("unexpected diff status %c", p->status);
+			die(_("unexpected diff status %c"), p->status);
 		case DIFF_STATUS_UNMERGED:
 			/*
 			 * ADD_CACHE_IGNORE_REMOVAL is unset if "git
@@ -64,7 +64,7 @@ static void update_callback(struct diff_queue_struct *q,
 		case DIFF_STATUS_TYPE_CHANGED:
 			if (add_file_to_index(&the_index, path, data->flags)) {
 				if (!(data->flags & ADD_CACHE_IGNORE_ERRORS))
-					die("updating files failed");
+					die(_("updating files failed"));
 				data->add_errors++;
 			}
 			break;
@@ -172,7 +172,7 @@ static void treat_gitlinks(const char **pathspec)
 					/* strip trailing slash */
 					pathspec[j] = xstrndup(ce->name, len);
 				else
-					die ("Path '%s' is in submodule '%.*s'",
+					die (_("Path '%s' is in submodule '%.*s'"),
 						pathspec[j], len, ce->name);
 			}
 		}
@@ -191,7 +191,7 @@ static void refresh(int verbose, const char **pathspec)
 		      pathspec, seen, "Unstaged changes after refreshing the index:");
 	for (i = 0; i < specs; i++) {
 		if (!seen[i])
-			die("pathspec '%s' did not match any files", pathspec[i]);
+			die(_("pathspec '%s' did not match any files"), pathspec[i]);
 	}
         free(seen);
 }
@@ -205,7 +205,7 @@ static const char **validate_pathspec(int argc, const char **argv, const char *p
 		for (p = pathspec; *p; p++) {
 			if (has_symlink_leading_path(*p, strlen(*p))) {
 				int len = prefix ? strlen(prefix) : 0;
-				die("'%s' is beyond a symbolic link", *p + len);
+				die(_("'%s' is beyond a symbolic link"), *p + len);
 			}
 		}
 	}
@@ -272,7 +272,7 @@ static int edit_patch(int argc, const char **argv, const char *prefix)
 	git_config(git_diff_basic_config, NULL); /* no "diff" UI options */
 
 	if (read_cache() < 0)
-		die ("Could not read the index");
+		die (_("Could not read the index"));
 
 	init_revisions(&rev, prefix);
 	rev.diffopt.context = 7;
@@ -281,24 +281,24 @@ static int edit_patch(int argc, const char **argv, const char *prefix)
 	rev.diffopt.output_format = DIFF_FORMAT_PATCH;
 	out = open(file, O_CREAT | O_WRONLY, 0644);
 	if (out < 0)
-		die ("Could not open '%s' for writing.", file);
+		die (_("Could not open '%s' for writing."), file);
 	rev.diffopt.file = xfdopen(out, "w");
 	rev.diffopt.close_file = 1;
 	if (run_diff_files(&rev, 0))
-		die ("Could not write patch");
+		die (_("Could not write patch"));
 
 	launch_editor(file, NULL, NULL);
 
 	if (stat(file, &st))
-		die_errno("Could not stat '%s'", file);
+		die_errno(_("Could not stat '%s'"), file);
 	if (!st.st_size)
-		die("Empty patch. Aborted.");
+		die(_("Empty patch. Aborted."));
 
 	memset(&child, 0, sizeof(child));
 	child.git_cmd = 1;
 	child.argv = apply_argv;
 	if (run_command(&child))
-		die ("Could not apply '%s'", file);
+		die (_("Could not apply '%s'"), file);
 
 	unlink(file);
 	return 0;
@@ -354,7 +354,7 @@ static int add_files(struct dir_struct *dir, int flags)
 	for (i = 0; i < dir->nr; i++)
 		if (add_file_to_cache(dir->entries[i]->name, flags)) {
 			if (!ignore_add_errors)
-				die("adding files failed");
+				die(_("adding files failed"));
 			exit_status = 1;
 		}
 	return exit_status;
@@ -386,9 +386,9 @@ int cmd_add(int argc, const char **argv, const char *prefix)
 	argv++;
 
 	if (addremove && take_worktree_changes)
-		die("-A and -u are mutually incompatible");
+		die(_("-A and -u are mutually incompatible"));
 	if (!show_only && ignore_missing)
-		die("Option --ignore-missing can only be used together with --dry-run");
+		die(_("Option --ignore-missing can only be used together with --dry-run"));
 	if ((addremove || take_worktree_changes) && !argc) {
 		static const char *here[2] = { ".", NULL };
 		argc = 1;
@@ -408,14 +408,14 @@ int cmd_add(int argc, const char **argv, const char *prefix)
 		  ? ADD_CACHE_IGNORE_REMOVAL : 0));
 
 	if (require_pathspec && argc == 0) {
-		fprintf(stderr, "Nothing specified, nothing added.\n");
-		fprintf(stderr, "Maybe you wanted to say 'git add .'?\n");
+		fprintf(stderr, _("Nothing specified, nothing added.\n"));
+		fprintf(stderr, _("Maybe you wanted to say 'git add .'?\n"));
 		return 0;
 	}
 	pathspec = validate_pathspec(argc, argv, prefix);
 
 	if (read_cache() < 0)
-		die("index file corrupt");
+		die(_("index file corrupt"));
 	treat_gitlinks(pathspec);
 
 	if (add_new_files) {
@@ -467,7 +467,7 @@ int cmd_add(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 exit_status;
Signature · 1 line
1.7.4.1
#108 lore raw

PATCH v3 11/15 add: mark "The following paths are ignored" for translation

In reply to Jonathan Nieder

From: Ævar Arnfjörð Bjarmason <[email protected]>
Date: Wed, 22 Sep 2010 19:20:25 +0000

t2204 (.gitignore) and t3700 (add) explicitly check this sequence of messages, so while at it, split each relevant test into a part that just checks "git add"'s exit status and a part that checks porcelain output.

---
 builtin/add.c          |    8 ++++----
 t/t2204-add-ignored.sh |   37 +++++++++++++++++++++++++------------
 t/t3700-add.sh         |    5 ++++-
 3 files changed, 33 insertions(+), 17 deletions(-)
builtin/add.c +4 -4
index a9a78f4..21776ac 100644
@@ -307,7 +307,7 @@ static int edit_patch(int argc, const char **argv, const char *prefix)
 static struct lock_file lock_file;
 
 static const char ignore_error[] =
-"The following paths are ignored by one of your .gitignore files:\n";
+N_("The following paths are ignored by one of your .gitignore files:\n");
 
 static int verbose = 0, show_only = 0, ignored_too = 0, refresh_only = 0;
 static int ignore_add_errors, addremove, intent_to_add, ignore_missing = 0;
@@ -344,11 +344,11 @@ static int add_files(struct dir_struct *dir, int flags)
 	int i, exit_status = 0;
 
 	if (dir->ignored_nr) {
-		fprintf(stderr, ignore_error);
+		fprintf(stderr, _(ignore_error));
 		for (i = 0; i < dir->ignored_nr; i++)
 			fprintf(stderr, "%s\n", dir->ignored[i]->name);
-		fprintf(stderr, "Use -f if you really want to add them.\n");
-		die("no files added");
+		fprintf(stderr, _("Use -f if you really want to add them.\n"));
+		die(_("no files added"));
 	}
 
 	for (i = 0; i < dir->nr; i++)
t/t2204-add-ignored.sh +25 -12
index 24afdab..4975336 100755
@@ -31,18 +31,21 @@ do
 		rm -f .git/index &&
 		test_must_fail git add "$i" 2>err &&
 		git ls-files "$i" >out &&
-		! test -s out &&
-		grep -e "Use -f if" err &&
-		cat err
+		! test -s out
+	'
+
+	test_expect_success C_LOCALE_OUTPUT "complaints for ignored $i output" '
+		grep -e "Use -f if" err
 	'
 
 	test_expect_success "complaints for ignored $i with unignored file" '
 		rm -f .git/index &&
 		test_must_fail git add "$i" file 2>err &&
 		git ls-files "$i" >out &&
-		! test -s out &&
-		grep -e "Use -f if" err &&
-		cat err
+		! test -s out
+	'
+	test_expect_success C_LOCALE_OUTPUT "complaints for ignored $i with unignored file output" '
+		grep -e "Use -f if" err
 	'
 done
 
@@ -54,9 +57,14 @@ do
 			cd dir &&
 			test_must_fail git add "$i" 2>err &&
 			git ls-files "$i" >out &&
-			! test -s out &&
-			grep -e "Use -f if" err &&
-			cat err
+			! test -s out
+		)
+	'
+
+	test_expect_success C_LOCALE_OUTPUT "complaints for ignored $i in dir output" '
+		(
+			cd dir &&
+			grep -e "Use -f if" err
 		)
 	'
 done
@@ -69,9 +77,14 @@ do
 			cd sub &&
 			test_must_fail git add "$i" 2>err &&
 			git ls-files "$i" >out &&
-			! test -s out &&
-			grep -e "Use -f if" err &&
-			cat err
+			! test -s out
+		)
+	'
+
+	test_expect_success C_LOCALE_OUTPUT "complaints for ignored $i in sub output" '
+		(
+			cd sub &&
+			grep -e "Use -f if" err
 		)
 	'
 done
t/t3700-add.sh +4 -1
index ec71083..ac115ed 100755
@@ -283,7 +283,10 @@ add 'track-this'
 EOF
 
 test_expect_success 'git add --dry-run --ignore-missing of non-existing file' '
-	test_must_fail git add --dry-run --ignore-missing track-this ignored-file >actual.out 2>actual.err &&
+	test_must_fail git add --dry-run --ignore-missing track-this ignored-file >actual.out 2>actual.err
+'
+
+test_expect_success C_LOCALE_OUTPUT 'git add --dry-run --ignore-missing of non-existing file output' '
 	test_cmp expect.out actual.out &&
 	test_cmp expect.err actual.err
 '
Signature · 1 line
1.7.4.1
#109 lore raw

PATCH v3 12/15 add: mark "did not match any files" for translation

In reply to Jonathan Nieder

From: Ævar Arnfjörð Bjarmason <[email protected]>
Date: Sun, 19 Sep 2010 15:48:06 +0000

... and skip the test that checks for it when the C_LOCALE_OUTPUT prereq is not present.

---
 builtin/add.c  |    2 +-
 t/t3700-add.sh |    8 ++++++--
 2 files changed, 7 insertions(+), 3 deletions(-)
builtin/add.c +1 -1
index 21776ac..ffbd459 100644
@@ -451,7 +451,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
 					if (excluded(&dir, pathspec[i], &dtype))
 						dir_add_ignored(&dir, pathspec[i], strlen(pathspec[i]));
 				} else
-					die("pathspec '%s' did not match any files",
+					die(_("pathspec '%s' did not match any files"),
 					    pathspec[i]);
 			}
 		}
t/t3700-add.sh +6 -2
index ac115ed..7de42fa 100755
@@ -268,8 +268,12 @@ test_expect_success 'git add --dry-run of existing changed file' "
 
 test_expect_success 'git add --dry-run of non-existing file' "
 	echo ignored-file >>.gitignore &&
-	test_must_fail git add --dry-run track-this ignored-file >actual 2>&1 &&
-	echo \"fatal: pathspec 'ignored-file' did not match any files\" | test_cmp - actual
+	test_must_fail git add --dry-run track-this ignored-file >actual 2>&1
+"
+
+test_expect_success C_LOCALE_OUTPUT 'git add --dry-run of an existing file output' "
+	echo \"fatal: pathspec 'ignored-file' did not match any files\" >expect &&
+	test_cmp expect actual
 "
 
 cat >expect.err <<\EOF
Signature · 1 line
1.7.4.1
#110 lore raw

PATCH v3 13/15 add -u --verbose: mark "remove '%s'" for translation

In reply to Jonathan Nieder

From: Ævar Arnfjörð Bjarmason <[email protected]>
Date: Sun, 19 Sep 2010 14:48:59 +0000

... and skip the corresponding test when output is not in the C locale.

---
 builtin/add.c         |    2 +-
 t/t2200-add-update.sh |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
builtin/add.c +1 -1
index ffbd459..33b9970 100644
@@ -74,7 +74,7 @@ static void update_callback(struct diff_queue_struct *q,
 			if (!(data->flags & ADD_CACHE_PRETEND))
 				remove_file_from_index(&the_index, path);
 			if (data->flags & (ADD_CACHE_PRETEND|ADD_CACHE_VERBOSE))
-				printf("remove '%s'\n", path);
+				printf(_("remove '%s'\n"), path);
 			break;
 		}
 	}
t/t2200-add-update.sh +1 -1
index 0692427..856e7da 100755
@@ -111,7 +111,7 @@ test_expect_success 'touch and then add explicitly' '
 
 '
 
-test_expect_success 'add -n -u should not add but just report' '
+test_expect_success C_LOCALE_OUTPUT 'add -n -u should not add but just report' '
 
 	(
 		echo "add '\''check'\''" &&
Signature · 1 line
1.7.4.1
#111 lore raw

PATCH v3 14/15 update-index --refresh --porcelain: add missing const

In reply to Jonathan Nieder
---
 cache.h      |    2 +-
 read-cache.c |    4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
cache.h +1 -1
index a465f38..8188169 100644
@@ -512,7 +512,7 @@ extern void fill_stat_cache_info(struct cache_entry *ce, struct stat *st);
 #define REFRESH_IGNORE_MISSING	0x0008	/* ignore non-existent */
 #define REFRESH_IGNORE_SUBMODULES	0x0010	/* ignore submodules */
 #define REFRESH_IN_PORCELAIN	0x0020	/* user friendly output, not "needs update" */
-extern int refresh_index(struct index_state *, unsigned int flags, const char **pathspec, char *seen, char *header_msg);
+extern int refresh_index(struct index_state *, unsigned int flags, const char **pathspec, char *seen, const char *header_msg);
 
 struct lock_file {
 	struct lock_file *next;
read-cache.c +2 -2
index 4f2e890..15b0a73 100644
@@ -1104,7 +1104,7 @@ static struct cache_entry *refresh_cache_ent(struct index_state *istate,
 }
 
 static void show_file(const char * fmt, const char * name, int in_porcelain,
-		      int * first, char *header_msg)
+		      int * first, const char *header_msg)
 {
 	if (in_porcelain && *first && header_msg) {
 		printf("%s\n", header_msg);
@@ -1114,7 +1114,7 @@ static void show_file(const char * fmt, const char * name, int in_porcelain,
 }
 
 int refresh_index(struct index_state *istate, unsigned int flags, const char **pathspec,
-		  char *seen, char *header_msg)
+		  char *seen, const char *header_msg)
 {
 	int i;
 	int has_errors = 0;
Signature · 1 line
1.7.4.1
#112 lore raw

PATCH v3 15/15 add --refresh --verbose: mark "Unstaged changes" heading for translation

In reply to Jonathan Nieder

From: Ævar Arnfjörð Bjarmason <[email protected]>
Date: Wed, 1 Sep 2010 18:49:22 +0000

---
That's the end of the series. Thanks for reading.

I also should say, to be clear, I will not be sending more series like this (though if there are bugs in this one I'd be happy to fix them).

 builtin/add.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
builtin/add.c +1 -1
index 33b9970..a512597 100644
@@ -188,7 +188,7 @@ static void refresh(int verbose, const char **pathspec)
 		/* nothing */;
 	seen = xcalloc(specs, 1);
 	refresh_index(&the_index, verbose ? REFRESH_IN_PORCELAIN : REFRESH_QUIET,
-		      pathspec, seen, "Unstaged changes after refreshing the index:");
+		      pathspec, seen, _("Unstaged changes after refreshing the index:"));
 	for (i = 0; i < specs; i++) {
 		if (!seen[i])
 			die(_("pathspec '%s' did not match any files"), pathspec[i]);
Signature · 1 line
1.7.4.1
#114 lore raw

Re: [PATCH v3 00/15] Mark "init", "clone", and "add" output for translation

Quoted 5 lines · Ævar Arnfjörð Bjarmason
Quoted 2 lines · Jonathan Nieder

Please feel free to try it out, complain, ack, send patches, and so on.

Thanks a lot for taking this on.

I compared this miniseries with the early part of your original. It seems to contain only sane refinements, adding missed markings etc.

#115 lore raw

Re: [PATCH v3 00/15] Mark "init", "clone", and "add" output for translation

Quoted 10 lines · Junio C Hamano
Quoted 5 lines · Ævar Arnfjörð Bjarmason
Quoted 2 lines · Jonathan Nieder

Please feel free to try it out, complain, ack, send patches, and so on.

Thanks a lot for taking this on.

I compared this miniseries with the early part of your original.  It seems to contain only sane refinements, adding missed markings etc.

Yeah it's looking much better.

I've been coordinating with Jonathan on #git-devel. Some more changes were made yesterday. I'm going to pack them up and re-submit again (just minor nits etc). That series should be in a form that's acceptable for being applied as-is.

#116 lore raw

Re: [PATCH v3 00/15] Mark "init", "clone", and "add" output for translation

In reply to Jonathan Nieder
Quoted 7 lines · Jonathan Nieder

This series still includes the skeleton gettext.h wrapper.

Changes from v1:

- clearer commit messages, hopefully
- clearer documentation for GETTEXT_POISON in the makefile

Quoted 7 lines

Please feel free to try it out, complain, ack, send patches, and so on.

Jonathan Nieder (2):
i18n: do not poison translations unless GIT_GETTEXT_POISON envvar is
set
update-index --refresh --porcelain: add missing const

I took this series (minus 4/15), which roughly corresponds to up to 13/72 of Ævar's original. A few quick comments:

* 01/15
Thanks for guarding the header file from double inclusion. I have this nagging feeling that the inline _() function might be too clever for some compilers (non gcc and perhaps older versions of gcc), but we can always ifdef it away if it turns problematic.

* 02/15
I am not entirely happy that it is a too generic name to contaminate namespace of programs that may want to get i18n support while wanting to catch bugs with their own unrelated poisoning scheme.

As to Malkovich, I tend to agree with your reasoning that code that emit messages prefixed by "#" rebase relies on should be restructured to limit the scope of translation to just the body of these lines, and that should be done in a separate patch.

* 04/15
Deferred per request from Ævar.

#117 lore raw

v4 cover No-op gettextize core Git C programs

This is an improved version of the no-op gettextize series for core Git C programs based on Jonathan Nieder's v3 series. Changes since then.

* After it's applied Git will no longer fail tests when compiled with GETTEXT_POISON=YesPlease. It did this because Jonathan's series changed the GETTEXT POISON string. See the comment in the "simulate unfriendly translator" patch. Regarding Junio's comment:

As to Malkovich, I tend to agree with your reasoning that code that emit messages prefixed by "#" rebase relies on should be restructured to limit the scope of translation to just the body of these lines, and that should be done in a separate patch.

I agree. I'll change it to just "GETTEXT POISON" in a later patch. But I'd prefer not to break git in any testing mode until then.

* Reverted back to using the "gettextize" patch subjects I originally used. I'm using these consistetly so I can later git log --grep=gettextize: to find them. I'd like to preserve that attributed.

* Amended and improved some log messages.

Other than that it's the same. For this to compile without warnings you first need the "Add missing const to char* declarations" series I've just submitted. But otherwise it's all good to go.

Jonathan Nieder (1):
gettext: do not poison translations unless GIT_GETTEXT_POISON envvar
is set

Ævar Arnfjörð Bjarmason (72):
gettext: add no-op _() and N_() wrappers
gettext tests: add GETTEXT_POISON to simulate unfriendly translator
Makefile: "pot" target to extract messages marked for translation
gettextize: git-init basic messages
gettextize: git-init "Initialized [...] repository" message
gettextize: git-clone basic messages
gettextize: git-clone "Cloning into" message
gettextize: git-clone "Cloning into" message
gettextize: git-add basic messages
gettextize: git-add "The following paths are ignored" message
gettextize: git-add "did not match any files" message
gettextize: git-add "remove '%s'" message
gettextize: git-add "Unstaged changes" message
gettextize: git-branch basic messages
gettextize: git-branch "remote branch '%s' not found" message
gettextize: git-branch "Deleted branch [...]" message
gettextize: git-branch "git branch -v" messages
gettextize: git-branch "(no branch)" message
gettextize: git-checkout basic messages
gettextize: git-checkout: our/their version message
gettextize: git-checkout describe_detached_head messages
gettextize: git-checkout "HEAD is now at" message
gettextize: git-checkout "Switched to a .. branch" message
gettextize: git-commit basic messages
gettextize: git-commit "middle of a merge" message
gettextize: git-commit formatting messages
gettextize: git-commit print_summary messages
gettextize: git-commit "enter the commit message" message
gettextize: git-commit advice messages
gettextize: git-diff basic messages
gettextize: git-fetch basic messages
gettextize: git-fetch formatting messages
gettextize: git-fetch update_local_ref messages
gettextize: git-fetch split up "(non-fast-forward)" message
gettextize: git-grep basic messages
gettextize: git-grep "--open-files-in-pager" message
gettextize: git-log basic messages
gettextize: git-log "--OPT does not make sense" messages
gettextize: git-merge basic messages
gettextize: git-merge "Updating %s..%s" message
gettextize: git-merge "You have not concluded your merge" messages
gettextize: git-merge "Wonderful" message
gettextize: git-mv basic messages
gettextize: git-mv "bad" messages
gettextize: git-rm basic messages
gettextize: git-reset basic messages
gettextize: git-reset reset_type_names messages
gettextize: git-reset "Unstaged changes after reset" message
gettextize: git-tag basic messages
gettextize: git-tag tag_template message
gettextize: git-push basic messages
gettextize: git-push "prevent you from losing" message
gettextize: git-status basic messages
gettextize: git-status "nothing to commit" messages
gettextize: git-status shortstatus messages
gettextize: git-status "Changes to be committed" message
gettextize: git-status "Initial commit" message
gettextize: git-status "renamed: " message
gettextize: git-archive basic messages
gettextize: git-bundle basic messages
gettextize: git-clean basic messages
gettextize: git-clean clean.requireForce messages
gettextize: git-describe basic messages
gettextize: git-gc basic messages
gettextize: git-gc "Auto packing the repository" message
gettextize: git-notes basic commands
gettextize: git-notes GIT_NOTES_REWRITE_MODE error message
gettextize: git-revert basic messages
gettextize: git-revert "Your local changes" message
gettextize: git-revert literal "me" messages
gettextize: git-revert split up "could not revert/apply" message
gettextize: git-shortlog basic messages

 Makefile                         |   27 ++++++
 builtin/add.c                    |   50 ++++++------
 builtin/archive.c                |   14 ++--
 builtin/branch.c                 |   69 ++++++++--------
 builtin/bundle.c                 |    6 +-
 builtin/checkout.c               |   93 +++++++++++-----------
 builtin/clean.c                  |   33 +++++---
 builtin/clone.c                  |   63 ++++++++-------
 builtin/commit.c                 |  162 +++++++++++++++++++-------------------
 builtin/describe.c               |   36 ++++----
 builtin/diff.c                   |   18 ++--
 builtin/fetch.c                  |   82 ++++++++++----------
 builtin/gc.c                     |   24 +++---
 builtin/grep.c                   |   34 ++++----
 builtin/init-db.c                |   58 ++++++++------
 builtin/log.c                    |   68 ++++++++--------
 builtin/merge.c                  |  128 +++++++++++++++---------------
 builtin/mv.c                     |   32 ++++----
 builtin/notes.c                  |  112 +++++++++++++-------------
 builtin/push.c                   |   42 +++++-----
 builtin/reset.c                  |   42 +++++-----
 builtin/revert.c                 |   76 ++++++++++--------
 builtin/rm.c                     |   22 +++---
 builtin/shortlog.c               |    8 +-
 builtin/tag.c                    |   66 ++++++++--------
 cache.h                          |    1 +
 gettext.c                        |   14 +++
 gettext.h                        |   32 ++++++++
 po/.gitignore                    |    1 +
 t/lib-httpd.sh                   |    2 +-
 t/t0001-init.sh                  |    2 +-
 t/t1200-tutorial.sh              |    5 +-
 t/t2200-add-update.sh            |    2 +-
 t/t2204-add-ignored.sh           |   37 ++++++---
 t/t3030-merge-recursive.sh       |    2 +-
 t/t3200-branch.sh                |    2 +-
 t/t3203-branch-output.sh         |    2 +-
 t/t3501-revert-cherry-pick.sh    |    2 +-
 t/t3507-cherry-pick-conflict.sh  |    2 +-
 t/t3700-add.sh                   |   13 +++-
 t/t4001-diff-rename.sh           |    4 +-
 t/t4014-format-patch.sh          |    2 +-
 t/t5526-fetch-submodules.sh      |   40 ++++++++--
 t/t5541-http-push.sh             |    7 +-
 t/t5601-clone.sh                 |    2 +-
 t/t6040-tracking-info.sh         |    2 +-
 t/t6120-describe.sh              |    2 +-
 t/t7004-tag.sh                   |    1 +
 t/t7012-skip-worktree-writing.sh |    4 +-
 t/t7060-wtstatus.sh              |    2 +-
 t/t7102-reset.sh                 |    2 +-
 t/t7110-reset-merge.sh           |    6 +-
 t/t7201-co.sh                    |   10 +-
 t/t7300-clean.sh                 |    6 +-
 t/t7500-commit.sh                |    8 +-
 t/t7501-commit.sh                |    7 +-
 t/t7502-commit.sh                |   60 +++++++++------
 t/t7506-status-submodule.sh      |   28 +++---
 t/t7508-status.sh                |  115 +++++++++++++++------------
 t/t7600-merge.sh                 |    2 +-
 t/t7607-merge-overwrite.sh       |   10 ++-
 t/t7611-merge-abort.sh           |   20 ++++-
 t/t7811-grep-open.sh             |    2 +-
 t/test-lib.sh                    |    9 ++
 wt-status.c                      |  116 ++++++++++++++--------------
 65 files changed, 1084 insertions(+), 867 deletions(-)
 create mode 100644 gettext.c
 create mode 100644 gettext.h
 create mode 100644 po/.gitignore
Signature · 1 line
1.7.2.3
#118 lore raw

Re: [PATCH v4 00/73] No-op gettextize core Git C programs

Quoted 4 lines · Ævar Arnfjörð Bjarmason

* Reverted back to using the "gettextize" patch subjects I originally used. I'm using these consistetly so I can later git log --grep=gettextize: to find them. I'd like to preserve that attributed.

Can we make that shorter, perhaps just "i18n:"? In this series, your first three and Jonathan's are oddballs that do not have "gettexize:" anyway.

Will give it a whirl. Thanks.

#119 lore raw

Re: [PATCH v4 00/73] No-op gettextize core Git C programs

Quoted 7 lines · Junio C Hamano
Quoted 4 lines · Ævar Arnfjörð Bjarmason

* Reverted back to using the "gettextize" patch subjects I originally used. I'm using these consistetly so I can later git log --grep=gettextize: to find them. I'd like to preserve that attributed.

Quoted 5 lines

Can we make that shorter, perhaps just "i18n:"? In this series, your first three and Jonathan's are oddballs that do not have "gettexize:" anyway.

Will give it a whirl. Thanks.

It was a slightly unpleasant experience to merge this round to 'pu' (after excluding the earlier round from it, of course), as a few topics in flight that reorganized existing functions into smaller helpers had to conflict with this patch. I tried to be careful but please double check the result, perhaps with:

    $ git show --first-parent origin/pu

when it is propagated to mirrors.

Thanks.

#120 lore raw

Re: [PATCH v4 00/73] No-op gettextize core Git C programs

Quoted 21 lines · Junio C Hamano
Quoted 7 lines · Junio C Hamano
Quoted 4 lines · Ævar Arnfjörð Bjarmason

  * Reverted back to using the "gettextize" patch subjects I originally used. I'm using these consistetly so I can later git log --grep=gettextize: to find them. I'd like to preserve that attributed.

Quoted 5 lines

Can we make that shorter, perhaps just "i18n:"?  In this series, your first three and Jonathan's are oddballs that do not have "gettexize:" anyway.

Will give it a whirl.  Thanks.

It was a slightly unpleasant experience to merge this round to 'pu' (after excluding the earlier round from it, of course), as a few topics in flight that reorganized existing functions into smaller helpers had to conflict with this patch.  I tried to be careful but please double check the result, perhaps with:

Quoted 3 lines
   $ git show --first-parent origin/pu

when it is propagated to mirrors.

I've gone over the version in pu. It looks good to me.

#121 lore raw

PATCH v4 1/73 gettext: add no-op _() and N_() wrappers

In reply to Junio C Hamano

The _ function is for translating strings into the user's chosen language. The N_ macro just marks translatable strings for the xgettext(1) tool without translating them; it is intended for use in contexts where a function call cannot be used. So, for example:

	fprintf(stderr, _("Expansion of alias '%s' failed; "
		"'%s' is not a git command\n"),
		cmd, argv[0]);

and

	const char *unpack_plumbing_errors[NB_UNPACK_TREES_ERROR_TYPES] = {
		/* ERROR_WOULD_OVERWRITE */
		N_("Entry '%s' would be overwritten by merge. Cannot merge."),
	[...]

Define such _ and N_ in a new gettext.h and include it in cache.h, so they can be used everywhere. Each just returns its argument for now. _ is a function rather than a macro like N_ to avoid the temptation to use _("foo") as a string literal (which would be a compile-time error once _(s) expands to an expression for the translation of s).

---
 Makefile  |    1 +
 cache.h   |    1 +
 gettext.h |   26 ++++++++++++++++++++++++++
 3 files changed, 28 insertions(+), 0 deletions(-)
 create mode 100644 gettext.h
Makefile +1 -0
index ade7923..c153f45 100644
@@ -515,6 +515,7 @@ LIB_H += diff.h
 LIB_H += dir.h
 LIB_H += exec_cmd.h
 LIB_H += fsck.h
+LIB_H += gettext.h
 LIB_H += git-compat-util.h
 LIB_H += graph.h
 LIB_H += grep.h
cache.h +1 -0
index 3abf895..a465f38 100644
@@ -5,6 +5,7 @@
 #include "strbuf.h"
 #include "hash.h"
 #include "advice.h"
+#include "gettext.h"
 
 #include SHA1_HEADER
 #ifndef git_SHA_CTX
gettext.h new file +26 -0
new file mode 100644
index 0000000..6949d73
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2010-2011 Ævar Arnfjörð Bjarmason
+ *
+ * This is a skeleton no-op implementation of gettext for Git.
+ * You can replace it with something that uses libintl.h and wraps
+ * gettext() to try out the translations.
+ */
+
+#ifndef GETTEXT_H
+#define GETTEXT_H
+
+#ifdef _
+#error "namespace conflict: '_' is pre-defined?"
+#endif
+
+#define FORMAT_PRESERVING(n) __attribute__((format_arg(n)))
+
+static inline FORMAT_PRESERVING(1) const char *_(const char *msgid)
+{
+	return msgid;
+}
+
+/* Mark msgid for translation but do not translate it. */
+#define N_(msgid) (msgid)
+
+#endif
Signature · 1 line
1.7.2.3
#122 lore raw

PATCH v4 2/73 gettext tests: add GETTEXT_POISON to simulate unfriendly translator

In reply to Junio C Hamano

Add a new GETTEXT_POISON compile-time parameter to make _(msg) always return gibberish. So now you can run

make GETTEXT_POISON=YesPlease

to get a copy of git that functions correctly (one hopes) but produces output that is in nobody's native language at all.

This is a debugging aid for people who are working on the i18n part of the system, to make sure that they are not marking plumbing messages that should never be translated with _().

As new strings get marked for translation, naturally a number of tests will be broken in this mode. Tests that depend on output from Porcelain will need to be marked with the new C_LOCALE_OUTPUT test prerequisite. Newly failing tests that do not depend on output from Porcelain would be bugs due to messages that should not have been marked for translation.

Note that the string we're using ("# GETTEXT POISON #") intentionally starts the pound sign. Some of Git's tests such as t3404-rebase-interactive.sh rely on interactive editing with a fake editor, and will needlessly break if the message doesn't start with something the interactive editor considers a comment.

A future patch will fix fix the underlying cause of that issue by adding "#" characters to the commit advice automatically.

---
 Makefile      |    7 +++++++
 gettext.h     |    8 +++++++-
 t/test-lib.sh |    3 +++
 3 files changed, 17 insertions(+), 1 deletions(-)
Makefile +7 -0
index c153f45..c348bb7 100644
@@ -216,6 +216,9 @@ all::
 #
 # Define NO_REGEX if you have no or inferior regex support in your C library.
 #
+# Define GETTEXT_POISON if you are debugging the choice of strings marked
+# for translation.  This will turn all strings that use gettext into gibberish.
+#
 # Define JSMIN to point to JavaScript minifier that functions as
 # a filter to have gitweb.js minified.
 #
@@ -1370,6 +1373,9 @@ endif
 ifdef NO_SYMLINK_HEAD
 	BASIC_CFLAGS += -DNO_SYMLINK_HEAD
 endif
+ifdef GETTEXT_POISON
+	BASIC_CFLAGS += -DGETTEXT_POISON
+endif
 ifdef NO_STRCASESTR
 	COMPAT_CFLAGS += -DNO_STRCASESTR
 	COMPAT_OBJS += compat/strcasestr.o
@@ -2089,6 +2095,7 @@ endif
 ifdef GIT_TEST_CMP_USE_COPIED_CONTEXT
 	@echo GIT_TEST_CMP_USE_COPIED_CONTEXT=YesPlease >>$@
 endif
+	@echo GETTEXT_POISON=\''$(subst ','\'',$(subst ','\'',$(GETTEXT_POISON)))'\' >>$@
 
 ### Detect Tck/Tk interpreter path changes
 ifndef NO_TCLTK
gettext.h +7 -1
index 6949d73..3d7cf44 100644
@@ -15,9 +15,15 @@
 
 #define FORMAT_PRESERVING(n) __attribute__((format_arg(n)))
 
+#ifdef GETTEXT_POISON
+#define use_poison() 1
+#else
+#define use_poison() 0
+#endif
+
 static inline FORMAT_PRESERVING(1) const char *_(const char *msgid)
 {
-	return msgid;
+	return use_poison() ? "# GETTEXT POISON #" : msgid;
 }
 
 /* Mark msgid for translation but do not translate it. */
t/test-lib.sh +3 -0
index 0fdc541..0840e4a 100644
@@ -1079,6 +1079,9 @@ esac
 test -z "$NO_PERL" && test_set_prereq PERL
 test -z "$NO_PYTHON" && test_set_prereq PYTHON
 
+# Can we rely on git's output in the C locale?
+test -z "$GETTEXT_POISON" && test_set_prereq C_LOCALE_OUTPUT
+
 # test whether the filesystem supports symbolic links
 ln -s x y 2>/dev/null && test -h y 2>/dev/null && test_set_prereq SYMLINKS
 rm -f y
Signature · 1 line
1.7.2.3
#123 lore raw

Re: [PATCH v4 02/73] gettext tests: add GETTEXT_POISON to simulate unfriendly translator

Hi again,

Quoted 2 lines · Ævar Arnfjörð Bjarmason

Note that the string we're using ("# GETTEXT POISON #") intentionally starts the pound sign.

I think I've caused more grief than it's worth complaining about that. But here's what a fixup (against 77bc5af, i18n: add GETTEXT_POISON to simulate unfriendly translator, 2011-02-22) would look like, in case it's wanted.

If this fixup is applied, the last two paragraphs of the change description (starting with "Note that the string we're using") could be removed.

Will comment on how later patches in the series would be affected in separate messages as I apply them. Patch 1 (i18n: add no-op _() and N_() wrappers) and patch 2 (gettext_poison) look good to me, for what it's worth, with or without this fixup.

-- 8< --
Subject: i18n: make the string used by GETTEXT_POISON less meaningful

The idea of the GETTEXT_POISON facility is to simulate a worst-case translation, so that strings marked for translation that cause trouble can be noticed and dealt with.

A string starting with "#" does not seem particularly well suited for that purpose, since it makes '#' characters that mark a comment and that translators must be careful not to remove harder to find. Plus it muddles the issue --- is the poisonous string meant to be a random worst case or not?

The affected strings with a "# " are in wt-status.c, builtin/commit.c, and builtin/tag.c. A proof-of-concept patch moving the # signs outside the translated strings exists and works well. If we want to mark those strings for translation without something like that patch, we can skip the relevant tests or start returning a string starting with a hash then.

---
 gettext.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
gettext.h +1 -1
index 11d82b0..361962e 100644
@@ -23,7 +23,7 @@
 
 static inline FORMAT_PRESERVING(1) const char *_(const char *msgid)
 {
-	return use_gettext_poison() ? "# GETTEXT POISON #" : msgid;
+	return use_gettext_poison() ? " GETTEXT POISON " : msgid;
 }
 
 /* Mark msgid for translation but do not translate it. */
Signature · 1 line
1.7.4.1
#124 lore raw

Re: [PATCH v4 02/73] gettext tests: add GETTEXT_POISON to simulate unfriendly translator

Jonathan Nieder <[email protected]> writes:

[offtopic: why is Jakub on the CC list? -- I don't recall him saying much on this topic yet...]

Quoted 3 lines

The idea of the GETTEXT_POISON facility is to simulate a worst-case translation, so that strings marked for translation that cause trouble can be noticed and dealt with.

I've never thought this was about a "worst-case translation".

Isn't this about emitting all the strings marked for translation in a form significantly different from the original, in the hope that such an output would help us find messages that should never be marked for translation by triggering test failures? I do not see any "worst-case", just different enough for the plumbing tests to break.

IOW, I don't think this is about helping translators in l10n, but about helping coders in i18n department.

Quoted 3 lines

A string starting with "#" does not seem particularly well suited for that purpose, since it makes '#' characters that mark a comment and that translators must be careful not to remove harder to find.

Hence, I would suggest an alternative phrasing of the above part (and alternative way of thinking): '... since it easily hides a mistaken marking of a line that _has_ to always start with "#" followed by a translatable string.'

#125 lore raw

Re: [PATCH v4 02/73] gettext tests: add GETTEXT_POISON to simulate unfriendly translator

Quoted 4 lines · Junio C Hamano

Jonathan Nieder <[email protected]> writes:

[offtopic: why is Jakub on the CC list? -- I don't recall him saying much on this topic yet...]

I see that I screwed up my J-completion. I meant to include Jonathan, not Jakub. Oops. Sorry for the spam Jakub.

Quoted 6 lines
Quoted 3 lines

The idea of the GETTEXT_POISON facility is to simulate a worst-case translation, so that strings marked for translation that cause trouble can be noticed and dealt with.

I've never thought this was about a "worst-case translation".

Quoted 8 lines

Isn't this about emitting all the strings marked for translation in a form significantly different from the original, in the hope that such an output would help us find messages that should never be marked for translation by triggering test failures?  I do not see any "worst-case", just different enough for the plumbing tests to break.

IOW, I don't think this is about helping translators in l10n, but about helping coders in i18n department.

Yes, exactly.

#126 lore raw

PATCH v4 3/73 gettext: do not poison translations unless GIT_GETTEXT_POISON envvar is set

In reply to Junio C Hamano

From: Jonathan Nieder <[email protected]>

Tweak the GETTEXT_POISON facility so it is activated at run time instead of compile time. If the GIT_GETTEXT_POISON environment variable is set, _(msg) will result in gibberish as before; but if the GIT_GETTEXT_POISON variable is not set, it will return the message for human-readable output. So the behavior of mistranslated and untranslated git can be compared without rebuilding git in between.

For simplicity we always set the GIT_GETTEXT_POISON variable in tests.

This does not affect builds without the GETTEXT_POISON compile-time option set, so non-i18n git will not be slowed down.

---
 Makefile      |    5 ++++-
 gettext.c     |   14 ++++++++++++++
 gettext.h     |    2 +-
 t/test-lib.sh |    8 +++++++-
 4 files changed, 26 insertions(+), 3 deletions(-)
 create mode 100644 gettext.c
Makefile +4 -1
index c348bb7..4e9d935 100644
@@ -217,7 +217,9 @@ all::
 # Define NO_REGEX if you have no or inferior regex support in your C library.
 #
 # Define GETTEXT_POISON if you are debugging the choice of strings marked
-# for translation.  This will turn all strings that use gettext into gibberish.
+# for translation.  In a GETTEXT_POISON build, you can turn all strings marked
+# for translation into gibberish by setting the GIT_GETTEXT_POISON variable
+# (to any value) in your environment.
 #
 # Define JSMIN to point to JavaScript minifier that functions as
 # a filter to have gitweb.js minified.
@@ -1374,6 +1376,7 @@ ifdef NO_SYMLINK_HEAD
 	BASIC_CFLAGS += -DNO_SYMLINK_HEAD
 endif
 ifdef GETTEXT_POISON
+	LIB_OBJS += gettext.o
 	BASIC_CFLAGS += -DGETTEXT_POISON
 endif
 ifdef NO_STRCASESTR
gettext.c new file +14 -0
new file mode 100644
index 0000000..9688c8b
@@ -0,0 +1,14 @@
+/*
+ * Copyright (c) 2010 Ævar Arnfjörð Bjarmason
+ */
+
+#include "git-compat-util.h"
+#include "gettext.h"
+
+int use_poison(void)
+{
+	static int poison_requested = -1;
+	if (poison_requested == -1)
+		poison_requested = getenv("GIT_GETTEXT_POISON") ? 1 : 0;
+	return poison_requested;
+}
gettext.h +1 -1
index 3d7cf44..ee7d41d 100644
@@ -16,7 +16,7 @@
 #define FORMAT_PRESERVING(n) __attribute__((format_arg(n)))
 
 #ifdef GETTEXT_POISON
-#define use_poison() 1
+extern int use_poison(void);
 #else
 #define use_poison() 0
 #endif
t/test-lib.sh +7 -1
index 0840e4a..f4c1e04 100644
@@ -1080,7 +1080,13 @@ test -z "$NO_PERL" && test_set_prereq PERL
 test -z "$NO_PYTHON" && test_set_prereq PYTHON
 
 # Can we rely on git's output in the C locale?
-test -z "$GETTEXT_POISON" && test_set_prereq C_LOCALE_OUTPUT
+if test -n "$GETTEXT_POISON"
+then
+	GIT_GETTEXT_POISON=YesPlease
+	export GIT_GETTEXT_POISON
+else
+	test_set_prereq C_LOCALE_OUTPUT
+fi
 
 # test whether the filesystem supports symbolic links
 ln -s x y 2>/dev/null && test -h y 2>/dev/null && test_set_prereq SYMLINKS
Signature · 1 line
1.7.2.3
#127 lore raw

PATCH v4 4/73 Makefile: "pot" target to extract messages marked for translation

In reply to Junio C Hamano

Add rules to generate a template (po/git.pot) listing messages marked for translation in the C portion of git.

To get started translating, just run "make pot".

---
 Makefile      |   16 ++++++++++++++++
 po/.gitignore |    1 +
 2 files changed, 17 insertions(+), 0 deletions(-)
 create mode 100644 po/.gitignore
Makefile +16 -0
index 4e9d935..1cc6c60 100644
@@ -321,6 +321,7 @@ INSTALL = install
 RPMBUILD = rpmbuild
 TCL_PATH = tclsh
 TCLTK_PATH = wish
+XGETTEXT = xgettext
 PTHREAD_LIBS = -lpthread
 PTHREAD_CFLAGS =
 GCOV = gcov
@@ -1590,6 +1591,7 @@ ifndef V
 	QUIET_BUILT_IN = @echo '   ' BUILTIN $@;
 	QUIET_GEN      = @echo '   ' GEN $@;
 	QUIET_LNCP     = @echo '   ' LN/CP $@;
+	QUIET_XGETTEXT = @echo '   ' XGETTEXT $@;
 	QUIET_GCOV     = @echo '   ' GCOV $@;
 	QUIET_SUBDIR0  = +@subdir=
 	QUIET_SUBDIR1  = ;$(NO_SUBDIR) echo '   ' SUBDIR $$subdir; \
@@ -2057,6 +2059,20 @@ info:
 pdf:
 	$(MAKE) -C Documentation pdf
 
+XGETTEXT_FLAGS = \
+	--force-po \
+	--add-comments \
+	--msgid-bugs-address="Git Mailing List <[email protected]>" \
+	--from-code=UTF-8
+XGETTEXT_FLAGS_C = $(XGETTEXT_FLAGS) --keyword=_ --keyword=N_ --language=C
+LOCALIZED_C := $(C_OBJ:o=c)
+
+po/git.pot: $(LOCALIZED_C)
+	$(QUIET_XGETTEXT)$(XGETTEXT) -o$@+ $(XGETTEXT_FLAGS_C) $(LOCALIZED_C) && \
+	mv $@+ $@
+
+pot: po/git.pot
+
 $(ETAGS_TARGET): FORCE
 	$(RM) $(ETAGS_TARGET)
 	$(FIND) . -name '*.[hcS]' -print | xargs etags -a -o $(ETAGS_TARGET)
po/.gitignore new file +1 -0
new file mode 100644
index 0000000..a242a86
@@ -0,0 +1 @@
+/git.pot
Signature · 1 line
1.7.2.3
#128 lore raw

Re: [PATCH v4 04/73] Makefile: "pot" target to extract messages marked for translation

Quoted 2 lines · Ævar Arnfjörð Bjarmason

Add rules to generate a template (po/git.pot) listing messages marked for translation in the C portion of git.

A forgotten piece. Not urgent at all.

-- 8< --
Subject: i18n: "make distclean" should clean up after "make pot"

This is in "make distclean" and not "make clean" to avoid needlessly changing the POT-Creation-Date in the following scenario:

make clean; # cleaning up after an old build
git pull
make pot; # regenerate po template if necessary
msgmerge po/my_language.po po/git.pot

---
 Makefile |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
Makefile +1 -0
index 1cc6c60..7497835 100644
@@ -2340,6 +2340,7 @@ dist-doc:
 
 distclean: clean
 	$(RM) configure
+	$(RM) po/git.pot
 
 clean:
 	$(RM) *.o block-sha1/*.o ppc/*.o compat/*.o compat/*/*.o xdiff/*.o vcs-svn/*.o \
Signature · 1 line
1.7.4.1
#129 lore raw

Re: [PATCH v4 04/73] Makefile: "pot" target to extract messages marked for translation

Quoted 1 line · Jonathan Nieder

A forgotten piece.  Not urgent at all.

Yeah, noticed this. Meant to sent a fixup for it. Thanks for beating me to it.

There's also one other (future) issue your mv $i+ $i trick confuses xgettext, which complains about invalid CHARSET in a later patch when there's more than one xgettext call. I.e. it doesn't like to append to files that don't end in *.pot for some reason.

The output is still the same though, so the warning doesn't have any real effect.

Just thought I'd mention it.

#130 lore raw

Re: [PATCH v4 04/73] Makefile: "pot" target to extract messages marked for translation

(-cc: Jakub)

Quoted 4 lines · Ævar Arnfjörð Bjarmason

There's also one other (future) issue your mv $i+ $i trick confuses xgettext, which complains about invalid CHARSET in a later patch when there's more than one xgettext call. I.e. it doesn't like to append to files that don't end in *.pot for some reason.

Hmm, I had been wondering where that message came from. Maybe the following would help?

---
 Makefile      |    4 ++--
 po/.gitignore |    2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
Makefile +2 -2
index 7497835..781af23 100644
@@ -2068,8 +2068,8 @@ XGETTEXT_FLAGS_C = $(XGETTEXT_FLAGS) --keyword=_ --keyword=N_ --language=C
 LOCALIZED_C := $(C_OBJ:o=c)
 
 po/git.pot: $(LOCALIZED_C)
-	$(QUIET_XGETTEXT)$(XGETTEXT) -o$@+ $(XGETTEXT_FLAGS_C) $(LOCALIZED_C) && \
-	mv $@+ $@
+	$(QUIET_XGETTEXT)$(XGETTEXT) -ogit-tmp.pot $(XGETTEXT_FLAGS_C) $(LOCALIZED_C) && \
+	mv git-tmp.pot $@
 
 pot: po/git.pot
 
po/.gitignore +1 -1
index a242a86..e3a8c5d 100644
@@ -1 +1 @@
-/git.pot
+*.pot
Signature · 1 line
1.7.4.1
#131 lore raw

Re: [PATCH v4 04/73] Makefile: "pot" target to extract messages marked for translation

Makefile XGETTEXT_FLAGS_C = $(XGETTEXT_FLAGS) --keyword=_ --keyword=N_ --language=C · line 2072

Quoted 8 lines · Jonathan Nieder

Hmm, I had been wondering where that message came from. Maybe the following would help?
...
po/git.pot: $(LOCALIZED_C)

Makefile +2 -2
-	$(QUIET_XGETTEXT)$(XGETTEXT) -o$@+ $(XGETTEXT_FLAGS_C) $(LOCALIZED_C) && \
-	mv $@+ $@
+	$(QUIET_XGETTEXT)$(XGETTEXT) -ogit-tmp.pot $(XGETTEXT_FLAGS_C) $(LOCALIZED_C) && \
+	mv git-tmp.pot $@

Yeah, or "tmp-$@".

In either case, I'd prefer to see the above removed the temporary and the target before running the command, following the idiom:

	rm -f $@+ $@ && \
        $(command that does not remove its output when killed) -o $@+ && \
        mv $@+ $@

Does xgettext leave output file specified with -o when it gets killed? If not, we don't have to use a temporary. Makefiles in gitk and git-gui do not seem to protect against it either.

#132 lore raw

Re: [PATCH v4 04/73] Makefile: "pot" target to extract messages marked for translation

Quoted 1 line · Junio C Hamano

Does xgettext leave output file specified with -o when it gets killed?

I don't think so. But xgettext collects output and then writes it all in one swoop, so it's hard to provoke problems that way in practice.

The possibility that had me worried is what hat happens when we start translating shell scripts:

	xgettext -o$@ $(XGETTEXT_FLAGS_C) $(LOCALIZED_C)
	xgettext -o$@ --add-missing $(XGETTEXT_FLAGS_SH) $(LOCALIZED_SH)
	xgettext -o$@ --add-missing $(XGETTEXT_FLAGS_PERL) $(LOCALIZED_PERL)

If the build is interrupted partway through, the output from the commands that succeeded will remain and leave out the messages that would have been added later out of the template.

#133 lore raw

PATCH v4 5/73 gettextize: git-init basic messages

In reply to Junio C Hamano

Change the user visible strings in init-db.c to use gettext localizations. This only converts messages which needed to be changed from "foo" to _("foo"), and didn't need any TRANSLATORS comments.

I haven't marked the messages in init_db_usage or init_db_options for translation, since that would require additional changes in parse-options.c. Those can be done later.

---
 builtin/init-db.c |   46 +++++++++++++++++++++++-----------------------
 1 files changed, 23 insertions(+), 23 deletions(-)
builtin/init-db.c +23 -23
index 4f5348e..f7ddf5b 100644
@@ -31,7 +31,7 @@ static void safe_create_dir(const char *dir, int share)
 		}
 	}
 	else if (share && adjust_shared_perm(dir))
-		die("Could not make %s writable by group", dir);
+		die(_("Could not make %s writable by group"), dir);
 }
 
 static void copy_templates_1(char *path, int baselen,
@@ -58,25 +58,25 @@ static void copy_templates_1(char *path, int baselen,
 		namelen = strlen(de->d_name);
 		if ((PATH_MAX <= baselen + namelen) ||
 		    (PATH_MAX <= template_baselen + namelen))
-			die("insanely long template name %s", de->d_name);
+			die(_("insanely long template name %s"), de->d_name);
 		memcpy(path + baselen, de->d_name, namelen+1);
 		memcpy(template + template_baselen, de->d_name, namelen+1);
 		if (lstat(path, &st_git)) {
 			if (errno != ENOENT)
-				die_errno("cannot stat '%s'", path);
+				die_errno(_("cannot stat '%s'"), path);
 		}
 		else
 			exists = 1;
 
 		if (lstat(template, &st_template))
-			die_errno("cannot stat template '%s'", template);
+			die_errno(_("cannot stat template '%s'"), template);
 
 		if (S_ISDIR(st_template.st_mode)) {
 			DIR *subdir = opendir(template);
 			int baselen_sub = baselen + namelen;
 			int template_baselen_sub = template_baselen + namelen;
 			if (!subdir)
-				die_errno("cannot opendir '%s'", template);
+				die_errno(_("cannot opendir '%s'"), template);
 			path[baselen_sub++] =
 				template[template_baselen_sub++] = '/';
 			path[baselen_sub] =
@@ -93,20 +93,20 @@ static void copy_templates_1(char *path, int baselen,
 			int len;
 			len = readlink(template, lnk, sizeof(lnk));
 			if (len < 0)
-				die_errno("cannot readlink '%s'", template);
+				die_errno(_("cannot readlink '%s'"), template);
 			if (sizeof(lnk) <= len)
-				die("insanely long symlink %s", template);
+				die(_("insanely long symlink %s"), template);
 			lnk[len] = 0;
 			if (symlink(lnk, path))
-				die_errno("cannot symlink '%s' '%s'", lnk, path);
+				die_errno(_("cannot symlink '%s' '%s'"), lnk, path);
 		}
 		else if (S_ISREG(st_template.st_mode)) {
 			if (copy_file(path, template, st_template.st_mode))
-				die_errno("cannot copy '%s' to '%s'", template,
+				die_errno(_("cannot copy '%s' to '%s'"), template,
 					  path);
 		}
 		else
-			error("ignoring template %s", template);
+			error(_("ignoring template %s"), template);
 	}
 }
 
@@ -129,7 +129,7 @@ static void copy_templates(const char *template_dir)
 		return;
 	template_len = strlen(template_dir);
 	if (PATH_MAX <= (template_len+strlen("/config")))
-		die("insanely long template path %s", template_dir);
+		die(_("insanely long template path %s"), template_dir);
 	strcpy(template_path, template_dir);
 	if (template_path[template_len-1] != '/') {
 		template_path[template_len++] = '/';
@@ -137,7 +137,7 @@ static void copy_templates(const char *template_dir)
 	}
 	dir = opendir(template_path);
 	if (!dir) {
-		warning("templates not found %s", template_dir);
+		warning(_("templates not found %s"), template_dir);
 		return;
 	}
 
@@ -150,8 +150,8 @@ static void copy_templates(const char *template_dir)
 
 	if (repository_format_version &&
 	    repository_format_version != GIT_REPO_VERSION) {
-		warning("not copying templates of "
-			"a wrong format version %d from '%s'",
+		warning(_("not copying templates of "
+			"a wrong format version %d from '%s'"),
 			repository_format_version,
 			template_dir);
 		closedir(dir);
@@ -188,7 +188,7 @@ static int create_default_files(const char *template_path)
 	int filemode;
 
 	if (len > sizeof(path)-50)
-		die("insane git directory %s", git_dir);
+		die(_("insane git directory %s"), git_dir);
 	memcpy(path, git_dir, len);
 
 	if (len && path[len-1] != '/')
@@ -375,7 +375,7 @@ static int guess_repository_type(const char *git_dir)
 	if (!strcmp(".", git_dir))
 		return 1;
 	if (!getcwd(cwd, sizeof(cwd)))
-		die_errno("cannot tell cwd");
+		die_errno(_("cannot tell cwd"));
 	if (!strcmp(git_dir, cwd))
 		return 1;
 	/*
@@ -450,18 +450,18 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
 					errno = EEXIST;
 					/* fallthru */
 				case -1:
-					die_errno("cannot mkdir %s", argv[0]);
+					die_errno(_("cannot mkdir %s"), argv[0]);
 					break;
 				default:
 					break;
 				}
 				shared_repository = saved;
 				if (mkdir(argv[0], 0777) < 0)
-					die_errno("cannot mkdir %s", argv[0]);
+					die_errno(_("cannot mkdir %s"), argv[0]);
 				mkdir_tried = 1;
 				goto retry;
 			}
-			die_errno("cannot chdir to %s", argv[0]);
+			die_errno(_("cannot chdir to %s"), argv[0]);
 		}
 	} else if (0 < argc) {
 		usage(init_db_usage[0]);
@@ -483,8 +483,8 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
 	git_dir = getenv(GIT_DIR_ENVIRONMENT);
 	work_tree = getenv(GIT_WORK_TREE_ENVIRONMENT);
 	if ((!git_dir || is_bare_repository_cfg == 1) && work_tree)
-		die("%s (or --work-tree=<directory>) not allowed without "
-		    "specifying %s (or --git-dir=<directory>)",
+		die(_("%s (or --work-tree=<directory>) not allowed without "
+			  "specifying %s (or --git-dir=<directory>)"),
 		    GIT_WORK_TREE_ENVIRONMENT,
 		    GIT_DIR_ENVIRONMENT);
 
@@ -509,14 +509,14 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
 		if (!git_work_tree_cfg) {
 			git_work_tree_cfg = xcalloc(PATH_MAX, 1);
 			if (!getcwd(git_work_tree_cfg, PATH_MAX))
-				die_errno ("Cannot access current working directory");
+				die_errno (_("Cannot access current working directory"));
 		}
 		if (work_tree)
 			set_git_work_tree(make_absolute_path(work_tree));
 		else
 			set_git_work_tree(git_work_tree_cfg);
 		if (access(get_git_work_tree(), X_OK))
-			die_errno ("Cannot access work tree '%s'",
+			die_errno (_("Cannot access work tree '%s'"),
 				   get_git_work_tree());
 	}
 	else {
Signature · 1 line
1.7.2.3
#134 lore raw

PATCH v4 6/73 gettextize: git-init "Initialized [...] repository" message

In reply to Junio C Hamano

These messages could benefit from splitting up. An earlier version of this patch began like this:

    const char *reinit_shared   = _("Reinitialized existing shared Git repository in %s\n");
    const char *init_shared     = _("Initialized empty shared Git repository in %s\n");
    const char *reinit_noshared = _("Reinitialized existing Git repository in %s\n");
    const char *init_noshared   = _("Initialized empty Git repository in %s\n");

But in the first round of gettextization I'm aiming to keep code changes to a minimum for ease of review. So just add a comment explaining to translators how the sprintf format gets used so they can cope for now if the language's grammar allows.

---
 builtin/init-db.c |   12 +++++++++---
 t/t0001-init.sh   |    2 +-
 2 files changed, 10 insertions(+), 4 deletions(-)
builtin/init-db.c +9 -3
index f7ddf5b..e0e5ce3 100644
@@ -354,9 +354,15 @@ int init_db(const char *template_dir, unsigned int flags)
 	if (!(flags & INIT_DB_QUIET)) {
 		const char *git_dir = get_git_dir();
 		int len = strlen(git_dir);
-		printf("%s%s Git repository in %s%s\n",
-		       reinit ? "Reinitialized existing" : "Initialized empty",
-		       shared_repository ? " shared" : "",
+
+		/*
+		 * TRANSLATORS: The first '%s' is either "Reinitialized
+		 * existing" or "Initialized empty", the second " shared" or
+		 * "", and the last '%s%s' is the verbatim directory name.
+		 */
+		printf(_("%s%s Git repository in %s%s\n"),
+		       reinit ? _("Reinitialized existing") : _("Initialized empty"),
+		       shared_repository ? _(" shared") : "",
 		       git_dir, len && git_dir[len-1] != '/' ? "/" : "");
 	}
 
t/t0001-init.sh +1 -1
index f684993..dd4c00d 100755
@@ -180,7 +180,7 @@ test_expect_success 'GIT_DIR & GIT_WORK_TREE (2)' '
 	fi
 '
 
-test_expect_success 'reinit' '
+test_expect_success C_LOCALE_OUTPUT 'reinit' '
 
 	(
 		sane_unset GIT_CONFIG GIT_WORK_TREE GIT_CONFIG &&
Signature · 1 line
1.7.2.3
#135 lore raw

PATCH v4 7/73 gettextize: git-clone basic messages

In reply to Junio C Hamano
---
 builtin/clone.c |   54 +++++++++++++++++++++++++++---------------------------
 1 files changed, 27 insertions(+), 27 deletions(-)
builtin/clone.c +27 -27
index 60d9a64..f46d09b 100644
@@ -208,7 +208,7 @@ static void setup_reference(const char *repo)
 	if (is_directory(mkpath("%s/.git/objects", ref_git)))
 		ref_git = mkpath("%s/.git", ref_git);
 	else if (!is_directory(mkpath("%s/objects", ref_git)))
-		die("reference repository '%s' is not a local directory.",
+		die(_("reference repository '%s' is not a local directory."),
 		    option_reference);
 
 	ref_git_copy = xstrdup(ref_git);
@@ -235,15 +235,15 @@ static void copy_or_link_directory(struct strbuf *src, struct strbuf *dest)
 
 	dir = opendir(src->buf);
 	if (!dir)
-		die_errno("failed to open '%s'", src->buf);
+		die_errno(_("failed to open '%s'"), src->buf);
 
 	if (mkdir(dest->buf, 0777)) {
 		if (errno != EEXIST)
-			die_errno("failed to create directory '%s'", dest->buf);
+			die_errno(_("failed to create directory '%s'"), dest->buf);
 		else if (stat(dest->buf, &buf))
-			die_errno("failed to stat '%s'", dest->buf);
+			die_errno(_("failed to stat '%s'"), dest->buf);
 		else if (!S_ISDIR(buf.st_mode))
-			die("%s exists and is not a directory", dest->buf);
+			die(_("%s exists and is not a directory"), dest->buf);
 	}
 
 	strbuf_addch(src, '/');
@@ -257,7 +257,7 @@ static void copy_or_link_directory(struct strbuf *src, struct strbuf *dest)
 		strbuf_setlen(dest, dest_len);
 		strbuf_addstr(dest, de->d_name);
 		if (stat(src->buf, &buf)) {
-			warning ("failed to stat %s\n", src->buf);
+			warning (_("failed to stat %s\n"), src->buf);
 			continue;
 		}
 		if (S_ISDIR(buf.st_mode)) {
@@ -267,16 +267,16 @@ static void copy_or_link_directory(struct strbuf *src, struct strbuf *dest)
 		}
 
 		if (unlink(dest->buf) && errno != ENOENT)
-			die_errno("failed to unlink '%s'", dest->buf);
+			die_errno(_("failed to unlink '%s'"), dest->buf);
 		if (!option_no_hardlinks) {
 			if (!link(src->buf, dest->buf))
 				continue;
 			if (option_local)
-				die_errno("failed to create link '%s'", dest->buf);
+				die_errno(_("failed to create link '%s'"), dest->buf);
 			option_no_hardlinks = 1;
 		}
 		if (copy_file_with_time(dest->buf, src->buf, 0666))
-			die_errno("failed to copy file to '%s'", dest->buf);
+			die_errno(_("failed to copy file to '%s'"), dest->buf);
 	}
 	closedir(dir);
 }
@@ -305,7 +305,7 @@ static const struct ref *clone_local(const char *src_repo,
 	ret = transport_get_remote_refs(transport);
 	transport_disconnect(transport);
 	if (0 <= option_verbosity)
-		printf("done.\n");
+		printf(_("done.\n"));
 	return ret;
 }
 
@@ -387,11 +387,11 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 			     builtin_clone_usage, 0);
 
 	if (argc > 2)
-		usage_msg_opt("Too many arguments.",
+		usage_msg_opt(_("Too many arguments."),
 			builtin_clone_usage, builtin_clone_options);
 
 	if (argc == 0)
-		usage_msg_opt("You must specify a repository to clone.",
+		usage_msg_opt(_("You must specify a repository to clone."),
 			builtin_clone_usage, builtin_clone_options);
 
 	if (option_mirror)
@@ -399,7 +399,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 
 	if (option_bare) {
 		if (option_origin)
-			die("--bare and --origin %s options are incompatible.",
+			die(_("--bare and --origin %s options are incompatible."),
 			    option_origin);
 		option_no_checkout = 1;
 	}
@@ -418,7 +418,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 		repo = repo_name;
 	is_local = path && !is_bundle;
 	if (is_local && option_depth)
-		warning("--depth is ignored in local clones; use file:// instead.");
+		warning(_("--depth is ignored in local clones; use file:// instead."));
 
 	if (argc == 2)
 		dir = xstrdup(argv[1]);
@@ -428,8 +428,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 
 	dest_exists = !stat(dir, &buf);
 	if (dest_exists && !is_empty_dir(dir))
-		die("destination path '%s' already exists and is not "
-			"an empty directory.", dir);
+		die(_("destination path '%s' already exists and is not "
+			"an empty directory."), dir);
 
 	strbuf_addf(&reflog_msg, "clone: from %s", repo);
 
@@ -438,7 +438,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 	else {
 		work_tree = getenv("GIT_WORK_TREE");
 		if (work_tree && !stat(work_tree, &buf))
-			die("working tree '%s' already exists.", work_tree);
+			die(_("working tree '%s' already exists."), work_tree);
 	}
 
 	if (option_bare || work_tree)
@@ -451,10 +451,10 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 	if (!option_bare) {
 		junk_work_tree = work_tree;
 		if (safe_create_leading_directories_const(work_tree) < 0)
-			die_errno("could not create leading directories of '%s'",
+			die_errno(_("could not create leading directories of '%s'"),
 				  work_tree);
 		if (!dest_exists && mkdir(work_tree, 0755))
-			die_errno("could not create work tree dir '%s'.",
+			die_errno(_("could not create work tree dir '%s'."),
 				  work_tree);
 		set_git_work_tree(work_tree);
 	}
@@ -465,7 +465,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 	setenv(CONFIG_ENVIRONMENT, mkpath("%s/config", git_dir), 1);
 
 	if (safe_create_leading_directories_const(git_dir) < 0)
-		die("could not create leading directories of '%s'", git_dir);
+		die(_("could not create leading directories of '%s'"), git_dir);
 	set_git_dir(make_absolute_path(git_dir));
 
 	if (0 <= option_verbosity)
@@ -527,7 +527,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 		transport = transport_get(remote, remote->url[0]);
 
 		if (!transport->get_refs_list || !transport->fetch)
-			die("Don't know how to clone %s", transport->url);
+			die(_("Don't know how to clone %s"), transport->url);
 
 		transport_set_option(transport, TRANS_OPT_KEEP, "yes");
 
@@ -566,8 +566,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 			strbuf_release(&head);
 
 			if (!our_head_points_at) {
-				warning("Remote branch %s not found in "
-					"upstream %s, using HEAD instead",
+				warning(_("Remote branch %s not found in "
+					"upstream %s, using HEAD instead"),
 					option_branch, option_origin);
 				our_head_points_at = remote_head_points_at;
 			}
@@ -576,7 +576,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 			our_head_points_at = remote_head_points_at;
 	}
 	else {
-		warning("You appear to have cloned an empty repository.");
+		warning(_("You appear to have cloned an empty repository."));
 		our_head_points_at = NULL;
 		remote_head_points_at = NULL;
 		remote_head = NULL;
@@ -618,8 +618,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 	} else {
 		/* Nothing to checkout out */
 		if (!option_no_checkout)
-			warning("remote HEAD refers to nonexistent ref, "
-				"unable to checkout.\n");
+			warning(_("remote HEAD refers to nonexistent ref, "
+				"unable to checkout.\n"));
 		option_no_checkout = 1;
 	}
 
@@ -655,7 +655,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 
 		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"));
 
 		err |= run_hook(NULL, "post-checkout", sha1_to_hex(null_sha1),
 				sha1_to_hex(our_head_points_at->old_sha1), "1",
Signature · 1 line
1.7.2.3
#136 lore raw

PATCH v4 8/73 gettextize: git-clone "Cloning into" message

In reply to Junio C Hamano

Separate the "Cloning into %s" and "Cloning into bare repository %s" messages to make them easier to translate. No noticeable change intended.

---
 builtin/clone.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)
builtin/clone.c +6 -3
index f46d09b..db0240d 100644
@@ -468,9 +468,12 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 		die(_("could not create leading directories of '%s'"), git_dir);
 	set_git_dir(make_absolute_path(git_dir));
 
-	if (0 <= option_verbosity)
-		printf("Cloning into %s%s...\n",
-		       option_bare ? "bare repository " : "", dir);
+	if (0 <= option_verbosity) {
+		if (option_bare)
+			printf("Cloning into bare repository %s...\n", dir);
+		else
+			printf("Cloning into %s...\n", dir);
+	}
 	init_db(option_template, INIT_DB_QUIET);
 
 	/*
Signature · 1 line
1.7.2.3
#137 lore raw

PATCH v4 9/73 gettextize: git-clone "Cloning into" message

In reply to Junio C Hamano
---
 builtin/clone.c  |    4 ++--
 t/t5601-clone.sh |    2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
builtin/clone.c +2 -2
index db0240d..b9394c4 100644
@@ -470,9 +470,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 
 	if (0 <= option_verbosity) {
 		if (option_bare)
-			printf("Cloning into bare repository %s...\n", dir);
+			printf(_("Cloning into bare repository %s...\n"), dir);
 		else
-			printf("Cloning into %s...\n", dir);
+			printf(_("Cloning into %s...\n"), dir);
 	}
 	init_db(option_template, INIT_DB_QUIET);
 
t/t5601-clone.sh +1 -1
index 987e0c8..9e6fa3b 100755
@@ -31,7 +31,7 @@ test_expect_success 'clone with excess parameters (2)' '
 
 '
 
-test_expect_success 'output from clone' '
+test_expect_success C_LOCALE_OUTPUT 'output from clone' '
 	rm -fr dst &&
 	git clone -n "file://$(pwd)/src" dst >output &&
 	test $(grep Clon output | wc -l) = 1
Signature · 1 line
1.7.2.3
#138 lore raw

PATCH v4 10/73 gettextize: git-add basic messages

In reply to Junio C Hamano
---
 builtin/add.c |   36 ++++++++++++++++++------------------
 1 files changed, 18 insertions(+), 18 deletions(-)
builtin/add.c +18 -18
index 42c906e..a9a78f4 100644
@@ -38,7 +38,7 @@ static void update_callback(struct diff_queue_struct *q,
 		const char *path = p->one->path;
 		switch (p->status) {
 		default:
-			die("unexpected diff status %c", p->status);
+			die(_("unexpected diff status %c"), p->status);
 		case DIFF_STATUS_UNMERGED:
 			/*
 			 * ADD_CACHE_IGNORE_REMOVAL is unset if "git
@@ -64,7 +64,7 @@ static void update_callback(struct diff_queue_struct *q,
 		case DIFF_STATUS_TYPE_CHANGED:
 			if (add_file_to_index(&the_index, path, data->flags)) {
 				if (!(data->flags & ADD_CACHE_IGNORE_ERRORS))
-					die("updating files failed");
+					die(_("updating files failed"));
 				data->add_errors++;
 			}
 			break;
@@ -172,7 +172,7 @@ static void treat_gitlinks(const char **pathspec)
 					/* strip trailing slash */
 					pathspec[j] = xstrndup(ce->name, len);
 				else
-					die ("Path '%s' is in submodule '%.*s'",
+					die (_("Path '%s' is in submodule '%.*s'"),
 						pathspec[j], len, ce->name);
 			}
 		}
@@ -191,7 +191,7 @@ static void refresh(int verbose, const char **pathspec)
 		      pathspec, seen, "Unstaged changes after refreshing the index:");
 	for (i = 0; i < specs; i++) {
 		if (!seen[i])
-			die("pathspec '%s' did not match any files", pathspec[i]);
+			die(_("pathspec '%s' did not match any files"), pathspec[i]);
 	}
         free(seen);
 }
@@ -205,7 +205,7 @@ static const char **validate_pathspec(int argc, const char **argv, const char *p
 		for (p = pathspec; *p; p++) {
 			if (has_symlink_leading_path(*p, strlen(*p))) {
 				int len = prefix ? strlen(prefix) : 0;
-				die("'%s' is beyond a symbolic link", *p + len);
+				die(_("'%s' is beyond a symbolic link"), *p + len);
 			}
 		}
 	}
@@ -272,7 +272,7 @@ static int edit_patch(int argc, const char **argv, const char *prefix)
 	git_config(git_diff_basic_config, NULL); /* no "diff" UI options */
 
 	if (read_cache() < 0)
-		die ("Could not read the index");
+		die (_("Could not read the index"));
 
 	init_revisions(&rev, prefix);
 	rev.diffopt.context = 7;
@@ -281,24 +281,24 @@ static int edit_patch(int argc, const char **argv, const char *prefix)
 	rev.diffopt.output_format = DIFF_FORMAT_PATCH;
 	out = open(file, O_CREAT | O_WRONLY, 0644);
 	if (out < 0)
-		die ("Could not open '%s' for writing.", file);
+		die (_("Could not open '%s' for writing."), file);
 	rev.diffopt.file = xfdopen(out, "w");
 	rev.diffopt.close_file = 1;
 	if (run_diff_files(&rev, 0))
-		die ("Could not write patch");
+		die (_("Could not write patch"));
 
 	launch_editor(file, NULL, NULL);
 
 	if (stat(file, &st))
-		die_errno("Could not stat '%s'", file);
+		die_errno(_("Could not stat '%s'"), file);
 	if (!st.st_size)
-		die("Empty patch. Aborted.");
+		die(_("Empty patch. Aborted."));
 
 	memset(&child, 0, sizeof(child));
 	child.git_cmd = 1;
 	child.argv = apply_argv;
 	if (run_command(&child))
-		die ("Could not apply '%s'", file);
+		die (_("Could not apply '%s'"), file);
 
 	unlink(file);
 	return 0;
@@ -354,7 +354,7 @@ static int add_files(struct dir_struct *dir, int flags)
 	for (i = 0; i < dir->nr; i++)
 		if (add_file_to_cache(dir->entries[i]->name, flags)) {
 			if (!ignore_add_errors)
-				die("adding files failed");
+				die(_("adding files failed"));
 			exit_status = 1;
 		}
 	return exit_status;
@@ -386,9 +386,9 @@ int cmd_add(int argc, const char **argv, const char *prefix)
 	argv++;
 
 	if (addremove && take_worktree_changes)
-		die("-A and -u are mutually incompatible");
+		die(_("-A and -u are mutually incompatible"));
 	if (!show_only && ignore_missing)
-		die("Option --ignore-missing can only be used together with --dry-run");
+		die(_("Option --ignore-missing can only be used together with --dry-run"));
 	if ((addremove || take_worktree_changes) && !argc) {
 		static const char *here[2] = { ".", NULL };
 		argc = 1;
@@ -408,14 +408,14 @@ int cmd_add(int argc, const char **argv, const char *prefix)
 		  ? ADD_CACHE_IGNORE_REMOVAL : 0));
 
 	if (require_pathspec && argc == 0) {
-		fprintf(stderr, "Nothing specified, nothing added.\n");
-		fprintf(stderr, "Maybe you wanted to say 'git add .'?\n");
+		fprintf(stderr, _("Nothing specified, nothing added.\n"));
+		fprintf(stderr, _("Maybe you wanted to say 'git add .'?\n"));
 		return 0;
 	}
 	pathspec = validate_pathspec(argc, argv, prefix);
 
 	if (read_cache() < 0)
-		die("index file corrupt");
+		die(_("index file corrupt"));
 	treat_gitlinks(pathspec);
 
 	if (add_new_files) {
@@ -467,7 +467,7 @@ int cmd_add(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 exit_status;
Signature · 1 line
1.7.2.3
#139 lore raw

PATCH v4 11/73 gettextize: git-add "The following paths are ignored" message

In reply to Junio C Hamano

The tests t2204 (.gitignore) and t3700 (add) explicitly check for these messages, so while at it, split each relevant test into a part that just checks "git add"'s exit status and a part that checks porcelain output.

---
 builtin/add.c          |    8 ++++----
 t/t2204-add-ignored.sh |   37 +++++++++++++++++++++++++------------
 t/t3700-add.sh         |    5 ++++-
 3 files changed, 33 insertions(+), 17 deletions(-)
builtin/add.c +4 -4
index a9a78f4..21776ac 100644
@@ -307,7 +307,7 @@ static int edit_patch(int argc, const char **argv, const char *prefix)
 static struct lock_file lock_file;
 
 static const char ignore_error[] =
-"The following paths are ignored by one of your .gitignore files:\n";
+N_("The following paths are ignored by one of your .gitignore files:\n");
 
 static int verbose = 0, show_only = 0, ignored_too = 0, refresh_only = 0;
 static int ignore_add_errors, addremove, intent_to_add, ignore_missing = 0;
@@ -344,11 +344,11 @@ static int add_files(struct dir_struct *dir, int flags)
 	int i, exit_status = 0;
 
 	if (dir->ignored_nr) {
-		fprintf(stderr, ignore_error);
+		fprintf(stderr, _(ignore_error));
 		for (i = 0; i < dir->ignored_nr; i++)
 			fprintf(stderr, "%s\n", dir->ignored[i]->name);
-		fprintf(stderr, "Use -f if you really want to add them.\n");
-		die("no files added");
+		fprintf(stderr, _("Use -f if you really want to add them.\n"));
+		die(_("no files added"));
 	}
 
 	for (i = 0; i < dir->nr; i++)
t/t2204-add-ignored.sh +25 -12
index 24afdab..4975336 100755
@@ -31,18 +31,21 @@ do
 		rm -f .git/index &&
 		test_must_fail git add "$i" 2>err &&
 		git ls-files "$i" >out &&
-		! test -s out &&
-		grep -e "Use -f if" err &&
-		cat err
+		! test -s out
+	'
+
+	test_expect_success C_LOCALE_OUTPUT "complaints for ignored $i output" '
+		grep -e "Use -f if" err
 	'
 
 	test_expect_success "complaints for ignored $i with unignored file" '
 		rm -f .git/index &&
 		test_must_fail git add "$i" file 2>err &&
 		git ls-files "$i" >out &&
-		! test -s out &&
-		grep -e "Use -f if" err &&
-		cat err
+		! test -s out
+	'
+	test_expect_success C_LOCALE_OUTPUT "complaints for ignored $i with unignored file output" '
+		grep -e "Use -f if" err
 	'
 done
 
@@ -54,9 +57,14 @@ do
 			cd dir &&
 			test_must_fail git add "$i" 2>err &&
 			git ls-files "$i" >out &&
-			! test -s out &&
-			grep -e "Use -f if" err &&
-			cat err
+			! test -s out
+		)
+	'
+
+	test_expect_success C_LOCALE_OUTPUT "complaints for ignored $i in dir output" '
+		(
+			cd dir &&
+			grep -e "Use -f if" err
 		)
 	'
 done
@@ -69,9 +77,14 @@ do
 			cd sub &&
 			test_must_fail git add "$i" 2>err &&
 			git ls-files "$i" >out &&
-			! test -s out &&
-			grep -e "Use -f if" err &&
-			cat err
+			! test -s out
+		)
+	'
+
+	test_expect_success C_LOCALE_OUTPUT "complaints for ignored $i in sub output" '
+		(
+			cd sub &&
+			grep -e "Use -f if" err
 		)
 	'
 done
t/t3700-add.sh +4 -1
index ec71083..ac115ed 100755
@@ -283,7 +283,10 @@ add 'track-this'
 EOF
 
 test_expect_success 'git add --dry-run --ignore-missing of non-existing file' '
-	test_must_fail git add --dry-run --ignore-missing track-this ignored-file >actual.out 2>actual.err &&
+	test_must_fail git add --dry-run --ignore-missing track-this ignored-file >actual.out 2>actual.err
+'
+
+test_expect_success C_LOCALE_OUTPUT 'git add --dry-run --ignore-missing of non-existing file output' '
 	test_cmp expect.out actual.out &&
 	test_cmp expect.err actual.err
 '
Signature · 1 line
1.7.2.3
#140 lore raw

PATCH v4 12/73 gettextize: git-add "did not match any files" message

In reply to Junio C Hamano

Make the "did not match any files" message translatable, and skip the test that checks for it when the C_LOCALE_OUTPUT prereq is not present.

---
 builtin/add.c  |    2 +-
 t/t3700-add.sh |    8 ++++++--
 2 files changed, 7 insertions(+), 3 deletions(-)
builtin/add.c +1 -1
index 21776ac..ffbd459 100644
@@ -451,7 +451,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
 					if (excluded(&dir, pathspec[i], &dtype))
 						dir_add_ignored(&dir, pathspec[i], strlen(pathspec[i]));
 				} else
-					die("pathspec '%s' did not match any files",
+					die(_("pathspec '%s' did not match any files"),
 					    pathspec[i]);
 			}
 		}
t/t3700-add.sh +6 -2
index ac115ed..7de42fa 100755
@@ -268,8 +268,12 @@ test_expect_success 'git add --dry-run of existing changed file' "
 
 test_expect_success 'git add --dry-run of non-existing file' "
 	echo ignored-file >>.gitignore &&
-	test_must_fail git add --dry-run track-this ignored-file >actual 2>&1 &&
-	echo \"fatal: pathspec 'ignored-file' did not match any files\" | test_cmp - actual
+	test_must_fail git add --dry-run track-this ignored-file >actual 2>&1
+"
+
+test_expect_success C_LOCALE_OUTPUT 'git add --dry-run of an existing file output' "
+	echo \"fatal: pathspec 'ignored-file' did not match any files\" >expect &&
+	test_cmp expect actual
 "
 
 cat >expect.err <<\EOF
Signature · 1 line
1.7.2.3
#141 lore raw

PATCH v4 13/73 gettextize: git-add "remove '%s'" message

In reply to Junio C Hamano

Make the "remove '%s'" message translatable. It's displayed under git add -u --verbose. Also skip the corresponding test when output is not in the C locale.

---
 builtin/add.c         |    2 +-
 t/t2200-add-update.sh |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
builtin/add.c +1 -1
index ffbd459..33b9970 100644
@@ -74,7 +74,7 @@ static void update_callback(struct diff_queue_struct *q,
 			if (!(data->flags & ADD_CACHE_PRETEND))
 				remove_file_from_index(&the_index, path);
 			if (data->flags & (ADD_CACHE_PRETEND|ADD_CACHE_VERBOSE))
-				printf("remove '%s'\n", path);
+				printf(_("remove '%s'\n"), path);
 			break;
 		}
 	}
t/t2200-add-update.sh +1 -1
index 0692427..856e7da 100755
@@ -111,7 +111,7 @@ test_expect_success 'touch and then add explicitly' '
 
 '
 
-test_expect_success 'add -n -u should not add but just report' '
+test_expect_success C_LOCALE_OUTPUT 'add -n -u should not add but just report' '
 
 	(
 		echo "add '\''check'\''" &&
Signature · 1 line
1.7.2.3
#142 lore raw

PATCH v4 14/73 gettextize: git-add "Unstaged changes" message

In reply to Junio C Hamano

Make the "Unstaged changes after refreshing the index:" translatable. It's displayed under git add --refresh --verbose.

---
 builtin/add.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
builtin/add.c +1 -1
index 33b9970..a512597 100644
@@ -188,7 +188,7 @@ static void refresh(int verbose, const char **pathspec)
 		/* nothing */;
 	seen = xcalloc(specs, 1);
 	refresh_index(&the_index, verbose ? REFRESH_IN_PORCELAIN : REFRESH_QUIET,
-		      pathspec, seen, "Unstaged changes after refreshing the index:");
+		      pathspec, seen, _("Unstaged changes after refreshing the index:"));
 	for (i = 0; i < specs; i++) {
 		if (!seen[i])
 			die(_("pathspec '%s' did not match any files"), pathspec[i]);
Signature · 1 line
1.7.2.3
#143 lore raw

PATCH v4 15/73 gettextize: git-branch basic messages

In reply to Junio C Hamano
---
 builtin/branch.c |   56 +++++++++++++++++++++++++++---------------------------
 1 files changed, 28 insertions(+), 28 deletions(-)
builtin/branch.c +28 -28
index 9e546e4..6695db4 100644
@@ -133,12 +133,12 @@ static int branch_merged(int kind, const char *name,
 	if ((head_rev != reference_rev) &&
 	    in_merge_bases(rev, &head_rev, 1) != merged) {
 		if (merged)
-			warning("deleting branch '%s' that has been merged to\n"
-				"         '%s', but it is not yet merged to HEAD.",
+			warning(_("deleting branch '%s' that has been merged to\n"
+				"         '%s', but it is not yet merged to HEAD."),
 				name, reference_name);
 		else
-			warning("not deleting branch '%s' that is not yet merged to\n"
-				"         '%s', even though it is merged to HEAD.",
+			warning(_("not deleting branch '%s' that is not yet merged to\n"
+				"         '%s', even though it is merged to HEAD."),
 				name, reference_name);
 	}
 	return merged;
@@ -165,19 +165,19 @@ static int delete_branches(int argc, const char **argv, int force, int kinds)
 		remote = "";
 		break;
 	default:
-		die("cannot use -a with -d");
+		die(_("cannot use -a with -d"));
 	}
 
 	if (!force) {
 		head_rev = lookup_commit_reference(head_sha1);
 		if (!head_rev)
-			die("Couldn't look up commit object for HEAD");
+			die(_("Couldn't look up commit object for HEAD"));
 	}
 	for (i = 0; i < argc; i++, strbuf_release(&bname)) {
 		strbuf_branchname(&bname, argv[i]);
 		if (kinds == REF_LOCAL_BRANCH && !strcmp(head, bname.buf)) {
-			error("Cannot delete the branch '%s' "
-			      "which you are currently on.", bname.buf);
+			error(_("Cannot delete the branch '%s' "
+			      "which you are currently on."), bname.buf);
 			ret = 1;
 			continue;
 		}
@@ -186,7 +186,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds)
 
 		name = xstrdup(mkpath(fmt, bname.buf));
 		if (!resolve_ref(name, sha1, 1, NULL)) {
-			error("%sbranch '%s' not found.",
+			error(_("%sbranch '%s' not found."),
 					remote, bname.buf);
 			ret = 1;
 			continue;
@@ -194,21 +194,21 @@ static int delete_branches(int argc, const char **argv, int force, int kinds)
 
 		rev = lookup_commit_reference(sha1);
 		if (!rev) {
-			error("Couldn't look up commit object for '%s'", name);
+			error(_("Couldn't look up commit object for '%s'"), name);
 			ret = 1;
 			continue;
 		}
 
 		if (!force && !branch_merged(kinds, bname.buf, rev, head_rev)) {
-			error("The branch '%s' is not fully merged.\n"
+			error(_("The branch '%s' is not fully merged.\n"
 			      "If you are sure you want to delete it, "
-			      "run 'git branch -D %s'.", bname.buf, bname.buf);
+			      "run 'git branch -D %s'."), bname.buf, bname.buf);
 			ret = 1;
 			continue;
 		}
 
 		if (delete_ref(name, sha1, 0)) {
-			error("Error deleting %sbranch '%s'", remote,
+			error(_("Error deleting %sbranch '%s'"), remote,
 			      bname.buf);
 			ret = 1;
 		} else {
@@ -218,7 +218,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds)
 			       find_unique_abbrev(sha1, DEFAULT_ABBREV));
 			strbuf_addf(&buf, "branch.%s", bname.buf);
 			if (git_config_rename_section(buf.buf, NULL) < 0)
-				warning("Update of config-file failed");
+				warning(_("Update of config-file failed"));
 			strbuf_release(&buf);
 		}
 	}
@@ -300,7 +300,7 @@ static int append_ref(const char *refname, const unsigned char *sha1, int flags,
 	if (ref_list->verbose || ref_list->with_commit || merge_filter != NO_FILTER) {
 		commit = lookup_commit_reference_gently(sha1, 1);
 		if (!commit) {
-			cb->ret = error("branch '%s' does not point at a commit", refname);
+			cb->ret = error(_("branch '%s' does not point at a commit"), refname);
 			return 0;
 		}
 
@@ -535,7 +535,7 @@ static int print_ref_list(int kinds, int detached, int verbose, int abbrev, stru
 	free_ref_list(&ref_list);
 
 	if (cb.ret)
-		error("some refs could not be read");
+		error(_("some refs could not be read"));
 
 	return cb.ret;
 }
@@ -548,7 +548,7 @@ static void rename_branch(const char *oldname, const char *newname, int force)
 	int recovery = 0;
 
 	if (!oldname)
-		die("cannot rename the current branch while not on any.");
+		die(_("cannot rename the current branch while not on any."));
 
 	if (strbuf_check_branch_ref(&oldref, oldname)) {
 		/*
@@ -558,35 +558,35 @@ static void rename_branch(const char *oldname, const char *newname, int force)
 		if (resolve_ref(oldref.buf, sha1, 1, NULL))
 			recovery = 1;
 		else
-			die("Invalid branch name: '%s'", oldname);
+			die(_("Invalid branch name: '%s'"), oldname);
 	}
 
 	if (strbuf_check_branch_ref(&newref, newname))
-		die("Invalid branch name: '%s'", newname);
+		die(_("Invalid branch name: '%s'"), newname);
 
 	if (resolve_ref(newref.buf, sha1, 1, NULL) && !force)
-		die("A branch named '%s' already exists.", newref.buf + 11);
+		die(_("A branch named '%s' already exists."), newref.buf + 11);
 
 	strbuf_addf(&logmsg, "Branch: renamed %s to %s",
 		 oldref.buf, newref.buf);
 
 	if (rename_ref(oldref.buf, newref.buf, logmsg.buf))
-		die("Branch rename failed");
+		die(_("Branch rename failed"));
 	strbuf_release(&logmsg);
 
 	if (recovery)
-		warning("Renamed a misnamed branch '%s' away", oldref.buf + 11);
+		warning(_("Renamed a misnamed branch '%s' away"), oldref.buf + 11);
 
 	/* no need to pass logmsg here as HEAD didn't really move */
 	if (!strcmp(oldname, head) && create_symref("HEAD", newref.buf, NULL))
-		die("Branch renamed to %s, but HEAD is not updated!", newname);
+		die(_("Branch renamed to %s, but HEAD is not updated!"), newname);
 
 	strbuf_addf(&oldsection, "branch.%s", oldref.buf + 11);
 	strbuf_release(&oldref);
 	strbuf_addf(&newsection, "branch.%s", newref.buf + 11);
 	strbuf_release(&newref);
 	if (git_config_rename_section(oldsection.buf, newsection.buf) < 0)
-		die("Branch is renamed, but update of config-file failed");
+		die(_("Branch is renamed, but update of config-file failed"));
 	strbuf_release(&oldsection);
 	strbuf_release(&newsection);
 }
@@ -601,7 +601,7 @@ static int opt_parse_merge_filter(const struct option *opt, const char *arg, int
 	if (!arg)
 		arg = "HEAD";
 	if (get_sha1(arg, merge_filter_ref))
-		die("malformed object name %s", arg);
+		die(_("malformed object name %s"), arg);
 	return 0;
 }
 
@@ -675,13 +675,13 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
 
 	head = resolve_ref("HEAD", head_sha1, 0, NULL);
 	if (!head)
-		die("Failed to resolve HEAD as a valid ref.");
+		die(_("Failed to resolve HEAD as a valid ref."));
 	head = xstrdup(head);
 	if (!strcmp(head, "HEAD")) {
 		detached = 1;
 	} else {
 		if (prefixcmp(head, "refs/heads/"))
-			die("HEAD not found below refs/heads!");
+			die(_("HEAD not found below refs/heads!"));
 		head += 11;
 	}
 	hashcpy(merge_filter_ref, head_sha1);
@@ -701,7 +701,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
 		rename_branch(argv[0], argv[1], rename > 1);
 	else if (argc <= 2) {
 		if (kinds != REF_LOCAL_BRANCH)
-			die("-a and -r options to 'git branch' do not make sense with a branch name");
+			die(_("-a and -r options to 'git branch' do not make sense with a branch name"));
 		create_branch(head, argv[0], (argc == 2) ? argv[1] : head,
 			      force_create, reflog, track);
 	} else
Signature · 1 line
1.7.2.3
#144 lore raw

PATCH v4 16/73 gettextize: git-branch "remote branch '%s' not found" message

In reply to Junio C Hamano

This could be done better by splitting it up, but it would change too much code, which I'm trying to avoid at this point. Instead add a TRANSLATORS comment to explain what "remote " does.

---
 builtin/branch.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
builtin/branch.c +2 -1
index 6695db4..e9d8a5a 100644
@@ -157,7 +157,8 @@ static int delete_branches(int argc, const char **argv, int force, int kinds)
 	switch (kinds) {
 	case REF_REMOTE_BRANCH:
 		fmt = "refs/remotes/%s";
-		remote = "remote ";
+		/* TRANSLATORS: This is "remote " in "remote branch '%s' not found" */
+		remote = _("remote ");
 		force = 1;
 		break;
 	case REF_LOCAL_BRANCH:
Signature · 1 line
1.7.2.3
#145 lore raw

Re: [PATCH v4 16/73] gettextize: git-branch "remote branch '%s' not found" message

W dniu 23.02.2011 00:41, Ævar Arnfjörð Bjarmason pisze:

Quoted 3 lines

This could be done better by splitting it up, but it would change too much code, which I'm trying to avoid at this point. Instead add a TRANSLATORS comment to explain what "remote " does.

Not sure what you meant by splitting it up. Hopefully not splitting the text even more?

IMO all such code will have to be rewritten to allow better translation. Example patch at the bottom.

I remember at least one more such case - it was sth like "%s %s %s" where first part was translatable but defined somewhere else.

This can be done before or after applying the i18n patches, but if it's going to be done after, then I think it'd be better to mark such places as "to be rewritten" instead of just simply marking them for translation.

Quoted 11 lines
---
 builtin/branch.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
builtin/branch.c +0 -0
index 6695db4..e9d8a5a 100644

builtin/branch.c static int delete_branches(int argc, const char **argv, int force, int kinds) · line 164

Quoted 9 lines
builtin/branch.c +2 -1
@@ -157,7 +157,8 @@ static int delete_branches(int argc, const char **argv, int force, int kinds)
 	switch (kinds) {
 	case REF_REMOTE_BRANCH:
 		fmt = "refs/remotes/%s";
-		remote = "remote ";
+		/* TRANSLATORS: This is "remote " in "remote branch '%s' not found" */
+		remote = _("remote ");
 		force = 1;
 		break;
 	case REF_LOCAL_BRANCH:

--->8---
From a82add2f0562839e60611e7c3f3409d6cea87ad1 Mon Sep 17 00:00:00 2001
From: Piotr Krukowiecki <[email protected]>
Date: Sun, 27 Feb 2011 19:55:48 +0100
Subject: [PATCH] Change how error message is created for easier translation

When a text is split or stiched together from several texts it's very hard/impossible to do a good translation.

---
 builtin/branch.c |   20 ++++++++++++--------
 1 files changed, 12 insertions(+), 8 deletions(-)
builtin/branch.c +12 -8
index fe8f2fc..e4adc34 100644
@@ -149,20 +149,20 @@ static int delete_branches(int argc, const char **argv, int force, int kinds)
 	struct commit *rev, *head_rev = NULL;
 	unsigned char sha1[20];
 	char *name = NULL;
-	const char *fmt, *remote;
+	const char *fmt;
 	int i;
 	int ret = 0;
 	struct strbuf bname = STRBUF_INIT;
+	int is_remote = 0;
 
 	switch (kinds) {
 	case REF_REMOTE_BRANCH:
 		fmt = "refs/remotes/%s";
-		remote = "remote ";
+		is_remote = 1;
 		force = 1;
 		break;
 	case REF_LOCAL_BRANCH:
 		fmt = "refs/heads/%s";
-		remote = "";
 		break;
 	default:
 		die("cannot use -a with -d");
@@ -186,8 +186,9 @@ static int delete_branches(int argc, const char **argv, int force, int kinds)
 
 		name = xstrdup(mkpath(fmt, bname.buf));
 		if (!resolve_ref(name, sha1, 1, NULL)) {
-			error("%sbranch '%s' not found.",
-					remote, bname.buf);
+			const char *error_str = is_remote ? "Remote branch '%s' not found." :
+				"Branch '%s' not found.";
+			error(error_str, bname.buf);
 			ret = 1;
 			continue;
 		}
@@ -208,12 +209,15 @@ static int delete_branches(int argc, const char **argv, int force, int kinds)
 		}
 
 		if (delete_ref(name, sha1, 0)) {
-			error("Error deleting %sbranch '%s'", remote,
-			      bname.buf);
+			const char *error_str = is_remote ? "Error deleting remote branch '%s'" :
+				"Error deleting branch '%s'";
+			error(error_str, bname.buf);
 			ret = 1;
 		} else {
 			struct strbuf buf = STRBUF_INIT;
-			printf("Deleted %sbranch %s (was %s).\n", remote,
+			const char *error_str = is_remote ? "Deleted remote branch %s (was %s).\n" :
+				"Deleted branch %s (was %s).\n";
+			printf(error_str,
 			       bname.buf,
 			       find_unique_abbrev(sha1, DEFAULT_ABBREV));
 			strbuf_addf(&buf, "branch.%s", bname.buf);
Signature · 5 lines
1.7.1


-- 
Piotr Krukowiecki
#146 lore raw

PATCH v4 17/73 gettextize: git-branch "Deleted branch [...]" message

In reply to Junio C Hamano

Gettextize the "Deleted %sbranch %s (was %s).\n" messages. test in t3200-branch.sh explicitly checked for this message. Change it to skip under GETTEXT_POISON=YesPlease.

---
 builtin/branch.c  |    2 +-
 t/t3200-branch.sh |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
builtin/branch.c +1 -1
index e9d8a5a..d276681 100644
@@ -214,7 +214,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds)
 			ret = 1;
 		} else {
 			struct strbuf buf = STRBUF_INIT;
-			printf("Deleted %sbranch %s (was %s).\n", remote,
+			printf(_("Deleted %sbranch %s (was %s).\n"), remote,
 			       bname.buf,
 			       find_unique_abbrev(sha1, DEFAULT_ABBREV));
 			strbuf_addf(&buf, "branch.%s", bname.buf);
t/t3200-branch.sh +1 -1
index f308235..940d7ae 100755
@@ -203,7 +203,7 @@ test_expect_success 'test deleting branch deletes branch config' \
      test -z "$(git config branch.my7.remote)" &&
      test -z "$(git config branch.my7.merge)"'
 
-test_expect_success 'test deleting branch without config' \
+test_expect_success C_LOCALE_OUTPUT 'test deleting branch without config' \
     'git branch my7 s &&
      sha1=$(git rev-parse my7 | cut -c 1-7) &&
      test "$(git branch -d my7 2>&1)" = "Deleted branch my7 (was $sha1)."'
Signature · 1 line
1.7.2.3
#147 lore raw

Re: [PATCH v4 17/73] gettextize: git-branch "Deleted branch [...]" message

builtin/branch.c static int delete_branches(int argc, const char **argv, int force, int kinds) · line 217

Quoted 8 lines · Ævar Arnfjörð Bjarmason
builtin/branch.c +1 -1
@@ -214,7 +214,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds)
 			ret = 1;
 		} else {
 			struct strbuf buf = STRBUF_INIT;
-			printf("Deleted %sbranch %s (was %s).\n", remote,
+			printf(_("Deleted %sbranch %s (was %s).\n"), remote,

This patch might be might easier to read squashed with the previous one (both for the sake of providing context to reviewers and avoiding mixed-language output :)).

#148 lore raw

Re: [PATCH v4 17/73] gettextize: git-branch "Deleted branch [...]" message

Quoted 14 lines · Jonathan Nieder

builtin/branch.c static int delete_branches(int argc, const char **argv, int force, int kinds) · line 217

Quoted 8 lines · Ævar Arnfjörð Bjarmason
builtin/branch.c +1 -1
@@ -214,7 +214,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds)
                       ret = 1;
               } else {
                       struct strbuf buf = STRBUF_INIT;
-                     printf("Deleted %sbranch %s (was %s).\n", remote,
+                     printf(_("Deleted %sbranch %s (was %s).\n"), remote,

This patch might be might easier to read squashed with the previous one (both for the sake of providing context to reviewers and avoiding mixed-language output :)).

I split it up from the rest because I always tried to group translations with the tests they broke, and only the tests they broke and vice versa.

It was often a lot of work figuring out what translation broke what tests. IIRC splitting this all took me around half a day at the time.

So while it's easy to find out what message is the relevant one in this case, this is an attribute of the series I'd really like to keep for future bookkeeping. It's nice to be able to annotate a line in the test suite and see a patch that changes *just* that message and related tests, not a lot of other unrelated messages.

#149 lore raw

Re: [PATCH v4 17/73] gettextize: git-branch "Deleted branch [...]" message

(-cc: Jakub)

Quoted 4 lines · Ævar Arnfjörð Bjarmason

I split it up from the rest because I always tried to group translations with the tests they broke, and only the tests they broke and vice versa.

Quoted 8 lines

It was often a lot of work figuring out what translation broke what tests. IIRC splitting this all took me around half a day at the time.

So while it's easy to find out what message is the relevant one in this case, this is an attribute of the series I'd really like to keep for future bookkeeping. It's nice to be able to annotate a line in the test suite and see a patch that changes *just* that message and related tests, not a lot of other unrelated messages.

Makes sense, and thanks for doing that. It is nice to see the mass of messages for each command that don't produce complications separate from the harder ones.

Cheers,
Jonathan

#150 lore raw

PATCH v4 18/73 gettextize: git-branch "git branch -v" messages

In reply to Junio C Hamano

Make the "git branch -v" messages translatable, e.g.:

5054b57 [ahead 8] branch error fixup

This is possibly a plumbing message.

---
 builtin/branch.c         |    6 +++---
 t/t6040-tracking-info.sh |    2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)
builtin/branch.c +3 -3
index d276681..4c1a256 100644
@@ -373,11 +373,11 @@ static void fill_tracking_info(struct strbuf *stat, const char *branch_name,
 		strbuf_addf(stat, "%s: ",
 			shorten_unambiguous_ref(branch->merge[0]->dst, 0));
 	if (!ours)
-		strbuf_addf(stat, "behind %d] ", theirs);
+		strbuf_addf(stat, _("behind %d] "), theirs);
 	else if (!theirs)
-		strbuf_addf(stat, "ahead %d] ", ours);
+		strbuf_addf(stat, _("ahead %d] "), ours);
 	else
-		strbuf_addf(stat, "ahead %d, behind %d] ", ours, theirs);
+		strbuf_addf(stat, _("ahead %d, behind %d] "), ours, theirs);
 }
 
 static int matches_merge_filter(struct commit *commit)
t/t6040-tracking-info.sh +1 -1
index 1e0447f..6cad643 100755
@@ -42,7 +42,7 @@ b3 behind 1
 b4 ahead 2
 EOF
 
-test_expect_success 'branch -v' '
+test_expect_success C_LOCALE_OUTPUT 'branch -v' '
 	(
 		cd test &&
 		git branch -v
Signature · 1 line
1.7.2.3
#151 lore raw

Re: [PATCH v4 18/73] gettextize: git-branch "git branch -v" messages

Quoted 1 line · Ævar Arnfjörð Bjarmason

This is possibly a plumbing message.

Luckily it is not one.

Everything up to here looks good still.