git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Li Linchao via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Jonathan Tan <jonathantanmy@google.com>,
	Johannes Schindelin <Johannes.Schindelin@gmx.de>,
	Li Linchao <lilinchao@oschina.cn>
Subject: Re: [PATCH] remote-curl: send Accept-Language header to server
Date: Wed, 08 Jun 2022 16:32:06 -0700	[thread overview]
Message-ID: <xmqqa6amohop.fsf@gitster.g> (raw)
In-Reply-To: <pull.1251.git.1654678407365.gitgitgadget@gmail.com> (Li Linchao via GitGitGadget's message of "Wed, 08 Jun 2022 08:53:27 +0000")

"Li Linchao via GitGitGadget" <gitgitgadget@gmail.com> writes:

> From: Cactusinhand <lilinchao@oschina.cn>

Huh? 

> Git server end's ability to accept Accept-Language header was introduced
> in f18604bbf2(http: add Accept-Language header if possible), but this is
> only used by very early phase of the transfer, that's HTTP GET request to
> discover references. For other phases, like POST request in the smart HTTP
> the server side don't know what language client speak.

"client speak" -> "the client speaks".

> This patch teaches git client to learn end-user's preferred language and

"This patch teaches" -> "Teach"

> throw accept-language header to server side. Once server get this header

"server side" -> "the server side".
"server get" -> "the server gets"
"header" -> "header,"

> it have ability to talk to end-user with language they understand, this

"it have ability" -> "it has the ability"

", this" -> ". This"

> would be very helpful for many non-English speakers.
>
> Signed-off-by: Li Linchao <lilinchao@oschina.cn>

> diff --git a/http.c b/http.c
> index 11c6f69facd..0654e111d1d 100644
> --- a/http.c
> +++ b/http.c
> @@ -1775,7 +1775,7 @@ static void write_accept_language(struct strbuf *buf)
>   *   LANGUAGE= LANG=en_US.UTF-8 -> "Accept-Language: en-US, *; q=0.1"
>   *   LANGUAGE= LANG=C -> ""
>   */
> -static const char *get_accept_language(void)
> +const char *get_accept_language(void)

It was an understandable name for a file-scope static function, but
is this name suitable to be a global without making it more narrow
and specific to "HTTP" and "Header"?

> diff --git a/remote-curl.c b/remote-curl.c
> index 67f178b1120..8acf506705c 100644
> --- a/remote-curl.c
> +++ b/remote-curl.c
> @@ -1400,7 +1412,7 @@ static int stateless_connect(const char *service_name)
>  	struct discovery *discover;
>  	struct rpc_state rpc;
>  	struct strbuf buf = STRBUF_INIT;
> -
> +	const char *accept_language;

Do not lose the blank line after the block with variable
declarations.  IOW, the patch around this line should read like this
instead:

>  	struct discovery *discover;
>  	struct rpc_state rpc;
>  	struct strbuf buf = STRBUF_INIT;
> +	const char *accept_language;
>
>  	/*
>  	 * Run the info/refs request and see if the server supports protocol


> @@ -1418,6 +1430,10 @@ static int stateless_connect(const char *service_name)
>  		printf("\n");
>  		fflush(stdout);
>  	}
> +	accept_language = get_accept_language();
> +	if (accept_language) {
> +		rpc.hdr_accept_language = xstrfmt("%s", accept_language);
> +	}

Drop {} around a single-statement block.

> +	cat >exp <<-\EOF &&
> +	=> Send header: Accept-Language: zh-CN, en;q=0.9, *;q=0.8
> +	=> Send header: Accept-Language: zh-CN, en;q=0.9, *;q=0.8
> +	EOF
> +
> +	cd "$ROOT_PATH"/test_repo_clone &&
> +	: >path_lang &&
> +	git add path_lang &&
> +	test_tick &&
> +	git commit -m path_lang &&
> +	HEAD=$(git rev-parse --verify HEAD) &&
> +	GIT_TRACE_CURL=true LANGUAGE="zh_CN:en" git push -v -v 2>err &&

A few comments.

 * In all gettext/locale tests we seem to set both LANGUAGE and
   LC_ALL environment variables.  Shouldn't we do the same for
   consistency?

 * In existing tests, we seem to use ko_KR, en_US, ja_JP, and random
   assortment of languages (e.g. t5550).  Can we safely add any new
   languages to the mix without any downside to the tester?  We
   should reuse what we already use, especially if this ends up
   forcing users and testers to install yet another "language pack"
   for zh_CN.

Thanks.

  reply	other threads:[~2022-06-08 23:32 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-08  8:53 [PATCH] remote-curl: send Accept-Language header to server Li Linchao via GitGitGadget
2022-06-08 23:32 ` Junio C Hamano [this message]
2022-06-09  6:35 ` [PATCH v2] " Li Linchao via GitGitGadget
2022-06-09 23:55   ` Junio C Hamano
2022-06-10  3:49     ` lilinchao
2022-06-10  4:22       ` lilinchao
2022-06-12 17:20   ` [PATCH v3] " Li Linchao via GitGitGadget
2022-06-13 18:15     ` Junio C Hamano
2022-06-13 21:32     ` Junio C Hamano
2022-06-13 22:08       ` Junio C Hamano
2022-06-13 22:15         ` Junio C Hamano
2022-07-11  5:58     ` [PATCH v4] " Li Linchao via GitGitGadget
2022-06-09  7:30 ` [PATCH] " Ævar Arnfjörð Bjarmason
2022-06-09 17:34   ` Junio C Hamano
2022-06-10  2:38   ` lilinchao
2022-07-03  0:57     ` Junio C Hamano
2022-07-05 10:06       ` lilinchao
2022-07-05 10:15         ` Ævar Arnfjörð Bjarmason
2022-07-05 18:06           ` Junio C Hamano
2022-07-05 17:53         ` 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=xmqqa6amohop.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=jonathantanmy@google.com \
    --cc=lilinchao@oschina.cn \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).