git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: William Strecker-Kellogg <willsk@bnl.gov>,
	Git List <git@vger.kernel.org>,
	spearce@spearce.org
Subject: Re: [PATCH] Make http-backend REMOTE_USER configurable
Date: Thu, 29 Mar 2012 18:26:32 -0400	[thread overview]
Message-ID: <20120329222632.GC1413@sigill.intra.peff.net> (raw)
In-Reply-To: <20120329222230.GB1413@sigill.intra.peff.net>

On Thu, Mar 29, 2012 at 06:22:30PM -0400, Jeff King wrote:

> I think an even better thing would be for http-backend to leave
> GIT_COMMITTER_* alone if it exists; that is the usual well-known
> interface for setting such things. And then you could specify a
> detailed committer name and email if you want, or leave them blank to
> pull from $REMOTE_USER as we do now. As it is now, even if you specify
> GIT_COMMITTER_EMAIL, it gets overwritten with
> "$REMOTE_USER@http.$REMOTE_ADDR".

That patch would look something like this:

---
diff --git a/http-backend.c b/http-backend.c
index 869d515..aa892e6 100644
--- a/http-backend.c
+++ b/http-backend.c
@@ -318,7 +318,7 @@ static void run_service(const char **argv)
 	const char *user = getenv("REMOTE_USER");
 	const char *host = getenv("REMOTE_ADDR");
 	char *env[3];
-	struct strbuf buf = STRBUF_INIT;
+	int num_env = 0;
 	int gzipped_request = 0;
 	struct child_process cld;
 
@@ -332,13 +332,17 @@ static void run_service(const char **argv)
 	if (!host || !*host)
 		host = "(none)";
 
-	memset(&env, 0, sizeof(env));
-	strbuf_addf(&buf, "GIT_COMMITTER_NAME=%s", user);
-	env[0] = strbuf_detach(&buf, NULL);
-
-	strbuf_addf(&buf, "GIT_COMMITTER_EMAIL=%s@http.%s", user, host);
-	env[1] = strbuf_detach(&buf, NULL);
-	env[2] = NULL;
+	if (!getenv("GIT_COMMITTER_NAME")) {
+		struct strbuf buf = STRBUF_INIT;
+		strbuf_addf(&buf, "GIT_COMMITTER_NAME=%s", user);
+		env[num_env++] = strbuf_detach(&buf, NULL);
+	}
+	if (!getenv("GIT_COMMITTER_EMAIL")) {
+		struct strbuf buf = STRBUF_INIT;
+		strbuf_addf(&buf, "GIT_COMMITTER_EMAIL=%s@http.%s", user, host);
+		env[num_env++] = strbuf_detach(&buf, NULL);
+	}
+	env[num_env] = NULL;
 
 	memset(&cld, 0, sizeof(cld));
 	cld.argv = argv;
@@ -359,7 +363,6 @@ static void run_service(const char **argv)
 		exit(1);
 	free(env[0]);
 	free(env[1]);
-	strbuf_release(&buf);
 }
 
 static int show_text_ref(const char *name, const unsigned char *sha1,

  reply	other threads:[~2012-03-29 22:26 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-29 19:58 [PATCH] Make http-backend REMOTE_USER configurable William Strecker-Kellogg
2012-03-29 22:02 ` Junio C Hamano
2012-03-29 22:22   ` Jeff King
2012-03-29 22:26     ` Jeff King [this message]
2012-03-30  1:52       ` Junio C Hamano
2012-03-30  3:24         ` William Strecker-Kellogg
2012-03-30  7:01         ` Jeff King
2012-03-30 16: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=20120329222632.GC1413@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=spearce@spearce.org \
    --cc=willsk@bnl.gov \
    /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).