Skip to contentSkip to conversation

Add gettext support to Git

PATCH New Ævar Arnfjörð Bjarmason 3 participants 39 messages Jun 15, 2016 Kbuild

lore
Share & tools
lore
#0 lore raw

cover Add gettext support to Git

The previous nested pull requests were a mess, and I needed to fix some bugs. So here's a total re-do of the ab/i18n series. Everything that's already in pu from ab/i18n can be ejected in favor of this.

Most of these 63 patches have been seen here before. So I'll only be sending the stuff that's changed or interesting along with this series. To get the full thing go to:

    git://github.com/avar/git.git ab/i18n-all
    http://github.com/avar/git/compare/master...ab/i18n-all
    http://github.com/avar/git/compare/master...ab/i18n-all.patch

The last of which is a patch file suitable for git-am(1).

Since last time I've rebased this on the new upstream master branch, which now has my ab/test-2 series.

See comments by the patches below for other changes in this series since last time.

Jan Krüger (1):
po/de.po: add German translation

Marcin Cieślak (1):
po/pl.po: add Polish translation

Sam Reed (1):
po/en_GB.po: add British English Translation

I minimized this so it now only contains 3 msgid/msgstr pairs, instead of containing *all* of them just to translate those three.

As an aside I really need to patch the upstream gettext tools to make this easy. I have to manually edit the file now to do this.

Thomas Rast (1):
tests: locate i18n lib&data correctly under --valgrind

The 2e75a8c that's in pu right now solves the merge conflict between ab/i18n and ab/test incorrectly. Since ab/test has been merged this needs no changes to test-lib.sh at all (GIT_BUILD_DIR is now already defined there).

Ævar Arnfjörð Bjarmason (59):
builtin: use builtin.h for all builtin commands

These changes for builtin.h are now part of this series for convenience. But Junio might want to split them up away from the ab/i18n topic.

Add infrastructure for translating Git with gettext

Updated to solve merge conflicts with the new master. No other changes.

tests: rename test to work around GNU gettext bug
gettext: setlocale(LC_CTYPE, "") breaks Git's C function assumptions
Makefile: A variable for options used by xgettext(1) calls
Makefile: provide a --msgid-bugs-address to xgettext(1)
Makefile: tell xgettext(1) that our source is in UTF-8
Makefile: use variables and shorter lines for xgettext builtin.h: Include gettext.h
gettext: make the simple parts of git-init localizable
gettext: localize the main git-init message
gettext.c: work around us not using setlocale(LC_CTYPE, "") gettext tests: test if $VERSION exists before using it gettext tests: update test/is.po to match t/t0200/test.c gettext tests: add detection for is_IS.ISO-8859-1 locale gettext tests: test message re-encoding under Shell gettext tests: test re-encoding with a UTF-8 msgid under Shell gettext tests: mark a test message as not needing translation

po/is.po: msgmerge and add Language: header
po/is.po: add Icelandic translation

I've rewritten these and all other changes to po/*.po files to not have the autogenerated line numbers. So with this new topic these *never* apprear in the po/*.po history.

gettext tests: test message re-encoding under C gettext tests: remove old sanity test under NO_GETTEXT gettext docs: add po/README file documenting Git's gettext gettext tests: add GETTEXT_POISON=YesPlease Makefile parameter

gettext tests: skip lib-gettext.sh tests under GETTEXT_POISON

Split up from the below. Easier to review this way.

gettext tests: skip breaking tests under GETTEXT_POISON

Ejected changes to t7602-merge-octopus-many.sh from this. Those tests tested for a plumbing message (see below)

This is still the part of this series that needs the most review. I *think* I got this right, but more eyes are needed on it.

gettextize: git-clone basic messages
gettextize: git-clone "Cloning into" message
gettextize: git-add basic messages
gettextize: git-add refresh_index message
gettextize: git-branch basic messages
gettextize: git-branch "remote branch '%s' not found" message
gettextize: git-branch "git branch -v" messages
gettextize: git-branch "(no branch)" message
gettextize: git-checkout: our/their version message
gettextize: git-checkout basic messages
gettextize: git-checkout describe_detached_head messages
gettextize: git-checkout "Switched to a .. branch" message
gettextize: git-commit basic messages
gettextize: git-commit formatting messages
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-log basic messages
gettextize: git-merge basic messages

The finish() command ends up writing to the reflog, not only to stdout. So I needed drop all these patches:

gettextize: git-merge remaining cmd_merge messages
gettextize: git-merge "Merge made by %s." message
gettextize: git-merge "In-index merge" message

Now git-merge only makes the basic output/die messages translatable.

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-tag basic messages
gettextize: git-tag tag_template message
gettextize: git-push basic messages
gettextize: git-status basic messages
gettextize: git-status shortstatus messages

 .gitignore                          |    2 +
 INSTALL                             |   12 +
 Makefile                            |   92 ++-
 builtin.h                           |    1 +
 builtin/add.c                       |   46 +-
 builtin/branch.c                    |   69 +-
 builtin/checkout.c                  |   93 +-
 builtin/clone.c                     |   61 +-
 builtin/commit.c                    |  156 ++--
 builtin/diff.c                      |   20 +-
 builtin/fetch-pack.c                |    2 +-
 builtin/fetch.c                     |   82 +-
 builtin/grep.c                      |   34 +-
 builtin/hash-object.c               |    2 +-
 builtin/index-pack.c                |    2 +-
 builtin/init-db.c                   |   56 +-
 builtin/log.c                       |   68 +-
 builtin/merge-index.c               |    2 +-
 builtin/merge-recursive.c           |    2 +-
 builtin/merge-tree.c                |    2 +-
 builtin/merge.c                     |  122 ++--
 builtin/mktag.c                     |    2 +-
 builtin/mv.c                        |   32 +-
 builtin/pack-redundant.c            |    2 +-
 builtin/pack-refs.c                 |    2 +-
 builtin/patch-id.c                  |    2 +-
 builtin/push.c                      |   42 +-
 builtin/receive-pack.c              |    2 +-
 builtin/remote.c                    |    3 +-
 builtin/reset.c                     |   44 +-
 builtin/rm.c                        |   22 +-
 builtin/send-pack.c                 |    2 +-
 builtin/tag.c                       |   66 +-
 builtin/unpack-file.c               |    2 +-
 builtin/var.c                       |    2 +-
 config.mak.in                       |    2 +
 configure.ac                        |   12 +
 daemon.c                            |    3 +
 fast-import.c                       |    3 +
 gettext.c                           |   27 +
 gettext.h                           |   22 +
 git-sh-i18n.sh                      |   71 ++
 git.c                               |    3 +
 http-backend.c                      |    3 +
 http-fetch.c                        |    3 +
 http-push.c                         |    3 +
 imap-send.c                         |    3 +
 perl/Git/I18N.pm                    |   91 ++
 perl/Makefile                       |    3 +-
 perl/Makefile.PL                    |   14 +-
 po/.gitignore                       |    1 +
 po/README                           |   68 ++
 po/de.po                            | 1888 +++++++++++++++++++++++++++++++++++
 po/en_GB.po                         |   22 +
 po/is.po                            |  152 +++
 po/pl.po                            |  153 +++
 shell.c                             |    3 +
 show-index.c                        |    3 +
 t/lib-gettext.sh                    |   68 ++
 t/lib-httpd.sh                      |    2 +-
 t/t0001-init.sh                     |    2 +-
 t/t0200-gettext-basic.sh            |  108 ++
 t/t0200/test.c                      |   23 +
 t/t0200/test.perl                   |   14 +
 t/t0200/test.sh                     |   14 +
 t/t0201-gettext-fallbacks.sh        |   49 +
 t/t0202-gettext-perl.sh             |   27 +
 t/t0202/test.pl                     |  109 ++
 t/t0203-gettext-setlocale-sanity.sh |   26 +
 t/t0204-gettext-reencode-sanity.sh  |   78 ++
 t/t1200-tutorial.sh                 |    4 +-
 t/t2200-add-update.sh               |    2 +-
 t/t2204-add-ignored.sh              |    8 +-
 t/t3030-merge-recursive.sh          |    2 +-
 t/t3200-branch.sh                   |    2 +-
 t/t3203-branch-output.sh            |    2 +-
 t/t3700-add.sh                      |    4 +-
 t/t4001-diff-rename.sh              |    4 +-
 t/t4014-format-patch.sh             |    2 +-
 t/t5541-http-push.sh                |    2 +-
 t/t5601-clone.sh                    |    2 +-
 t/t6040-tracking-info.sh            |    2 +-
 t/t7004-tag.sh                      |    6 +-
 t/t7060-wtstatus.sh                 |    2 +-
 t/t7102-reset.sh                    |    2 +-
 t/t7110-reset-merge.sh              |    6 +-
 t/t7201-co.sh                       |   10 +-
 t/t7500-commit.sh                   |    9 +-
 t/t7501-commit.sh                   |   14 +-
 t/t7502-commit.sh                   |   46 +-
 t/t7506-status-submodule.sh         |   28 +-
 t/t7508-status.sh                   |   98 +-
 t/t7600-merge.sh                    |    2 +-
 t/t7811-grep-open.sh                |    2 +-
 t/test-lib.sh                       |    3 +
 upload-pack.c                       |    3 +
 wt-status.c                         |  116 ++--
 97 files changed, 3901 insertions(+), 706 deletions(-)
 create mode 100644 gettext.c
 create mode 100644 gettext.h
 create mode 100644 git-sh-i18n.sh
 create mode 100644 perl/Git/I18N.pm
 create mode 100644 po/.gitignore
 create mode 100644 po/README
 create mode 100644 po/de.po
 create mode 100644 po/en_GB.po
 create mode 100644 po/is.po
 create mode 100644 po/pl.po
 create mode 100644 t/lib-gettext.sh
 create mode 100755 t/t0200-gettext-basic.sh
 create mode 100644 t/t0200/test.c
 create mode 100644 t/t0200/test.perl
 create mode 100644 t/t0200/test.sh
 create mode 100755 t/t0201-gettext-fallbacks.sh
 create mode 100755 t/t0202-gettext-perl.sh
 create mode 100644 t/t0202/test.pl
 create mode 100755 t/t0203-gettext-setlocale-sanity.sh
 create mode 100755 t/t0204-gettext-reencode-sanity.sh
Signature · 1 line
1.7.2.3.313.gcd15
#1 lore raw

PATCH 1/63 builtin: use builtin.h for all builtin commands

Change the builtin/*.c files and wt-status.c files which weren't using builtin.h to use it, also remove any git-compat-util.h, strbuf.h and cache.h from those files. We can trust on builtin.h including them.

builtin.h also includes commit.h and notes.h. But I haven't removed these includes. They're redundant now, but we may want to remove them from builtin.h in the future.

This impeded my efforts to gettextize git, since I'd otherwise have to add gettext.h to all of these. Using builtin.h is a good idea in any case, since it's defining the prototypes for the cmd_* functions that these files define.

---
 builtin/clone.c           |    3 +--
 builtin/fetch-pack.c      |    2 +-
 builtin/hash-object.c     |    2 +-
 builtin/index-pack.c      |    2 +-
 builtin/merge-index.c     |    2 +-
 builtin/merge-recursive.c |    2 +-
 builtin/merge-tree.c      |    2 +-
 builtin/mktag.c           |    2 +-
 builtin/pack-redundant.c  |    2 +-
 builtin/pack-refs.c       |    2 +-
 builtin/patch-id.c        |    2 +-
 builtin/receive-pack.c    |    2 +-
 builtin/remote.c          |    3 +--
 builtin/reset.c           |    2 +-
 builtin/send-pack.c       |    2 +-
 builtin/unpack-file.c     |    2 +-
 builtin/var.c             |    2 +-
 wt-status.c               |    2 +-
 18 files changed, 18 insertions(+), 20 deletions(-)
builtin/clone.c +1 -2
index 19ed640..994d527 100644
@@ -8,7 +8,7 @@
  * Clone a repository into a different directory that does not yet exist.
  */
 
-#include "cache.h"
+#include "builtin.h"
 #include "parse-options.h"
 #include "fetch-pack.h"
 #include "refs.h"
@@ -16,7 +16,6 @@
 #include "tree-walk.h"
 #include "unpack-trees.h"
 #include "transport.h"
-#include "strbuf.h"
 #include "dir.h"
 #include "pack-refs.h"
 #include "sigchain.h"
builtin/fetch-pack.c +1 -1
index dbd8b7b..fd70b4c 100644
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "builtin.h"
 #include "refs.h"
 #include "pkt-line.h"
 #include "commit.h"
builtin/hash-object.c +1 -1
index 080af1a..8a5670f 100644
@@ -4,7 +4,7 @@
  * Copyright (C) Linus Torvalds, 2005
  * Copyright (C) Junio C Hamano, 2005
  */
-#include "cache.h"
+#include "builtin.h"
 #include "blob.h"
 #include "quote.h"
 #include "parse-options.h"
builtin/index-pack.c +1 -1
index 2e680d7..9c5c9d6 100644
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "builtin.h"
 #include "delta.h"
 #include "pack.h"
 #include "csum-file.h"
builtin/merge-index.c +1 -1
index 2c4cf5e..adc2a6d 100644
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "builtin.h"
 #include "run-command.h"
 #include "exec_cmd.h"
 
builtin/merge-recursive.c +1 -1
index 78b9db7..ad2d77d 100644
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "builtin.h"
 #include "commit.h"
 #include "tag.h"
 #include "merge-recursive.h"
builtin/merge-tree.c +1 -1
index 9b25ddc..1991742 100644
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "builtin.h"
 #include "tree-walk.h"
 #include "xdiff-interface.h"
 #include "blob.h"
builtin/mktag.c +1 -1
index 1cb0f3f..9148cc0 100644
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "builtin.h"
 #include "tag.h"
 #include "exec_cmd.h"
 
builtin/pack-redundant.c +1 -1
index 41e1615..a15e366 100644
@@ -6,7 +6,7 @@
 *
 */
 
-#include "cache.h"
+#include "builtin.h"
 #include "exec_cmd.h"
 
 #define BLKSIZE 512
builtin/pack-refs.c +1 -1
index 091860b..39a9d89 100644
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "builtin.h"
 #include "parse-options.h"
 #include "pack-refs.h"
 
builtin/patch-id.c +1 -1
index 5125300..33e9725 100644
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "builtin.h"
 #include "exec_cmd.h"
 
 static void flush_current_id(int patchlen, unsigned char *id, git_SHA_CTX *c)
builtin/receive-pack.c +1 -1
index 760817d..f64b79c 100644
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "builtin.h"
 #include "pack.h"
 #include "refs.h"
 #include "pkt-line.h"
builtin/remote.c +1 -2
index 48e0a6b..3cf3c6b 100644
@@ -1,9 +1,8 @@
-#include "cache.h"
+#include "builtin.h"
 #include "parse-options.h"
 #include "transport.h"
 #include "remote.h"
 #include "string-list.h"
-#include "strbuf.h"
 #include "run-command.h"
 #include "refs.h"
 
builtin/reset.c +1 -1
index 0037be4..c198b8e 100644
@@ -7,7 +7,7 @@
  *
  * Copyright (c) 2005, 2006 Linus Torvalds and Junio C Hamano
  */
-#include "cache.h"
+#include "builtin.h"
 #include "tag.h"
 #include "object.h"
 #include "commit.h"
builtin/send-pack.c +1 -1
index 481602d..a55a517 100644
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "builtin.h"
 #include "commit.h"
 #include "refs.h"
 #include "pkt-line.h"
builtin/unpack-file.c +1 -1
index 608590a..c905d80 100644
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "builtin.h"
 #include "blob.h"
 #include "exec_cmd.h"
 
builtin/var.c +1 -1
index 0744bb8..1787771 100644
@@ -3,7 +3,7 @@
  *
  * Copyright (C) Eric Biederman, 2005
  */
-#include "cache.h"
+#include "builtin.h"
 #include "exec_cmd.h"
 
 static const char var_usage[] = "git var (-l | <variable>)";
wt-status.c +1 -1
index 54b6b03..b05c6db 100644
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "builtin.h"
 #include "wt-status.h"
 #include "object.h"
 #include "dir.h"
Signature · 1 line
1.7.2.3.313.gcd15
#2 lore raw

PATCH 2/63 Add infrastructure for translating Git with gettext

In reply to Ævar Arnfjörð Bjarmason

All of the interface messages in Git core are currently hardcoded in English. Change that by optionally enabling translation of the core C, Shell and Perl programs via GNU or SunOS gettext. If you set the appropriate LC_* variables Git will speak your language, provided that someone has submitted a translation.

If gettext isn't available, or if Git is compiled with NO_GETTEXT=YesPlease, then Git fall back on its previous behavior of only speaking English. When using ./configure the autoconf script will auto-detect if the gettext libraries are installed and act appropriately.

With NO_GETTEXT=YesPlease gettext support will be #defined away for C programs. For Shell and Perl programs we rely on the git message catalog not being available. That's a reasonable assumption since then the message catalog won't be installed on the system during make install.

The gettext wrappers that are provided in the patch are only the bare minimum required to begin translation work. In particular I haven't added wrappers for the gettext functions that enable plural support, or those that provide message context (msgctxt).

Those can be added later. The intent is to start with a small subset and see what we need later, not to start with something that's unnecessarily large right away.

Implementation and usage notes:

* General:

Gettext .mo files will be installed and looked for in the standard $(prefix)/share/locale path. GIT_TEXTDOMAINDIR can also be set to override that, but that's only intended to be used to test Git itself.

* Perl:

Perl code that wants to be localized should use the new Git::I18n module. It imports a __ function into the caller's package by default.

Instead of using the high level Locale::TextDomain interface I've opted to use the low-level (equivalent to the C interface) Locale::Messages module, which Locale::TextDomain itself uses.

Locale::TextDomain does a lot of redundant work we don't need, and some of it would potentially introduce bugs. It tries to set the $TEXTDOMAIN based on package of the caller, and has its own hardcoded paths where it'll search for messages.

I found it easier just to completely avoid it rather than try to circumvent its behavior. In any case, this is an issue wholly internal Git::I18N. Its guts can be changed later if that's deemed necessary.

See <[email protected]> for a further elaboration on this topic.

* Shell:

Shell code that's to be localized should use the new git-sh-i18n library. It's just a wrapper for the system's gettext.sh.

If gettext.sh isn't available we'll fall back gettext(1) if it's available. The latter is available without the former on Solaris, which has its own non-GNU gettext implementation. We also need to emulate eval_gettext() there.

If neither are present we'll use a dumb printf(1) fall-through wrapper.

I originally tried to detect if the system supported `echo -n' but I found this to be a waste of time. My benchmarks on Linux, Solaris and FreeBSD reveal that printf(1) is fast enough, especially since we aren't calling gettext() from within any tight loops, and unlikely to ever do so.

This series has been tested by me on Ubuntu 10.04, Debian testing, FreeBSD 8.1 and SunOS 5.10, and by others on Mac OS X 10.6.3 (with Xcode 3.2.2) and openSUSE Factory (11.3, milestone 7).

SunOS has its own non-GNU gettext implementation which this patch supports, although that may change in the future if it turns out that we need some GNU libintl features that SunOS doesn't provide.

This patch is based on work by Jeff Epler <[email protected]> who did the initial Makefile / C work, and a lot of comments from the Git mailing list, including Jonathan Nieder, Jakub Narebski, Johannes Sixt, Peter Krefting, Junio C Hamano, Thomas Rast and others.

---
 .gitignore                   |    2 +
 INSTALL                      |   12 +++++
 Makefile                     |   69 +++++++++++++++++++++++++-
 config.mak.in                |    2 +
 configure.ac                 |   12 +++++
 daemon.c                     |    3 +
 fast-import.c                |    3 +
 gettext.c                    |   22 ++++++++
 gettext.h                    |   18 +++++++
 git-sh-i18n.sh               |   71 ++++++++++++++++++++++++++
 git.c                        |    3 +
 http-backend.c               |    3 +
 http-fetch.c                 |    3 +
 http-push.c                  |    3 +
 imap-send.c                  |    3 +
 perl/Git/I18N.pm             |   91 +++++++++++++++++++++++++++++++++
 perl/Makefile                |    3 +-
 perl/Makefile.PL             |   14 +++++-
 po/.gitignore                |    1 +
 po/is.po                     |   40 +++++++++++++++
 shell.c                      |    3 +
 show-index.c                 |    3 +
 t/lib-gettext.sh             |   42 ++++++++++++++++
 t/t0200-gettext.sh           |  113 ++++++++++++++++++++++++++++++++++++++++++
 t/t0200/test.c               |   13 +++++
 t/t0200/test.perl            |   14 +++++
 t/t0200/test.sh              |   14 +++++
 t/t0201-gettext-fallbacks.sh |   49 ++++++++++++++++++
 t/t0202-gettext-perl.sh      |   27 ++++++++++
 t/t0202/test.pl              |  107 +++++++++++++++++++++++++++++++++++++++
 t/test-lib.sh                |    2 +
 upload-pack.c                |    3 +
 32 files changed, 764 insertions(+), 4 deletions(-)
 create mode 100644 gettext.c
 create mode 100644 gettext.h
 create mode 100644 git-sh-i18n.sh
 create mode 100644 perl/Git/I18N.pm
 create mode 100644 po/.gitignore
 create mode 100644 po/is.po
 create mode 100644 t/lib-gettext.sh
 create mode 100755 t/t0200-gettext.sh
 create mode 100644 t/t0200/test.c
 create mode 100644 t/t0200/test.perl
 create mode 100644 t/t0200/test.sh
 create mode 100755 t/t0201-gettext-fallbacks.sh
 create mode 100755 t/t0202-gettext-perl.sh
 create mode 100644 t/t0202/test.pl
.gitignore +2 -0
index 20560b8..80ca718 100644
@@ -125,6 +125,7 @@
 /git-rm
 /git-send-email
 /git-send-pack
+/git-sh-i18n
 /git-sh-setup
 /git-shell
 /git-shortlog
@@ -215,3 +216,4 @@
 *.pdb
 /Debug/
 /Release/
+/share/
INSTALL +12 -0
index 59200b7..e4e7506 100644
@@ -93,6 +93,18 @@ Issues of note:
 	  history graphically, and in git-gui.  If you don't want gitk or
 	  git-gui, you can use NO_TCLTK.
 
+	- A gettext library is used by default for localizing Git. The
+	  primary target is GNU libintl, but the Solaris gettext
+	  implementation also works.
+
+	  We need a gettext.h on the system for C code, gettext.sh (or
+	  Solaris gettext(1)) for shell scripts, and libintl-perl for Perl
+	  programs.
+
+	  Set NO_GETTEXT to disable localization support and make Git only
+	  use English. Under autoconf the configure script will do this
+	  automatically if it can't find libintl on the system.
+
  - Some platform specific issues are dealt with Makefile rules,
    but depending on your specific installation, you may not
    have all the libraries/tools needed, or you may have
Makefile +67 -2

189 lines not on this page · raw message

config.mak.in +2 -0
index a0c34ee..9f47aa5 100644
@@ -34,9 +34,11 @@ NO_CURL=@NO_CURL@
 NO_EXPAT=@NO_EXPAT@
 NO_LIBGEN_H=@NO_LIBGEN_H@
 HAVE_PATHS_H=@HAVE_PATHS_H@
+NO_GETTEXT=@NO_GETTEXT@
 NEEDS_LIBICONV=@NEEDS_LIBICONV@
 NEEDS_SOCKET=@NEEDS_SOCKET@
 NEEDS_RESOLV=@NEEDS_RESOLV@
+NEEDS_LIBINTL=@NEEDS_LIBINTL@
 NEEDS_LIBGEN=@NEEDS_LIBGEN@
 NO_SYS_SELECT_H=@NO_SYS_SELECT_H@
 NO_D_INO_IN_DIRENT=@NO_D_INO_IN_DIRENT@
configure.ac +12 -0
index 56731c3..1821d89 100644
@@ -600,6 +600,12 @@ AC_CHECK_LIB([c], [basename],
 AC_SUBST(NEEDS_LIBGEN)
 test -n "$NEEDS_LIBGEN" && LIBS="$LIBS -lgen"
 
+AC_CHECK_LIB([c], [gettext],
+[NEEDS_LIBINTL=],
+[NEEDS_LIBINTL=YesPlease])
+AC_SUBST(NEEDS_LIBINTL)
+test -n "$NEEDS_LIBINTL" && LIBS="$LIBS -lintl"
+
 ## Checks for header files.
 AC_MSG_NOTICE([CHECKS for header files])
 #
@@ -798,6 +804,12 @@ AC_CHECK_HEADER([paths.h],
 [HAVE_PATHS_H=])
 AC_SUBST(HAVE_PATHS_H)
 #
+# Define NO_GETTEXT if you don't have libintl.h
+AC_CHECK_HEADER([libintl.h],
+[NO_GETTEXT=],
+[NO_GETTEXT=YesPlease])
+AC_SUBST(NO_GETTEXT)
+#
 # Define NO_STRCASESTR if you don't have strcasestr.
 GIT_CHECK_FUNC(strcasestr,
 [NO_STRCASESTR=],
daemon.c +3 -0
index e22a2b7..784f897 100644
@@ -3,6 +3,7 @@
 #include "exec_cmd.h"
 #include "run-command.h"
 #include "strbuf.h"
+#include "gettext.h"
 
 #include <syslog.h>
 
@@ -975,6 +976,8 @@ int main(int argc, char **argv)
 	gid_t gid = 0;
 	int i;
 
+	git_setup_gettext();
+
 	git_extract_argv0_path(argv[0]);
 
 	for (i = 1; i < argc; i++) {
fast-import.c +3 -0
index 2317b0f..7fb2a86 100644
@@ -156,6 +156,7 @@ Format of STDIN stream:
 #include "csum-file.h"
 #include "quote.h"
 #include "exec_cmd.h"
+#include "gettext.h"
 
 #define PACK_ID_BITS 16
 #define MAX_PACK_ID ((1<<PACK_ID_BITS)-1)
@@ -2918,6 +2919,8 @@ int main(int argc, const char **argv)
 
 	git_extract_argv0_path(argv[0]);
 
+	git_setup_gettext();
+
 	if (argc == 2 && !strcmp(argv[1], "-h"))
 		usage(fast_import_usage);
 
gettext.c new file +22 -0
new file mode 100644
index 0000000..7ae5cae
@@ -0,0 +1,22 @@
+#include "exec_cmd.h"
+#include <locale.h>
+#include <libintl.h>
+#include <stdlib.h>
+
+extern void git_setup_gettext(void) {
+	char *podir;
+	char *envdir = getenv("GIT_TEXTDOMAINDIR");
+
+	if (envdir) {
+		(void)bindtextdomain("git", envdir);
+	} else {
+		podir = (char *)system_path("share/locale");
+		if (!podir) return;
+		(void)bindtextdomain("git", podir);
+		free(podir);
+	}
+
+	(void)setlocale(LC_MESSAGES, "");
+	(void)setlocale(LC_CTYPE, "");
+	(void)textdomain("git");
+}
gettext.h new file +18 -0
new file mode 100644
index 0000000..e02939a
@@ -0,0 +1,18 @@
+#ifndef GETTEXT_H
+#define GETTEXT_H
+
+#ifdef NO_GETTEXT
+static inline void git_setup_gettext(void) {}
+#else
+extern void git_setup_gettext(void);
+#endif
+
+#define N_(s) (s)
+#ifdef NO_GETTEXT
+#define _(s) (s)
+#else
+#include <libintl.h>
+#define _(s) gettext(s)
+#endif
+
+#endif
git-sh-i18n.sh new file +71 -0

71 lines not on this page · raw message

git.c +3 -0
index 8de4810..f154852 100644
@@ -3,6 +3,7 @@
 #include "cache.h"
 #include "quote.h"
 #include "run-command.h"
+#include "gettext.h"
 
 const char git_usage_string[] =
 	"git [--version] [--exec-path[=GIT_EXEC_PATH]] [--html-path]\n"
@@ -502,6 +503,8 @@ int main(int argc, const char **argv)
 	if (!cmd)
 		cmd = "git-help";
 
+	git_setup_gettext();
+
 	/*
 	 * "git-xxxx" is the same as "git xxxx", but we obviously:
 	 *
http-backend.c +3 -0
index 14c90c2..502103d 100644
@@ -7,6 +7,7 @@
 #include "run-command.h"
 #include "string-list.h"
 #include "url.h"
+#include "gettext.h"
 
 static const char content_type[] = "Content-Type";
 static const char content_length[] = "Content-Length";
@@ -550,6 +551,8 @@ int main(int argc, char **argv)
 	char *cmd_arg = NULL;
 	int i;
 
+	git_setup_gettext();
+
 	git_extract_argv0_path(argv[0]);
 	set_die_routine(die_webcgi);
 
http-fetch.c +3 -0
index 762c750..b889c36 100644
@@ -2,6 +2,7 @@
 #include "exec_cmd.h"
 #include "http.h"
 #include "walker.h"
+#include "gettext.h"
 
 static const char http_fetch_usage[] = "git http-fetch "
 "[-c] [-t] [-a] [-v] [--recover] [-w ref] [--stdin] commit-id url";
@@ -24,6 +25,8 @@ int main(int argc, const char **argv)
 	int get_verbosely = 0;
 	int get_recover = 0;
 
+	git_setup_gettext();
+
 	git_extract_argv0_path(argv[0]);
 
 	while (arg < argc && argv[arg][0] == '-') {
http-push.c +3 -0
index c9bcd11..fc2c5f7 100644
@@ -10,6 +10,7 @@
 #include "remote.h"
 #include "list-objects.h"
 #include "sigchain.h"
+#include "gettext.h"
 
 #include <expat.h>
 
@@ -1791,6 +1792,8 @@ int main(int argc, char **argv)
 	struct remote *remote;
 	char *rewritten_url = NULL;
 
+	git_setup_gettext();
+
 	git_extract_argv0_path(argv[0]);
 
 	repo = xcalloc(sizeof(*repo), 1);
imap-send.c +3 -0
index 71506a8..c9dc7ec 100644
@@ -25,6 +25,7 @@
 #include "cache.h"
 #include "exec_cmd.h"
 #include "run-command.h"
+#include "gettext.h"
 #ifdef NO_OPENSSL
 typedef void *SSL;
 #else
@@ -1539,6 +1540,8 @@ int main(int argc, char **argv)
 
 	git_extract_argv0_path(argv[0]);
 
+	git_setup_gettext();
+
 	if (argc != 1)
 		usage(imap_send_usage);
 
perl/Git/I18N.pm new file +91 -0

91 lines not on this page · raw message

perl/Makefile +2 -1
index a2ffb64..b2977cd 100644
@@ -5,6 +5,7 @@ makfile:=perl.mak
 
 PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
 prefix_SQ = $(subst ','\'',$(prefix))
+localedir_SQ = $(subst ','\'',$(localedir))
 
 ifndef V
 	QUIET = @
@@ -38,7 +39,7 @@ $(makfile): ../GIT-CFLAGS Makefile
 	echo '	echo $(instdir_SQ)' >> $@
 else
 $(makfile): Makefile.PL ../GIT-CFLAGS
-	$(PERL_PATH) $< PREFIX='$(prefix_SQ)' INSTALL_BASE=''
+	$(PERL_PATH) $< PREFIX='$(prefix_SQ)' INSTALL_BASE='' --localedir='$(localedir_SQ)'
 endif
 
 # this is just added comfort for calling make directly in perl dir
perl/Makefile.PL +13 -1
index 0b9deca..456d45b 100644
@@ -1,4 +1,12 @@
+use strict;
+use warnings;
 use ExtUtils::MakeMaker;
+use Getopt::Long;
+
+# Sanity: die at first unknown option
+Getopt::Long::Configure qw/ pass_through /;
+
+GetOptions("localedir=s" => \my $localedir);
 
 sub MY::postamble {
 	return <<'MAKE_FRAG';
@@ -16,7 +24,10 @@ endif
 MAKE_FRAG
 }
 
-my %pm = ('Git.pm' => '$(INST_LIBDIR)/Git.pm');
+my %pm = (
+	'Git.pm' => '$(INST_LIBDIR)/Git.pm',
+	'Git/I18N.pm' => '$(INST_LIBDIR)/Git/I18N.pm',
+);
 
 # We come with our own bundled Error.pm. It's not in the set of default
 # Perl modules so install it if it's not available on the system yet.
@@ -33,6 +44,7 @@ WriteMakefile(
 	NAME            => 'Git',
 	VERSION_FROM    => 'Git.pm',
 	PM		=> \%pm,
+	PM_FILTER	=> qq[\$(PERL) -pe "s<\\Q++LOCALEDIR++\\E><$localedir>"],
 	MAKEFILE	=> 'perl.mak',
 	INSTALLSITEMAN3DIR => '$(SITEPREFIX)/share/man/man3'
 );
po/.gitignore new file +1 -0
new file mode 100644
index 0000000..221000e
@@ -0,0 +1 @@
+/*.pot
po/is.po new file +40 -0
new file mode 100644
index 0000000..03ca199
@@ -0,0 +1,40 @@
+msgid ""
+msgstr ""
+"Project-Id-Version: Git\n"
+"PO-Revision-Date: 2010-06-05 19:06 +0000\n"
+"Language-Team: Git Mailing List <[email protected]>\n"
+"Report-Msgid-Bugs-To: Git Mailing List <[email protected]>\n"
+"Last-Translator: Ævar Arnfjörð Bjarmason <[email protected]>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+msgid "See git help COMMAND for more information on a specific command."
+msgstr "Sjá git help SKIPUN til að sjá hjálp fyrir tiltekna skipun."
+
+#. TRANSLATORS: This is a test. You don't need to translate it.
+msgid "TEST: A C test string"
+msgstr "TILRAUN: C tilraunastrengur"
+
+#. TRANSLATORS: This is a test. You don't need to translate it.
+#, c-format
+msgid "TEST: A C test string %s"
+msgstr "TILRAUN: C tilraunastrengur %s"
+
+#. TRANSLATORS: This is a test. You don't need to translate it.
+msgid "TEST: A Shell test string"
+msgstr "TILRAUN: Skeljartilraunastrengur"
+
+#. TRANSLATORS: This is a test. You don't need to translate it.
+#, sh-format
+msgid "TEST: A Shell test $variable"
+msgstr "TILRAUN: Skeljartilraunastrengur með breytunni $variable"
+
+#. TRANSLATORS: This is a test. You don't need to translate it.
+msgid "TEST: A Perl test string"
+msgstr "TILRAUN: Perl tilraunastrengur"
+
+#. TRANSLATORS: This is a test. You don't need to translate it.
+#, perl-format
+msgid "TEST: A Perl test variable %s"
+msgstr "TILRAUN: Perl tilraunastrengur með breytunni %s"
shell.c +3 -0
index e4864e0..ba27c6b 100644
@@ -2,6 +2,7 @@
 #include "quote.h"
 #include "exec_cmd.h"
 #include "strbuf.h"
+#include "gettext.h"
 
 static int do_generic_cmd(const char *me, char *arg)
 {
@@ -51,6 +52,8 @@ int main(int argc, char **argv)
 	struct commands *cmd;
 	int devnull_fd;
 
+	git_setup_gettext();
+
 	/*
 	 * Always open file descriptors 0/1/2 to avoid clobbering files
 	 * in die().  It also avoids not messing up when the pipes are
show-index.c +3 -0
index 4c0ac13..c2f5448 100644
@@ -1,5 +1,6 @@
 #include "cache.h"
 #include "pack.h"
+#include "gettext.h"
 
 static const char show_index_usage[] =
 "git show-index < <packed archive index>";
@@ -11,6 +12,8 @@ int main(int argc, char **argv)
 	unsigned int version;
 	static unsigned int top_index[256];
 
+	git_setup_gettext();
+
 	if (argc != 1)
 		usage(show_index_usage);
 	if (fread(top_index, 2 * 4, 1, stdin) != 1)
t/lib-gettext.sh new file +42 -0

42 lines not on this page · raw message

t/t0200-gettext.sh new file +113 -0

113 lines not on this page · raw message

t/t0200/test.c new file +13 -0
new file mode 100644
index 0000000..93373b3
@@ -0,0 +1,13 @@
+/* This is a phony C program that's only here to test xgettext message extraction */
+
+const char help[] =
+	N_("See 'git help COMMAND' for more information on a specific command.");
+
+int main(void)
+{
+	/* TRANSLATORS: This is a test. You don't need to translate it. */
+	puts(_("TEST: A C test string"));
+
+	/* TRANSLATORS: This is a test. You don't need to translate it. */
+	printf(_("TEST: A C test string %s"), "variable");
+}
t/t0200/test.perl new file +14 -0
new file mode 100644
index 0000000..36fba34
@@ -0,0 +1,14 @@
+# This is a phony Perl program that's only here to test xgettext
+# message extraction
+
+# so the above comment won't be folded into the next one by xgettext
+1;
+
+# TRANSLATORS: This is a test. You don't need to translate it.
+print __("TEST: A Perl test string");
+
+# TRANSLATORS: This is a test. You don't need to translate it.
+printf __("TEST: A Perl test variable %s"), "moo";
+
+# TRANSLATORS: If you see this, Git has a bug
+print _"TEST: A Perl string xgettext will not get";
t/t0200/test.sh new file +14 -0
new file mode 100644
index 0000000..022d607
@@ -0,0 +1,14 @@
+# This is a phony Shell program that's only here to test xgettext
+# message extraction
+
+# so the above comment won't be folded into the next one by xgettext
+echo
+
+# TRANSLATORS: This is a test. You don't need to translate it.
+gettext "TEST: A Shell test string"
+
+# TRANSLATORS: This is a test. You don't need to translate it.
+eval_gettext "TEST: A Shell test \$variable"
+
+# TRANSLATORS: If you see this, Git has a bug
+_("TEST: A Shell string xgettext won't get")
t/t0201-gettext-fallbacks.sh new file +49 -0

49 lines not on this page · raw message

t/t0202-gettext-perl.sh new file +27 -0
new file mode 100755
index 0000000..428ebb0
@@ -0,0 +1,27 @@
+#!/bin/sh
+#
+# Copyright (c) 2010 Ævar Arnfjörð Bjarmason
+#
+
+test_description='Perl gettext interface (Git::I18N)'
+
+. ./lib-gettext.sh
+
+if ! test_have_prereq PERL; then
+	skip_all='skipping perl interface tests, perl not available'
+	test_done
+fi
+
+"$PERL_PATH" -MTest::More -e 0 2>/dev/null || {
+	skip_all="Perl Test::More unavailable, skipping test"
+	test_done
+}
+
+# The external test will outputs its own plan
+test_external_has_tap=1
+
+test_external_without_stderr \
+    'Perl Git::I18N API' \
+    "$PERL_PATH" "$TEST_DIRECTORY"/t0202/test.pl
+
+test_done
t/t0202/test.pl new file +107 -0

107 lines not on this page · raw message

t/test-lib.sh +2 -0
index dff5e25..3fcb272 100644
@@ -37,6 +37,7 @@ ORIGINAL_TERM=$TERM
 # For repeatability, reset the environment to known value.
 LANG=C
 LC_ALL=C
+LANGUAGE=C
 PAGER=cat
 TZ=UTC
 TERM=dumb
@@ -961,6 +962,7 @@ esac
 
 test -z "$NO_PERL" && test_set_prereq PERL
 test -z "$NO_PYTHON" && test_set_prereq PYTHON
+test -z "$NO_GETTEXT" && test_set_prereq GETTEXT
 
 # test whether the filesystem supports symbolic links
 ln -s x y 2>/dev/null && test -h y 2>/dev/null && test_set_prereq SYMLINKS
upload-pack.c +3 -0
index 92f9530..ce27a1a 100644
@@ -10,6 +10,7 @@
 #include "revision.h"
 #include "list-objects.h"
 #include "run-command.h"
+#include "gettext.h"
 
 static const char upload_pack_usage[] = "git upload-pack [--strict] [--timeout=nn] <dir>";
 
@@ -682,6 +683,8 @@ int main(int argc, char **argv)
 	int i;
 	int strict = 0;
 
+	git_setup_gettext();
+
 	git_extract_argv0_path(argv[0]);
 	read_replace_refs = 0;
 
Signature · 1 line
1.7.2.3.313.gcd15
#3 lore raw

PATCH 5/63 tests: locate i18n lib&data correctly under --valgrind

In reply to Ævar Arnfjörð Bjarmason

From: Thomas Rast <[email protected]>

The new t020[01] for gettext support did not find git-sh-i18n and the translation data when run under --valgrind: lib-gettext.sh tried to locate them under $GIT_EXEC_PATH, which normally is the git build directory, but is changed by --valgrind to point to the wrappers.

Introduce a new variable $GIT_BUILD_DIR which can be used to locate data that resides under the build directory, and use that instead.

---
 t/lib-gettext.sh |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
t/lib-gettext.sh +3 -3
index 831ee38..f0cdd3d 100644
@@ -5,11 +5,11 @@
 
 . ./test-lib.sh
 
-GIT_TEXTDOMAINDIR="$GIT_EXEC_PATH/share/locale"
-GIT_PO_PATH="$GIT_EXEC_PATH/po"
+GIT_TEXTDOMAINDIR="$GIT_BUILD_DIR/share/locale"
+GIT_PO_PATH="$GIT_BUILD_DIR/po"
 export GIT_TEXTDOMAINDIR GIT_PO_PATH
 
-. "$GIT_EXEC_PATH"/git-sh-i18n
+. "$GIT_BUILD_DIR"/git-sh-i18n
 
 if test_have_prereq GETTEXT
 then
Signature · 1 line
1.7.2.3.313.gcd15
#4 lore raw

PATCH 21/63 po/is.po: add Icelandic translation

In reply to Ævar Arnfjörð Bjarmason

Translate the non-TEST messages added in recent patches against init-db.c. This brings Icelandic translation coverage up to 100%.

---
 po/is.po |   95 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 95 insertions(+), 0 deletions(-)
po/is.po +95 -0
index 2c38b32..85d15b8 100644
@@ -11,6 +11,101 @@ msgstr ""
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 
+#, c-format
+msgid "Could not make %s writable by group"
+msgstr "Gat ekki gert %s skrifanlega af hóp"
+
+#, c-format
+msgid "insanely long template name %s"
+msgstr "brjálæðislega langt sniðsnafn %s"
+
+#, c-format
+msgid "cannot stat '%s'"
+msgstr "gat ekki stat-að '%s'"
+
+#, c-format
+msgid "cannot stat template '%s'"
+msgstr "gat ekki stat-að sniðið '%s'"
+
+#, c-format
+msgid "cannot opendir '%s'"
+msgstr "gat ekki opnað móppuna '%s'"
+
+#, c-format
+msgid "cannot readlink '%s'"
+msgstr "gat ekki lesið tengilinn '%s'"
+
+#, c-format
+msgid "insanely long symlink %s"
+msgstr "brjálæðislega langur tengill %s"
+
+#, c-format
+msgid "cannot symlink '%s' '%s'"
+msgstr "gat ekki búið til tengilinn '%s' '%s'"
+
+#, c-format
+msgid "cannot copy '%s' to '%s'"
+msgstr "gat ekki afritað '%s' til '%s'"
+
+#, c-format
+msgid "ignoring template %s"
+msgstr "hunsa sniðið %s"
+
+#, c-format
+msgid "insanely long template path %s"
+msgstr "brjálæðislega löng slóð á snið %s"
+
+#, c-format
+msgid "templates not found %s"
+msgstr "sniðið fannst ekki %s"
+
+#, c-format
+msgid "not copying templates of a wrong format version %d from '%s'"
+msgstr "aftira ekki sniðin vegna rangar útgáfu %d frá '%s'"
+
+#, c-format
+msgid "insane git directory %s"
+msgstr "brjálúð git mappa %s"
+
+#. 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.
+#, c-format
+msgid "%s%s Git repository in %s%s\n"
+msgstr "%s%s Git lind í %s%s\n"
+
+msgid "Reinitialized existing"
+msgstr "Endurgerði"
+
+msgid "Initialized empty"
+msgstr "Bjó til tóma"
+
+msgid " shared"
+msgstr " sameiginlega"
+
+msgid "cannot tell cwd"
+msgstr "finn ekki núverandi möppu"
+
+#, c-format
+msgid "cannot mkdir %s"
+msgstr "gat ekki búið til möppuna %s"
+
+#, c-format
+msgid "cannot chdir to %s"
+msgstr "get ekki farið inn í möppuna %s"
+
+#, c-format
+msgid "%s (or --work-tree=<directory>) not allowed without specifying %s (or --git-dir=<directory>)"
+msgstr "%s (eða --work-tree=<mappa>) ekki leyfilegt ásamt %s (eða --git-dir=<mappa>)"
+
+msgid "Cannot access current working directory"
+msgstr "Get ekki opnað núverandi vinnumöppu"
+
+#, c-format
+msgid "Cannot access work tree '%s'"
+msgstr "Get ekki opnað vinnutré '%s'"
+
+#. TRANSLATORS: This is a test. You don't need to translate it.
 msgid "See 'git help COMMAND' for more information on a specific command."
 msgstr "Sjá 'git help SKIPUN' til að sjá hjálp fyrir tiltekna skipun."
 
Signature · 1 line
1.7.2.3.313.gcd15
#5 lore raw

PATCH 26/63 gettext tests: add GETTEXT_POISON=YesPlease Makefile parameter

In reply to Ævar Arnfjörð Bjarmason

Add a new GETTEXT_POISON=YesPlease Makefile debug target. With this target every invocation of _(s) will return "# GETTEXT POISON #" instead of s' or the msgstr that s` would look up.

This target is intended to sanity check the gettextization series against the test suite.

If the test suite is relying on the US English output of Git the test should either have a NO_GETTEXT_POISON prerequisite, or the message in question shouldn't be translated because it's a plumbing message.

We won't catch everything with this since we don't have 100% test coverage, but the chances of us doing so are much larger.

The reason I'm using "# GETTEXT POISON #" is that a lot of tests that rely on the fake editor would break if it wasn't a comment, since the comment message that's inserted on e.g. `git commit --amend' is translatable.

---
 Makefile      |    9 +++++++++
 gettext.h     |    4 ++++
 t/test-lib.sh |    1 +
 3 files changed, 14 insertions(+), 0 deletions(-)
Makefile +9 -0
index 4d2d4c7..f26fca3 100644
@@ -43,6 +43,10 @@ all::
 # on platforms where we don't expect glibc (Linux, Hurd,
 # GNU/kFreeBSD), which includes libintl.
 #
+# Define GETTEXT_POISON to turn all strings that use gettext into
+# gibberish. This option should only be used by the Git developers to
+# check that the Git gettext implementation itself is sane.
+#
 # Define EXPATDIR=/foo/bar if your expat header and library files are in
 # /foo/bar/include and /foo/bar/lib directories.
 #
@@ -1507,6 +1511,10 @@ ifdef NEEDS_LIBINTL
 	EXTLIBS += -lintl
 endif
 
+ifdef GETTEXT_POISON
+	COMPAT_CFLAGS += -DGETTEXT_POISON
+endif
+
 ifeq ($(TCLTK_PATH),)
 NO_TCLTK=NoThanks
 endif
@@ -2065,6 +2073,7 @@ ifdef GIT_TEST_CMP_USE_COPIED_CONTEXT
 	@echo GIT_TEST_CMP_USE_COPIED_CONTEXT=YesPlease >>$@
 endif
 	@echo NO_GETTEXT=\''$(subst ','\'',$(subst ','\'',$(NO_GETTEXT)))'\' >>$@
+	@echo GETTEXT_POISON=\''$(subst ','\'',$(subst ','\'',$(GETTEXT_POISON)))'\' >>$@
 
 ### Detect Tck/Tk interpreter path changes
 ifndef NO_TCLTK
gettext.h +4 -0
index e02939a..94ab0f3 100644
@@ -11,8 +11,12 @@ extern void git_setup_gettext(void);
 #ifdef NO_GETTEXT
 #define _(s) (s)
 #else
+#ifndef GETTEXT_POISON
 #include <libintl.h>
 #define _(s) gettext(s)
+#else
+#define _(s) "# GETTEXT POISON #"
+#endif
 #endif
 
 #endif
t/test-lib.sh +1 -0
index 3fcb272..b297ef6 100644
@@ -963,6 +963,7 @@ esac
 test -z "$NO_PERL" && test_set_prereq PERL
 test -z "$NO_PYTHON" && test_set_prereq PYTHON
 test -z "$NO_GETTEXT" && test_set_prereq GETTEXT
+test -z "$GETTEXT_POISON" && 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
Signature · 1 line
1.7.2.3.313.gcd15
#6 lore raw

PATCH 27/63 gettext tests: skip lib-gettext.sh tests under GETTEXT_POISON

In reply to Ævar Arnfjörð Bjarmason

Change the gettext tests (all of whom use lib-gettext.sh) to skip under GETTEXT_POISON=YesPlease. We also print a message to this effect.

---
 t/lib-gettext.sh |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
t/lib-gettext.sh +8 -2
index 4570ead..c9a079e 100644
@@ -11,7 +11,7 @@ export GIT_TEXTDOMAINDIR GIT_PO_PATH
 
 . "$GIT_BUILD_DIR"/git-sh-i18n
 
-if test_have_prereq GETTEXT
+if test_have_prereq GETTEXT && test_have_prereq NO_GETTEXT_POISON
 then
 	# is_IS.UTF-8 on Solaris and FreeBSD, is_IS.utf8 on Debian
 	is_IS_locale=$(locale -a | sed -n '/^is_IS\.[uU][tT][fF]-*8$/{
@@ -58,5 +58,11 @@ then
 else
 	# Only run some tests when we don't have gettext support
 	test_set_prereq NO_GETTEXT
-	say "# lib-gettext: No GETTEXT support available"
+
+	if test_have_prereq NO_GETTEXT_POISON
+	then
+		say "# lib-gettext: GETTEXT_POISON defined, can't test gettext"
+	else
+		say "# lib-gettext: No GETTEXT support available"
+	fi
 fi
Signature · 1 line
1.7.2.3.313.gcd15
#7 lore raw

PATCH 28/63 gettext tests: skip breaking tests under GETTEXT_POISON

In reply to Ævar Arnfjörð Bjarmason

Change the tests that depend on the output of the porcelain to only run if the NO_GETTEXT_POISON prerequisite is set. These will always fail under GETTEXT_POISON=YesPlease.

I've manually inspected these and determined to the best of my ability that they aren't plumbing output.

---

(repeated)

This is still the part of this series that needs the most review. I *think* I got this right, but more eyes are needed on it.

 t/lib-httpd.sh              |    2 +-
 t/t0001-init.sh             |    2 +-
 t/t1200-tutorial.sh         |    4 +-
 t/t2200-add-update.sh       |    2 +-
 t/t2204-add-ignored.sh      |    8 ++--
 t/t3030-merge-recursive.sh  |    2 +-
 t/t3200-branch.sh           |    2 +-
 t/t3203-branch-output.sh    |    2 +-
 t/t3700-add.sh              |    4 +-
 t/t4001-diff-rename.sh      |    4 +-
 t/t4014-format-patch.sh     |    2 +-
 t/t5541-http-push.sh        |    2 +-
 t/t5601-clone.sh            |    2 +-
 t/t6040-tracking-info.sh    |    2 +-
 t/t7004-tag.sh              |    6 ++-
 t/t7060-wtstatus.sh         |    2 +-
 t/t7102-reset.sh            |    2 +-
 t/t7110-reset-merge.sh      |    6 +-
 t/t7201-co.sh               |   10 ++--
 t/t7500-commit.sh           |    9 +++-
 t/t7501-commit.sh           |   14 ++++--
 t/t7502-commit.sh           |   46 ++++++++++----------
 t/t7506-status-submodule.sh |   28 ++++++------
 t/t7508-status.sh           |   98 +++++++++++++++++++++---------------------
 t/t7600-merge.sh            |    2 +-
 t/t7811-grep-open.sh        |    2 +-
 26 files changed, 139 insertions(+), 126 deletions(-)
t/lib-httpd.sh +1 -1
index e733f65..817b865 100644
@@ -154,7 +154,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/t0001-init.sh +1 -1
index 7fe8883..b45df24 100755
@@ -124,7 +124,7 @@ test_expect_success 'GIT_DIR & GIT_WORK_TREE (2)' '
 	fi
 '
 
-test_expect_success 'reinit' '
+test_expect_success NO_GETTEXT_POISON 'reinit' '
 
 	(
 		unset GIT_CONFIG GIT_WORK_TREE GIT_CONFIG
t/t1200-tutorial.sh +3 -1
index ab55eda..c568e0e 100755
@@ -163,7 +163,9 @@ 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
 '
 
t/t2200-add-update.sh +1 -1
index 2ad2819..b3b90ca 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'\''" &&
t/t2204-add-ignored.sh +4 -4
index 24afdab..b7a0d71 100755
@@ -27,7 +27,7 @@ done
 
 for i in ign dir/ign dir/sub dir/sub/*ign sub/file sub sub/*
 do
-	test_expect_success "complaints for ignored $i" '
+	test_expect_success NO_GETTEXT_POISON "complaints for ignored $i" '
 		rm -f .git/index &&
 		test_must_fail git add "$i" 2>err &&
 		git ls-files "$i" >out &&
@@ -36,7 +36,7 @@ do
 		cat err
 	'
 
-	test_expect_success "complaints for ignored $i with unignored file" '
+	test_expect_success NO_GETTEXT_POISON "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 &&
@@ -48,7 +48,7 @@ done
 
 for i in sub sub/*
 do
-	test_expect_success "complaints for ignored $i in dir" '
+	test_expect_success NO_GETTEXT_POISON "complaints for ignored $i in dir" '
 		rm -f .git/index &&
 		(
 			cd dir &&
@@ -63,7 +63,7 @@ done
 
 for i in ign file
 do
-	test_expect_success "complaints for ignored $i in sub" '
+	test_expect_success NO_GETTEXT_POISON "complaints for ignored $i in sub" '
 		rm -f .git/index &&
 		(
 			cd sub &&
t/t3030-merge-recursive.sh +1 -1
index efe2900..b8ddb94 100755
@@ -281,7 +281,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" &&
t/t3200-branch.sh +1 -1
index f54a533..d90d9fd 100755
@@ -192,7 +192,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)."'
t/t3203-branch-output.sh +1 -1
index 809d1c4..dfdf5a7 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
t/t3700-add.sh +2 -2
index ec71083..fea0c17 100755
@@ -266,7 +266,7 @@ test_expect_success 'git add --dry-run of existing changed file' "
 	echo \"add 'track-this'\" | test_cmp - actual
 "
 
-test_expect_success 'git add --dry-run of non-existing file' "
+test_expect_success NO_GETTEXT_POISON '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
@@ -282,7 +282,7 @@ cat >expect.out <<\EOF
 add 'track-this'
 EOF
 
-test_expect_success 'git add --dry-run --ignore-missing of non-existing file' '
+test_expect_success NO_GETTEXT_POISON '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_cmp expect.out actual.out &&
 	test_cmp expect.err actual.err
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"'
 
t/t4014-format-patch.sh +1 -1
index f87434b..ae3659e 100755
@@ -592,7 +592,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 &&
t/t5541-http-push.sh +1 -1
index b0c2a2c..670d3de 100755
@@ -118,7 +118,7 @@ test_expect_success 'used receive-pack service' '
 test_http_push_nonff "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git \
 	"$ROOT_PATH"/test_repo_clone master
 
-test_expect_success 'push fails for non-fast-forward refs unmatched by remote helper' '
+test_expect_success NO_GETTEXT_POISON 'push fails for non-fast-forward refs unmatched by remote helper' '
 	# create a dissimilarly-named remote ref so that git is unable to match the
 	# two refs (viz. local, remote) unless an explicit refspec is provided.
 	git push origin master:retsam
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
t/t6040-tracking-info.sh +1 -1
index 1785e17..c9a86f6 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
t/t7004-tag.sh +4 -2
index ac943f5..cf40992 100755
@@ -1044,12 +1044,14 @@ test_expect_success GPG \
 	'verify signed tag fails when public key is not present' \
 	'test_must_fail git tag -v signed-tag'
 
-test_expect_success \
+# "POISON" isn't a comment, so skip under GETTEXT_POISON
+test_expect_success NO_GETTEXT_POISON \
 	'git tag -a fails if tag annotation is empty' '
 	! (GIT_EDITOR=cat git tag -a initial-comment)
 '
 
-test_expect_success \
+# Likewise GETTEXT_POISON doesn't emit something that looks like a comment
+test_expect_success NO_GETTEXT_POISON \
 	'message in editor has initial comment' '
 	GIT_EDITOR=cat git tag -a initial-comment > actual
 	# check the first line --- should be empty
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/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
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 &&
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 &&
t/t7500-commit.sh +6 -3
index aa9c577..6b983b8 100755
@@ -59,7 +59,10 @@ test_expect_success 'adding comments to a template should not commit' '
 	)
 '
 
-test_expect_success 'adding real content to a template should commit' '
+# These fail under GETTEXT_POISON because the poison editor message
+# doesn't do the right thing with comments and line breaks, this
+# message will be incorrectly broken up across lines.
+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 +70,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 +81,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 &&
t/t7501-commit.sh +10 -4
index 8297cb4..96601db 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" \
@@ -142,7 +145,8 @@ cat >msg <<EOF
 A good commit message.
 EOF
 
-test_expect_success \
+# Can't rely on editor with POISON
+test_expect_success NO_GETTEXT_POISON \
 	'editor not invoked if -F is given' '
 	 echo "moo" >file &&
 	 EDITOR=./editor git commit -a -F msg &&
@@ -163,7 +167,9 @@ d381ac431806e53f3dd7ac2f1ae0534f36d738b9
 402702b49136e7587daa9280e91e4bb7cb2179f7
 EOF
 
-test_expect_success \
+# rev-list won't be OK under GETTEXT_POISON since the above test won't
+# run.
+test_expect_success NO_GETTEXT_POISON \
     'validate git rev-list output.' \
     'test_cmp expected current'
 
t/t7502-commit.sh +23 -23

178 lines not on this page · raw message

t/t7506-status-submodule.sh +14 -14
index 3d4f85d..2347451 100755
@@ -20,17 +20,17 @@ 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
 '
 
-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
@@ -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
 '
t/t7508-status.sh +49 -49

374 lines not on this page · raw message

t/t7600-merge.sh +1 -1
index b4f40e4..cc6c4e9 100755
@@ -484,7 +484,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 &&
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.313.gcd15
#8 lore raw

PATCH 51/63 gettextize: git-merge basic messages

In reply to Ævar Arnfjörð Bjarmason
---
 builtin/merge.c |  122 +++++++++++++++++++++++++++---------------------------
 1 files changed, 61 insertions(+), 61 deletions(-)
builtin/merge.c +61 -61
index 5f65c0c..0ae2b51 100644
@@ -79,7 +79,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;
 }
 
@@ -116,13 +116,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");
@@ -220,17 +220,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 reset_hard(unsigned const char *sha1, int verbose)
@@ -247,7 +247,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)
@@ -276,7 +276,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();
 }
 
@@ -289,10 +289,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;
@@ -307,7 +307,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;
@@ -320,9 +320,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);
 }
 
@@ -342,7 +342,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",
@@ -364,7 +364,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);
@@ -393,7 +393,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/")) {
@@ -458,7 +458,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);
@@ -488,7 +488,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));
@@ -550,7 +550,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, struct commit_list *common,
@@ -591,7 +591,7 @@ int try_merge_command(const char *strategy, struct commit_list *common,
 	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;
@@ -608,7 +608,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")) {
@@ -621,7 +621,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;
 		}
 
@@ -648,7 +648,7 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,
 			else if (!strcmp(xopts[x], "no-renormalize"))
 				o.renormalize = 0;
 			else
-				die("Unknown option for merge-recursive: -X%s", xopts[x]);
+				die(_("Unknown option for merge-recursive: -X%s"), xopts[x]);
 		}
 
 		o.branch1 = head_arg;
@@ -663,7 +663,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 {
@@ -734,7 +734,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;
 }
 
@@ -788,7 +788,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;
@@ -837,7 +837,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++) {
@@ -853,8 +853,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;
 }
 
@@ -868,7 +868,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;
 	}
@@ -918,10 +918,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();
@@ -948,12 +948,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,
@@ -981,16 +981,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);
 		reset_hard(remote_head->sha1, 0);
@@ -1038,7 +1038,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;
@@ -1096,7 +1096,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));
@@ -1130,11 +1130,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 {
 		/*
@@ -1167,7 +1167,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);
@@ -1193,11 +1193,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
@@ -1258,17 +1258,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);
 	}
@@ -1284,35 +1284,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);
Signature · 1 line
1.7.2.3.313.gcd15
#9 lore raw

PATCH 63/63 po/en_GB.po: add British English Translation

In reply to Ævar Arnfjörð Bjarmason

From: Sam Reed <[email protected]>

Translate the three Git messages from US to British English. These all had to do with z v.s. s differences.

---
 po/en_GB.po |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)
 create mode 100644 po/en_GB.po
po/en_GB.po new file +22 -0
new file mode 100644
index 0000000..b1f3e34
@@ -0,0 +1,22 @@
+msgid ""
+msgstr ""
+"Project-Id-Version: Git\n"
+"PO-Revision-Date: 2010-09-02 19:09 +0000\n"
+"Language-Team: Git Mailing List <[email protected]>\n"
+"Report-Msgid-Bugs-To: Git Mailing List <[email protected]>\n"
+"Last-Translator: Sam Reed <[email protected]>\n"
+"Language-Team: Git Mailing List <[email protected]>\n"
+"Language: en-gb\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+msgid "Reinitialized existing"
+msgstr "Reinitialised existing"
+
+msgid "Initialized empty"
+msgstr "Initialised empty"
+
+#, c-format
+msgid "unrecognized argument: %s"
+msgstr "unrecognised argument: %s"
Signature · 1 line
1.7.2.3.313.gcd15
#10 lore raw

cover Add gettext support to Git

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

The previous nested pull requests were a mess, and I needed to fix some bugs. So here's a total re-do of the ab/i18n series. Everything that's already in pu from ab/i18n can be ejected in favor of this.

Most of these 63 patches have been seen here before. So I'll only be sending the stuff that's changed or interesting along with this series. To get the full thing go to:

Quoted 8 lines
   git://github.com/avar/git.git ab/i18n-all
   http://github.com/avar/git/compare/master...ab/i18n-all
   http://github.com/avar/git/compare/master...ab/i18n-all.patch

The last of which is a patch file suitable for git-am(1).

Since last time I've rebased this on the new upstream master branch, which now has my ab/test-2 series.

Here's more work on top of my existing 63 patch series, bringing it to 78 patches in total.

With this all of the 'mainporcelain common' *and* 'mainporcelain' in command-list.txt has been made translatable, aside from these shellscripts:

    git-am                                  mainporcelain
    git-bisect                              mainporcelain common
    git-pull                                mainporcelain common
    git-rebase                              mainporcelain common
    git-stash                               mainporcelain
    git-submodule                           mainporcelain

Jan Krüger was doing some work on the git-add--interactive helper and those, and I was getting comfortable with doing only C, so I've left those for now.

This time around the changes to tests to add the NO_GETTEXT_POISON prerequisite are part of the *.c patches themselves. This should make it easier to review the series, since you can see what tests need to be skipped for each patch.

This series goes on top of ab/i18n-all and can be pulled from my GitHub branch:

    git://github.com/avar/git.git ab/i18n-all-continue
    http://github.com/avar/git/compare/ab/i18n-all...ab/i18n-all-continue
    http://github.com/avar/git/compare/ab/i18n-all...ab/i18n-all-continue.patch

And to see the whole thing from master:

http://github.com/avar/git/compare/master...ab/i18n-all-continue
http://github.com/avar/git/compare/master...ab/i18n-all-continue.patch

Note that this doesn't include Ramkumar Ramachandra's patch to add Hindi. You'll have to get that from the archive separately.

Ævar Arnfjörð Bjarmason (15):
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-notes "Refusing to %s notes in %s" message
gettextize: git-revert basic messages
gettextize: git-revert mark the "me" variable for translation
gettextize: git-revert messages using the "me" variable
gettextize: git-revert split up "could not revert/apply" message
gettextize: git-shortlog basic messages

 builtin/archive.c                |   14 ++--
 builtin/bundle.c                 |    6 +-
 builtin/clean.c                  |   28 +++++----
 builtin/describe.c               |   36 +++++-----
 builtin/gc.c                     |   24 ++++----
 builtin/notes.c                  |  132 +++++++++++++++++++------------------
 builtin/revert.c                 |   65 ++++++++++---------
 builtin/shortlog.c               |    8 +-
 t/t3501-revert-cherry-pick.sh    |    2 +-
 t/t3507-cherry-pick-conflict.sh  |    2 +-
 t/t6120-describe.sh              |    2 +-
 t/t7012-skip-worktree-writing.sh |    4 +-
 t/t7300-clean.sh                 |    6 +-
 13 files changed, 170 insertions(+), 159 deletions(-)
Signature · 1 line
1.7.2.3.313.gcd15
#11 lore raw

PATCH 1/15 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.313.gcd15
#12 lore raw

PATCH 2/15 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 80649ba..f92970f 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.313.gcd15
#13 lore raw

PATCH 3/15 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 b508d2c..10dde87 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 7dbbea1..eed032d 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.313.gcd15
#14 lore raw

PATCH 4/15 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 |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
builtin/clean.c +6 -2
index 10dde87..642d767 100644
@@ -78,8 +78,12 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
 		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 (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.313.gcd15
#15 lore raw

PATCH 5/15 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 43caff2..616d405 100644
@@ -202,13 +202,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;
 	}
 
@@ -235,10 +235,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 = cmit->util;
 	if (n && (tags || all || n->prio == 2)) {
@@ -255,9 +255,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);
 
 	list = NULL;
 	cmit->object.flags = SEEN;
@@ -292,7 +292,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;
 		}
@@ -316,12 +316,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));
 	}
 
@@ -341,11 +341,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));
 		}
@@ -395,7 +395,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 *));
@@ -420,14 +420,14 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
 
 	for_each_ref(get_name, NULL);
 	if (!found_names && !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.313.gcd15
#16 lore raw

PATCH 6/15 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 c304638..05aed1f 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);
@@ -248,8 +248,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.313.gcd15
#17 lore raw

PATCH 7/15 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 05aed1f..74e77cb 100644
@@ -216,13 +216,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.313.gcd15
#18 lore raw

PATCH 8/15 gettextize: git-notes basic commands

In reply to Ævar Arnfjörð Bjarmason
---
 builtin/notes.c |  108 +++++++++++++++++++++++++++---------------------------
 1 files changed, 54 insertions(+), 54 deletions(-)
builtin/notes.c +54 -54
index fbc347c..d171f6f 100644
@@ -119,13 +119,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) {
@@ -135,10 +135,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));
 }
 
@@ -155,7 +155,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);
@@ -169,8 +169,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);
 	}
@@ -190,14 +190,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);
 		}
@@ -231,9 +231,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;
@@ -252,10 +252,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);
@@ -280,7 +280,7 @@ int 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 0; /* don't have to commit an unchanged tree */
 
@@ -292,7 +292,7 @@ int commit_notes(struct notes_tree *t, const char *msg)
 
 	/* Convert notes tree to tree object */
 	if (write_notes_tree(t, tree_sha1))
-		die("Failed to write current notes tree to database");
+		die(_("Failed to write current notes tree to database"));
 
 	/* Create new commit for the tree object */
 	if (!read_ref(t->ref, prev_commit)) { /* retrieve parent commit */
@@ -304,7 +304,7 @@ int commit_notes(struct notes_tree *t, const char *msg)
 		parent = NULL;
 	}
 	if (commit_tree(buf.buf + 7, tree_sha1, parent, new_commit, NULL))
-		die("Failed to commit notes tree to database");
+		die(_("Failed to commit notes tree to database"));
 
 	/* Update notes ref with new commit */
 	update_ref(buf.buf, t->ref, new_commit, prev_commit, 0, DIE_ON_ERR);
@@ -336,7 +336,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;
@@ -346,8 +346,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;
 	}
 
@@ -435,13 +435,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);
@@ -450,7 +450,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;
 		}
@@ -494,20 +494,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);
@@ -546,26 +546,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));
 	}
 
@@ -607,7 +607,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);
@@ -615,41 +615,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;
 	}
 
@@ -691,19 +691,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);
@@ -738,20 +738,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};
@@ -774,18 +774,18 @@ 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");
 
-	fprintf(stderr, "Removing note for object %s\n", sha1_to_hex(object));
+	fprintf(stderr, _("Removing note for object %s\n"), sha1_to_hex(object));
 	remove_note(t, object);
 
 	commit_notes(t, "Notes removed by 'git notes remove'");
@@ -808,7 +808,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);
 	}
 
@@ -864,7 +864,7 @@ int cmd_notes(int argc, const char **argv, const char *prefix)
 	else if (!strcmp(argv[0], "prune"))
 		result = prune(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.313.gcd15
#19 lore raw

PATCH 9/15 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 d171f6f..fe58a41 100644
@@ -371,8 +371,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.313.gcd15
#20 lore raw

PATCH 10/15 gettextize: git-notes "Refusing to %s notes in %s" message

In reply to Ævar Arnfjörð Bjarmason

The first %s in "Refusing to %s notes in %s" is one of "git notes ACTION". So we need to mark those actions for translation and later use _().

Also add a TRANSLATORS comment explaining to translators what the first %s means.

---
 builtin/notes.c |   18 ++++++++++--------
 1 files changed, 10 insertions(+), 8 deletions(-)
builtin/notes.c +10 -8
index fe58a41..2b417d7 100644
@@ -476,8 +476,10 @@ static struct notes_tree *init_notes_check(const char *subcommand)
 	t = &default_notes_tree;
 
 	if (prefixcmp(t->ref, "refs/notes/"))
-		die("Refusing to %s notes in %s (outside of refs/notes/)",
-		    subcommand, t->ref);
+		/* TRANSLATORS: The first %s is one of "git notes ACTION",
+		   e.g. "add", "copy", "append" etc. */
+		die(_("Refusing to %s notes in %s (outside of refs/notes/)"),
+		    _(subcommand), t->ref);
 	return t;
 }
 
@@ -500,7 +502,7 @@ static int list(int argc, const char **argv, const char *prefix)
 		usage_with_options(git_notes_list_usage, options);
 	}
 
-	t = init_notes_check("list");
+	t = init_notes_check(N_("list"));
 	if (argc) {
 		if (get_sha1(argv[0], object))
 			die(_("Failed to resolve '%s' as a valid ref."), argv[0]);
@@ -557,7 +559,7 @@ static int add(int argc, const char **argv, const char *prefix)
 	if (get_sha1(object_ref, object))
 		die(_("Failed to resolve '%s' as a valid ref."), object_ref);
 
-	t = init_notes_check("add");
+	t = init_notes_check(N_("add"));
 	note = get_note(t, object);
 
 	if (note) {
@@ -633,7 +635,7 @@ static int copy(int argc, const char **argv, const char *prefix)
 	if (get_sha1(object_ref, object))
 		die(_("Failed to resolve '%s' as a valid ref."), object_ref);
 
-	t = init_notes_check("copy");
+	t = init_notes_check(N_("copy"));
 	note = get_note(t, object);
 
 	if (note) {
@@ -749,7 +751,7 @@ static int show(int argc, const char **argv, const char *prefix)
 	if (get_sha1(object_ref, object))
 		die(_("Failed to resolve '%s' as a valid ref."), object_ref);
 
-	t = init_notes_check("show");
+	t = init_notes_check(N_("show"));
 	note = get_note(t, object);
 
 	if (!note)
@@ -785,7 +787,7 @@ static int remove_cmd(int argc, const char **argv, const char *prefix)
 	if (get_sha1(object_ref, object))
 		die(_("Failed to resolve '%s' as a valid ref."), object_ref);
 
-	t = init_notes_check("remove");
+	t = init_notes_check(N_("remove"));
 
 	fprintf(stderr, _("Removing note for object %s\n"), sha1_to_hex(object));
 	remove_note(t, object);
@@ -814,7 +816,7 @@ static int prune(int argc, const char **argv, const char *prefix)
 		usage_with_options(git_notes_prune_usage, options);
 	}
 
-	t = init_notes_check("prune");
+	t = init_notes_check(N_("prune"));
 
 	prune_notes(t, (verbose ? NOTES_PRUNE_VERBOSE : 0) |
 		(show_only ? NOTES_PRUNE_VERBOSE|NOTES_PRUNE_DRYRUN : 0) );
Signature · 1 line
1.7.2.3.313.gcd15
#21 lore raw

PATCH 11/15 gettextize: git-revert basic messages

In reply to Ævar Arnfjörð Bjarmason
---
 builtin/revert.c |   42 +++++++++++++++++++++---------------------
 1 files changed, 21 insertions(+), 21 deletions(-)
builtin/revert.c +21 -21
index 4b47ace..ece0c0f 100644
@@ -79,7 +79,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,
@@ -151,7 +151,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++)
@@ -185,7 +185,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;
@@ -199,7 +199,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;
@@ -211,7 +211,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);
@@ -227,7 +227,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));
 }
 
@@ -264,10 +264,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)
@@ -405,10 +405,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);
 	}
@@ -416,7 +416,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) {
@@ -425,7 +425,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;
@@ -433,11 +433,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;
@@ -450,7 +450,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));
 
 	/*
@@ -541,10 +541,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 int revert_or_cherry_pick(int argc, const char **argv)
@@ -558,13 +558,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"));
 	}
 
 	if (read_cache() < 0)
Signature · 1 line
1.7.2.3.313.gcd15
#22 lore raw

PATCH 12/15 gettextize: git-revert mark the "me" variable for translation

In reply to Ævar Arnfjörð Bjarmason

The "me" variable is used in many later messages to indicate whether we're using revert or cherry-pick. Mark it for translation for later use. Also leave a TRANSLATORS message explaining what these are for.

---
 builtin/revert.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
builtin/revert.c +3 -1
index ece0c0f..2f319f8 100644
@@ -552,7 +552,9 @@ static int revert_or_cherry_pick(int argc, const char **argv)
 	struct rev_info revs;
 
 	git_config(git_default_config, NULL);
-	me = action == REVERT ? "revert" : "cherry-pick";
+	/* TRANSLATORS: This is used in several error messages indicating
+	   the name of the current program */
+	me = action == REVERT ? N_("revert") : N_("cherry-pick");
 	setenv(GIT_REFLOG_ACTION, me, 0);
 	parse_args(argc, argv);
 
Signature · 1 line
1.7.2.3.313.gcd15
#23 lore raw

Re: [PATCH 12/15] gettextize: git-revert mark the "me" variable for translation

Quoted 2 lines · Ævar Arnfjörð Bjarmason

The "me" variable is used in many later messages to indicate whether we're using revert or cherry-pick.

What good does it do to translate it? The command name is the same even in Hindi git.

builtin/revert.c static int revert_or_cherry_pick(int argc, const char **argv) · line 558

Quoted 11 lines
builtin/revert.c +3 -1
@@ -552,7 +552,9 @@ static int revert_or_cherry_pick(int argc, const char **argv)
 	struct rev_info revs;
 
 	git_config(git_default_config, NULL);
-	me = action == REVERT ? "revert" : "cherry-pick";
+	/* TRANSLATORS: This is used in several error messages indicating
+	   the name of the current program */
+	me = action == REVERT ? N_("revert") : N_("cherry-pick");
 	setenv(GIT_REFLOG_ACTION, me, 0);

Unrelated question: Are reflog actions supposed to be translated? (I have not thought about that carefully.)

#24 lore raw

Re: [PATCH 12/15] gettextize: git-revert mark the "me" variable for translation

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

The "me" variable is used in many later messages to indicate whether we're using revert or cherry-pick.

What good does it do to translate it?  The command name is the same even in Hindi git.

Not all uses of it are references to git-%s, e.g. in the next patch:

    die(_("Your local changes would be overwritten by %s.\n"), _(me));

But maybe it's used in enough contexts for it to be useless to translate it like this, i.e. we'll have to fix it later, but we'll see about that.

Quoted 5 lines
Quoted 5 lines
builtin/revert.c +0 -0
@@ -552,7 +552,9 @@ static int revert_or_cherry_pick(int argc, const char **argv)
       struct rev_info revs;
 
Quoted 9 lines

builtin/revert.c static int revert_or_cherry_pick(int argc, const char **argv) · line 558

Quoted 6 lines
builtin/revert.c +3 -1
       git_config(git_default_config, NULL);
-     me = action == REVERT ? "revert" : "cherry-pick";
+     /* TRANSLATORS: This is used in several error messages indicating
+        the name of the current program */
+     me = action == REVERT ? N_("revert") : N_("cherry-pick");
       setenv(GIT_REFLOG_ACTION, me, 0);

Unrelated question: Are reflog actions supposed to be translated?  (I have not thought about that carefully.)

In this updated series I've explicitly reverted patches that (accidentally) translated some of the reflog.

I'm only translating things which'll be viewed by human eyes, and human eyes alone. That doesn't apply to the reflog, which I see as plumbing.

#25 lore raw

Re: [PATCH 12/15] gettextize: git-revert mark the "me" variable for translation

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

What good does it do to translate it?  The command name is the same even in Hindi git.

Not all uses of it are references to git-%s, e.g. in the next patch:

Right, forget about this comment. Maybe this patch should be squashed with the next one so reviewers can more easily see what is going on.

Quoted 6 lines

In this updated series I've explicitly reverted patches that (accidentally) translated some of the reflog.

I'm only translating things which'll be viewed by human eyes, and human eyes alone. That doesn't apply to the reflog, which I see as plumbing.

Thanks for explaining.

#26 lore raw

PATCH 13/15 gettextize: git-revert messages using the "me" variable

In reply to Ævar Arnfjörð Bjarmason

Mark messages that used the "me" variable for translation. The potential values of the variable had already been marked using N_(), so we can use _(me) here.

---
 builtin/revert.c              |   14 +++++++-------
 t/t3501-revert-cherry-pick.sh |    2 +-
 2 files changed, 8 insertions(+), 8 deletions(-)
builtin/revert.c +7 -7
index 2f319f8..8dff244 100644
@@ -286,10 +286,10 @@ static NORETURN void die_dirty_index(const char *me)
 		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);
+			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);
+			die(_("Your local changes would be overwritten by %s.\n"), _(me));
 	}
 }
 
@@ -339,7 +339,7 @@ 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);
+		die(_("%s: Unable to write new index file"), _(me));
 	rollback_lock_file(&index_lock);
 
 	if (!clean) {
@@ -446,8 +446,8 @@ 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",
-		    me, sha1_to_hex(parent->object.sha1));
+		die(_("%s: cannot parse parent commit %s"),
+		    _(me), sha1_to_hex(parent->object.sha1));
 
 	if (get_message(commit->buffer, &msg) != 0)
 		die(_("Cannot get commit message for %s"),
@@ -570,7 +570,7 @@ static int revert_or_cherry_pick(int argc, const char **argv)
 	}
 
 	if (read_cache() < 0)
-		die("git %s: failed to read the index", me);
+		die(_("git %s: failed to read the index"), _(me));
 
 	prepare_revs(&revs);
 
t/t3501-revert-cherry-pick.sh +1 -1
index bc7aedd..b12b1b4 100755
@@ -81,7 +81,7 @@ test_expect_success 'revert after renaming branch' '
 
 '
 
-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.313.gcd15
Reviewed-by on v1 13/15
#27 lore raw

Re: [PATCH 13/15] gettextize: git-revert messages using the "me" variable

(+cc: Christian, de facto cherry-pick maintainer)

Quoted 3 lines · Ævar Arnfjörð Bjarmason

Mark messages that used the "me" variable for translation. The potential values of the variable had already been marked using N_(), so we can use _(me) here.

Ah, now I understand better. Would it be possible to squash this patch with the previous one (for clarity)?

builtin/revert.c static NORETURN void die_dirty_index(const char *me) · line 292

Quoted 13 lines
builtin/revert.c +3 -3
@@ -286,10 +286,10 @@ static NORETURN void die_dirty_index(const char *me)
 		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);
+			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);
+			die(_("Your local changes would be overwritten by %s.\n"), _(me));

Good.

builtin/revert.c static int do_recursive_merge(struct commit *base, struct commit *next, · line 342

Quoted 6 lines
builtin/revert.c +1 -1
@@ -339,7 +339,7 @@ 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);
+		die(_("%s: Unable to write new index file"), _(me));

Not good, in my opinion. The dialogue ought to look like this, I think:

 $ git cherry-pick astermay
 ...
 fatal: cherry-pick: Unableway otay itewray ewnay indexway ilefay

builtin/revert.c static int do_pick_commit(void) · line 450

Quoted 8 lines
builtin/revert.c +2 -2
@@ -446,8 +446,8 @@ 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",
-		    me, sha1_to_hex(parent->object.sha1));
+		die(_("%s: cannot parse parent commit %s"),
+		    _(me), sha1_to_hex(parent->object.sha1));

Likewise.

builtin/revert.c static int revert_or_cherry_pick(int argc, const char **argv) · line 573

Quoted 6 lines
builtin/revert.c +1 -1
@@ -570,7 +570,7 @@ static int revert_or_cherry_pick(int argc, const char **argv)
 	}
 
 	if (read_cache() < 0)
-		die("git %s: failed to read the index", me);
+		die(_("git %s: failed to read the index"), _(me));

Likewise.

With the exceptions mentioned above,

Thanks.

#28 lore raw

Re: [PATCH 13/15] gettextize: git-revert messages using the "me" variable

Quoted 1 line · Jonathan Nieder

(+cc: Christian, de facto cherry-pick maintainer)

Thanks. In most cases I haven't been CC-ing people,

a) because I'd probably end up CC-ing everyone who ever touched git

b) the nature of the changes probalby doesn't especially benefit from me bothering all these people. But maybe that's the wrong assumption.

But by all means add more people to the CC :)

Quoted 8 lines
Quoted 3 lines · Ævar Arnfjörð Bjarmason

Mark messages that used the "me" variable for translation. The potential values of the variable had already been marked using N_(), so we can use _(me) here.

Ah, now I understand better.  Would it be possible to squash this patch with the previous one (for clarity)?

And now I see the reply I just sent off was useless, oh well, that's what I get for reading things sequentially :)

Sure, it can be squashed. I'm just trying to keep things as granular as possible, but maybe I'm overshooting it in some cases.

Quoted 40 lines
Quoted 10 lines
builtin/revert.c +2 -2
@@ -286,10 +286,10 @@ static NORETURN void die_dirty_index(const char *me)
               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);
+                     die(_("Your local changes would be overwritten by %s.\n"
+                         "Please, commit your changes or stash them to proceed."), _(me));
Quoted 3 lines

              else
-                     die("Your local changes would be overwritten by %s.\n", me);
+                     die(_("Your local changes would be overwritten by %s.\n"), _(me));

Good.

Quoted 6 lines
builtin/revert.c +0 -0
@@ -339,7 +339,7 @@ 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);
+             die(_("%s: Unable to write new index file"), _(me));

Not good, in my opinion.  The dialogue ought to look like this, I think:

 $ git cherry-pick astermay
 ...
 fatal: cherry-pick: Unableway otay itewray ewnay indexway ilefay

builtin/revert.c static int do_pick_commit(void) · line 450

Quoted 8 lines
builtin/revert.c +2 -2
@@ -446,8 +446,8 @@ 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",
-                 me, sha1_to_hex(parent->object.sha1));
+             die(_("%s: cannot parse parent commit %s"),
+                 _(me), sha1_to_hex(parent->object.sha1));

Likewise.

Quoted 8 lines

builtin/revert.c static int revert_or_cherry_pick(int argc, const char **argv) · line 573

Quoted 6 lines
builtin/revert.c +1 -1
@@ -570,7 +570,7 @@ static int revert_or_cherry_pick(int argc, const char **argv)
       }
 
       if (read_cache() < 0)
-             die("git %s: failed to read the index", me);
+             die(_("git %s: failed to read the index"), _(me));

Likewise.

I don't know if all of the above hold true, e.g. because some languages will always transliterate things, even proper nouns.

But as mentioned before the string is probably being used in too many different contexts for it to be useful to them.

Quoted 1 line

With the exceptions mentioned above,

So I should probably just skip translating the "me" variable for now. I.e. this and the last patch can probably be dropped.

Quoted 1 line
#29 lore raw

Re: [PATCH 13/15] gettextize: git-revert messages using the "me" variable

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

Not good, in my opinion.  The dialogue ought to look like this, I think:

 $ git cherry-pick astermay
 ...
 fatal: cherry-pick: Unableway otay itewray ewnay indexway ilefay

[...]

Quoted 5 lines

I don't know if all of the above hold true, e.g. because some languages will always transliterate things, even proper nouns.

But as mentioned before the string is probably being used in too many different contexts for it to be useful to them.

Hmm, okay. Do you mean languages like Japanese or something else? At any rate, I guess you are right that this is too complicated for the moment.

#30 lore raw

Re: [PATCH 13/15] gettextize: git-revert messages using the "me" variable

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

Not good, in my opinion.  The dialogue ought to look like this, I think:

 $ git cherry-pick astermay
 ...
 fatal: cherry-pick: Unableway otay itewray ewnay indexway ilefay

[...]

Quoted 3 lines

I don't know if all of the above hold true, e.g. because some languages will always transliterate things, even proper nouns.

Quoted 6 lines
Quoted 2 lines

But as mentioned before the string is probably being used in too many different contexts for it to be useful to them.

Hmm, okay.  Do you mean languages like Japanese or something else?  At any rate, I guess you are right that this is too complicated for the moment.

The languages here that translate "Wikipedia" differently than "Wikipedia" are a pretty good indicator:

http://meta.wikimedia.org/wiki/User:Waldir/Logos_and_slogans

#31 lore raw

Re: [PATCH 13/15] gettextize: git-revert messages using the "me" variable

Quoted 16 lines · Ævar Arnfjörð Bjarmason
Quoted 15 lines · Jonathan Nieder
Quoted 7 lines · Ævar Arnfjörð Bjarmason
Quoted 5 lines · Jonathan Nieder

Not good, in my opinion. The dialogue ought to look like this, I think:

 $ git cherry-pick astermay
 ...
 fatal: cherry-pick: Unableway otay itewray ewnay indexway ilefay

[...]

Quoted 5 lines

I don't know if all of the above hold true, e.g. because some languages will always transliterate things, even proper nouns.

But as mentioned before the string is probably being used in too many different contexts for it to be useful to them.

Quoted 8 lines
Quoted 3 lines

Hmm, okay. Do you mean languages like Japanese or something else? At any rate, I guess you are right that this is too complicated for the moment.

The languages here that translate "Wikipedia" differently than "Wikipedia" are a pretty good indicator:

http://meta.wikimedia.org/wiki/User:Waldir/Logos_and_slogans

I don't think so, unless you are translating the git subcommand names.

If your translated git lets/forces you to say

  $  git ckcherry-piay astermay

then that is a different story. It might be very reasonable to translate the "fatal:" message to

alfatay: ckcherry-piay: Unableway otay itewray ewnay indexway ilefay

and it probably becomes a fair comparison with the wikipedia situation, but otherwise no.

#32 lore raw

PATCH 14/15 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 8dff244..7157ee1 100644
@@ -510,8 +510,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.313.gcd15
Acked-by on v1 14/15
#33 lore raw

Re: [PATCH 14/15] gettextize: git-revert split up "could not revert/apply" message

(+cc: Christian)

Quoted 3 lines · Æ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.

Right, parts of speech can be a pain. So:

t/t3507-cherry-pick-conflict.sh test_expect_success 'failed cherry-pick does not advance HEAD' ' · line 41

Quoted 8 lines
t/t3507-cherry-pick-conflict.sh +1 -1
@@ -38,7 +38,7 @@ test_expect_success 'failed cherry-pick does not advance HEAD' '
 	test "$head" = "$newhead"
 '
 
-test_expect_success 'advice from failed cherry-pick' "
+test_expect_success NO_GETTEXT_POISON 'advice from failed cherry-pick' "

An idea (it may or may not be a good one ;-)): what if we made the gettext poison into an automatically generated .po file? Then testing poison would be a special case of running tests with an arbitrary locale:

 $ TEST_LANGUAGE=poison prove t[0-9]*.sh

and this test prerequisite could be more intuitively named LOCALE_C or similar.

#34 lore raw

Re: [PATCH 14/15] gettextize: git-revert split up "could not revert/apply" message

Quoted 10 lines · Jonathan Nieder

(+cc: Christian)

Quoted 3 lines · Æ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.

Right, parts of speech can be a pain.  So:

Thanks.

Quoted 13 lines

t/t3507-cherry-pick-conflict.sh test_expect_success 'failed cherry-pick does not advance HEAD' ' · line 41

Quoted 8 lines
t/t3507-cherry-pick-conflict.sh +0 -0
@@ -38,7 +38,7 @@ test_expect_success 'failed cherry-pick does not advance HEAD' '

      test "$head" = "$newhead"
 '

t/t3507-cherry-pick-conflict.sh +1 -1
-test_expect_success 'advice from failed cherry-pick' "
+test_expect_success NO_GETTEXT_POISON 'advice from failed cherry-pick' "

An idea (it may or may not be a good one ;-)): what if we made the gettext poison into an automatically generated .po file?  Then testing poison would be a special case of running tests with an arbitrary locale:

Quoted 4 lines
 $ TEST_LANGUAGE=poison prove t[0-9]*.sh

and this test prerequisite could be more intuitively named LOCALE_C or similar.

The issue with that is that gettext depends on setlocale(), which requires a *valid* locale. This is why I skip the t/lib-gettext.sh tests unless locale -a says is_IS is there, because even if we compile is.po using it won't work without the locale.

So to do this we'd have steal some locale.

Also, the set of tests we want to skip under POISON (i.e. automated garbage) is slightly different from the tests we want to skip under TEST_LOCALE=, because some of those tests are checking for the %s in "file failed: %s". So they'll fail under POISON, but shouldn't fail under any translation.

#35 lore raw

Re: [PATCH 14/15] gettextize: git-revert split up "could not revert/apply" message

Quoted 1 line · Ævar Arnfjörð Bjarmason

to do this we'd have steal some locale.

Alas. Thanks for explaining.

Quoted 5 lines

Also, the set of tests we want to skip under POISON (i.e. automated garbage) is slightly different from the tests we want to skip under TEST_LOCALE=, because some of those tests are checking for the %s in "file failed: %s". So they'll fail under POISON, but shouldn't fail under any translation.

This could be fixable in the long term, no? e.g., under POISON we could have something like

 _ () {
	 perl -pe 's/(?<!%)[^%#]*/POISON/g'

}

to preserve commit message comments and % directives.

#36 lore raw

Re: [PATCH 14/15] gettextize: git-revert split up "could not revert/apply" message

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

to do this we'd have steal some locale.

Alas.  Thanks for explaining.

Quoted 5 lines

Also, the set of tests we want to skip under POISON (i.e. automated garbage) is slightly different from the tests we want to skip under TEST_LOCALE=, because some of those tests are checking for the %s in "file failed: %s". So they'll fail under POISON, but shouldn't fail under any translation.

Quoted 8 lines

This could be fixable in the long term, no?  e.g., under POISON we could have something like

 _ () {
        perl -pe 's/(?<!%)[^%#]*/POISON/g'
 }

to preserve commit message comments and % directives.

Yeah, but rather than do fancy stuff like that in C I just made a dumb implementation.

It's far easier to just skip a few more tests than it is to come up with your own parser that avoids printf directives but still poisons the message enough that e.g. <grep "Clone" ..> won't work anymore.

#37 lore raw

PATCH 15/15 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 2135b0d..f2cfe97 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.313.gcd15