From: Junio C Hamano <gitster@pobox.com>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Cc: Jeff King <peff@peff.net>, Robin Dupret <robin.dupret@gmail.com>,
git@vger.kernel.org, Robin Dupret <robin.dupret@hey.com>
Subject: Re: [PATCH] http-backend: remove a duplicated code branch
Date: Tue, 12 Oct 2021 10:18:01 -0700 [thread overview]
Message-ID: <xmqqbl3u5fhy.fsf@gitster.g> (raw)
In-Reply-To: <8735p6li20.fsf@evledraar.gmail.com> ("Ævar Arnfjörð Bjarmason"'s message of "Tue, 12 Oct 2021 11:07:55 +0200")
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
> diff --git a/http-backend.c b/http-backend.c
> index e7c0eeab230..13bc421b4e8 100644
> --- a/http-backend.c
> +++ b/http-backend.c
> @@ -462,19 +462,19 @@ static void run_service(const char **argv, int buffer_input)
> const char *encoding = getenv("HTTP_CONTENT_ENCODING");
> const char *user = getenv("REMOTE_USER");
> const char *host = getenv("REMOTE_ADDR");
> - int gzipped_request = 0;
> + int gzipped_request;
> struct child_process cld = CHILD_PROCESS_INIT;
> ssize_t req_len = get_content_length();
>
> - if (encoding && !strcmp(encoding, "gzip"))
> - gzipped_request = 1;
> - else if (encoding && !strcmp(encoding, "x-gzip"))
> - gzipped_request = 1;
> -
> if (!user || !*user)
> user = "anonymous";
> if (!host || !*host)
> host = "(none)";
> + if (!encoding)
> + encoding = "";
> +
> + gzipped_request = (!strcmp(encoding, "gzip") ||
> + !strcmp(encoding, "x-gzip"))
In general, I'd frown upon such a conversion. In the the current
code, "encoding" might go dead after this point, but we are losing
information for no good reason by making !encoding and !*encoding
indistinguisable after this point. Compared to that, the rewrite in
the patch that started this discussion would be more preferrable.
Thanks.
next prev parent reply other threads:[~2021-10-12 17:18 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-11 19:25 [PATCH] http-backend: remove a duplicated code branch Robin Dupret
2021-10-11 19:25 ` Robin Dupret
2021-10-12 2:27 ` Jeff King
2021-10-12 9:07 ` Ævar Arnfjörð Bjarmason
2021-10-12 17:18 ` Junio C Hamano [this message]
[not found] ` <20211024162859.6295-1-robin.dupret@hey.com>
2021-10-24 16:28 ` Robin Dupret
2021-10-25 15:55 ` Junio C Hamano
2021-10-26 19:04 ` Robin Dupret
2021-10-12 17:15 ` Junio C Hamano
-- strict thread matches above, loose matches on Subject: below --
2021-10-24 17:23 Robin Dupret
2021-10-24 17:29 ` Robin Dupret
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=xmqqbl3u5fhy.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
--cc=robin.dupret@gmail.com \
--cc=robin.dupret@hey.com \
/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).