1. 10 3月, 2011 29 次提交
  2. 09 3月, 2011 7 次提交
    • J
      i18n: do not poison translations unless GIT_GETTEXT_POISON envvar is set · 30955229
      Jonathan Nieder 提交于
      Tweak the GETTEXT_POISON facility so it is activated at run time
      instead of compile time.  If the GIT_GETTEXT_POISON environment
      variable is set, _(msg) will result in gibberish as before; but if the
      GIT_GETTEXT_POISON variable is not set, it will return the message for
      human-readable output.  So the behavior of mistranslated and
      untranslated git can be compared without rebuilding git in between.
      
      For simplicity we always set the GIT_GETTEXT_POISON variable in tests.
      
      This does not affect builds without the GETTEXT_POISON compile-time
      option set, so non-i18n git will not be slowed down.
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      30955229
    • Æ
      i18n: add GETTEXT_POISON to simulate unfriendly translator · bb946bba
      Ævar Arnfjörð Bjarmason 提交于
      Add a new GETTEXT_POISON compile-time parameter to make _(msg) always
      return gibberish. So now you can run
      
      	make GETTEXT_POISON=YesPlease
      
      to get a copy of git that functions correctly (one hopes) but produces
      output that is in nobody's native language at all.
      
      This is a debugging aid for people who are working on the i18n part of
      the system, to make sure that they are not marking plumbing messages
      that should never be translated with _().
      
      As new strings get marked for translation, naturally a number of tests
      will be broken in this mode. Tests that depend on output from
      Porcelain will need to be marked with the new C_LOCALE_OUTPUT test
      prerequisite. Newly failing tests that do not depend on output from
      Porcelain would be bugs due to messages that should not have been
      marked for translation.
      
      Note that the string we're using ("# GETTEXT POISON #") intentionally
      starts the pound sign. Some of Git's tests such as
      t3404-rebase-interactive.sh rely on interactive editing with a fake
      editor, and will needlessly break if the message doesn't start with
      something the interactive editor considers a comment.
      
      A future patch will fix fix the underlying cause of that issue by
      adding "#" characters to the commit advice automatically.
      Signed-off-by: NÆvar Arnfjörð Bjarmason <avarab@gmail.com>
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      bb946bba
    • Æ
      i18n: add no-op _() and N_() wrappers · 65784830
      Ævar Arnfjörð Bjarmason 提交于
      The _ function is for translating strings into the user's chosen
      language.  The N_ macro just marks translatable strings for the
      xgettext(1) tool without translating them; it is intended for use in
      contexts where a function call cannot be used.  So, for example:
      
      	fprintf(stderr, _("Expansion of alias '%s' failed; "
      		"'%s' is not a git command\n"),
      		cmd, argv[0]);
      
      and
      
      	const char *unpack_plumbing_errors[NB_UNPACK_TREES_ERROR_TYPES] = {
      		/* ERROR_WOULD_OVERWRITE */
      		N_("Entry '%s' would be overwritten by merge. Cannot merge."),
      	[...]
      
      Define such _ and N_ in a new gettext.h and include it in cache.h, so
      they can be used everywhere.  Each just returns its argument for now.
      _ is a function rather than a macro like N_ to avoid the temptation to
      use _("foo") as a string literal (which would be a compile-time error
      once _(s) expands to an expression for the translation of s).
      Signed-off-by: NÆvar Arnfjörð Bjarmason <avarab@gmail.com>
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      65784830
    • J
      commit, status: use status_printf{,_ln,_more} helpers · 098d0e0e
      Jonathan Nieder 提交于
      wt-status code is used to provide a reminder of changes included and
      not included for the commit message template opened in the operator's
      text editor by "git commit".  Therefore each line of its output begins
      with the comment character "#":
      
      	# Please enter the commit message for your changes. Lines starting
      
      Use the new status_printf{,_ln,_more} functions to take care of adding
      "#" to the beginning of such status lines automatically.  Using these
      will have two advantages over the current code:
      
       - The obvious one is to force separation of the "#" from the
         translatable part of the message when git learns to translate its
         output.
      
       - Another advantage is that this makes it easier for us to drop "#"
         prefix in "git status" output in later versions of git if we want
         to.
      Explained-by: NJunio C Hamano <gitster@pobox.com>
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      098d0e0e
    • J
      commit: refer to commit template as s->fp · 3c624a30
      Jonathan Nieder 提交于
      Instead of maintaining a local variable for it, use s->fp to keep
      track of where the commit message template should be written.
      
      This prepares us to take advantage of the status_printf functions,
      which use a struct wt_status instead of a FILE pointer to determine
      where to send their output.
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      3c624a30
    • J
      wt-status: add helpers for printing wt-status lines · e0335fcd
      Jonathan Nieder 提交于
      Introduce status_printf{,_ln,_more} wrapper functions around
      color_vfprintf() which take care of adding "#" to the beginning of
      status lines automatically.  The semantics:
      
       - status_printf() is just like color_fprintf() but it adds a "# "
         at the beginning of each line of output;
      
       - status_printf_ln() is a convenience function that additionally
         adds "\n" at the end;
      
       - status_printf_more() is a variant of status_printf() used to
         continue lines that have already started.  It suppresses the "#" at
         the beginning of the first line.
      Helped-by: NJunio C Hamano <gitster@pobox.com>
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      e0335fcd
    • J
      compat: fall back on __va_copy if available · 26db0f2e
      Jonathan Nieder 提交于
      Since an obvious implementation of va_list is to make it a pointer
      into the stack frame, implementing va_copy as "dst = src" will work on
      many systems.  Platforms that use something different (e.g., a size-1
      array of structs, to be assigned with *(dst) = *(src)) will need some
      other compatibility macro, though.
      
      Luckily, as the glibc manual hints, such systems tend to provide the
      __va_copy macro (introduced in GCC in March, 1997).  By using that if
      it is available, we can cover our bases pretty well.
      
      Discovered by building with CC="gcc -std=c89" on an amd64 machine:
      
       $ make CC=c89 strbuf.o
       [...]
       strbuf.c: In function 'strbuf_vaddf':
       strbuf.c:211:2: error: incompatible types when assigning to type 'va_list'
        from type 'struct __va_list_tag *'
       make: *** [strbuf.o] Error 1
      Explained-by: NJunio C Hamano <gitster@pobox.com>
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      26db0f2e
  3. 26 2月, 2011 2 次提交
  4. 23 2月, 2011 2 次提交