All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiang Xin <worldhello.net@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: "Git List" <git@vger.kernel.org>,
	"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
	"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>,
	"Jonathan Nieder" <jrnieder@gmail.com>,
	"Jiang Xin" <worldhello.net@gmail.com>,
	"Andreas Schwab" <schwab@linux-m68k.org>
Subject: [PATCH 2/2] i18n: Add extra -- to seperate gettext and message
Date: Mon,  4 Jun 2012 07:09:27 +0800	[thread overview]
Message-ID: <1338764967-30103-2-git-send-email-worldhello.net@gmail.com> (raw)
In-Reply-To: <1338764967-30103-1-git-send-email-worldhello.net@gmail.com>

In commit b9b9c22, Ævar addressed a issue when gettextized a message
started with "--", such as "--cached cannot be used with --files", the
first word in the message would be treated as an option of gettext, and
might raise a bad option error.

The solution Ævar provided is to add a extra "--" option between gettext
and the message. But Vincent fount out later that the extra "--" was
extracted as gettext message by xgettext instead of the real message.
See:

 * http://thread.gmane.org/gmane.comp.version-control.git/199042

In order to fix this dilemma, we move the extra "--" option from gettext
to gettext wrapper (gettextln, and eval_gettext), and gettextize the
message using the wrapper function instead of gettext itself.

But for system with libintl's gettext.sh, eval_gettext and
eval_gettextln won't have this fix.

Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
Signed-off-by: Andreas Schwab <schwab@linux-m68k.org>
---
 git-sh-i18n.sh   | 8 ++++++--
 git-submodule.sh | 2 +-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/git-sh-i18n.sh b/git-sh-i18n.sh
index 6a27f..1c61e4 100644
--- a/git-sh-i18n.sh
+++ b/git-sh-i18n.sh
@@ -49,7 +49,7 @@ gnu)
 gettext_without_eval_gettext)
 	# Solaris has a gettext(1) but no eval_gettext(1)
 	eval_gettext () {
-		gettext "$1" | (
+		gettext -- "$1" | (
 			export PATH $(git sh-i18n--envsubst --variables "$1");
 			git sh-i18n--envsubst "$1"
 		)
@@ -68,10 +68,14 @@ poison)
 	;;
 *)
 	gettext () {
+		# Bypass options, such as '--'.
+		shift $(($# - 1))
 		printf "%s" "$1"
 	}
 
 	eval_gettext () {
+		# Bypass options, such as '--'.
+		shift $(($# - 1))
 		printf "%s" "$1" | (
 			export PATH $(git sh-i18n--envsubst --variables "$1");
 			git sh-i18n--envsubst "$1"
@@ -82,7 +86,7 @@ esac
 
 # Git-specific wrapper functions
 gettextln () {
-	gettext "$1"
+	gettext -- "$1"
 	echo
 }
 
diff --git a/git-submodule.sh b/git-submodule.sh
index 5c61a..bb9f6 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -710,7 +710,7 @@ cmd_summary() {
 	if [ -n "$files" ]
 	then
 		test -n "$cached" &&
-		die "$(gettext -- "--cached cannot be used with --files")"
+		die "$(gettextln "--cached cannot be used with --files")"
 		diff_cmd=diff-files
 		head=
 	fi
-- 
1.7.10.2.559.g0ba0f00

  reply	other threads:[~2012-06-03 23:09 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-03 23:09 [PATCH 1/2] i18n: Extract msgs marked by sh gettext wrappers Jiang Xin
2012-06-03 23:09 ` Jiang Xin [this message]
2012-06-04  8:56   ` [PATCH 2/2] i18n: Add extra -- to seperate gettext and message Ævar Arnfjörð Bjarmason
2012-06-04 13:55     ` Jiang Xin
2012-06-04 16:59       ` Junio C Hamano
2012-06-15 16:05         ` Jiang Xin
2012-06-15 17:41           ` Jonathan Nieder
2012-06-15 18:13             ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1338764967-30103-2-git-send-email-worldhello.net@gmail.com \
    --to=worldhello.net@gmail.com \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jrnieder@gmail.com \
    --cc=pclouds@gmail.com \
    --cc=schwab@linux-m68k.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.