git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: VenomVendor <info@venomvendor.com>,
	Junio C Hamano <gitster@pobox.com>,
	Phillip Wood <phillip.wood@dunelm.org.uk>,
	git@vger.kernel.org
Subject: Re: [PATCH 4/3] am, sequencer: stop parsing our own committer ident
Date: Tue, 27 Oct 2020 03:23:09 -0400	[thread overview]
Message-ID: <20201027072309.GE3005508@coredump.intra.peff.net> (raw)
In-Reply-To: <nycvar.QRO.7.76.6.2010261722230.56@tvgsbejvaqbjf.bet>

On Mon, Oct 26, 2020 at 05:25:01PM +0100, Johannes Schindelin wrote:

> On Fri, 23 Oct 2020, Jeff King wrote:
> 
> > diff --git a/ident.c b/ident.c
> > index 6aba4b5cb6..7743c1ed05 100644
> > --- a/ident.c
> > +++ b/ident.c
> > @@ -384,6 +384,12 @@ const char *fmt_ident(const char *name, const char *email,
> >  	struct strbuf *ident = &ident_pool[index];
> >  	index = (index + 1) % ARRAY_SIZE(ident_pool);
> >
> > +	if (!email) {
> > +		if (whose_ident == WANT_AUTHOR_IDENT)
> > +			email = getenv("GIT_AUTHOR_EMAIL");
> > +		else if (whose_ident == WANT_COMMITTER_IDENT)
> > +			email = getenv("GIT_COMMITTER_EMAIL");
> 
> I *guess* that this is a strict improvement, calling `getenv()` much
> closer to the time the value is actually used (and hence avoiding the
> problem where pointers returned by `getenv()` get stale due to environment
> changes).

I don't think it changes much in practice. Most of the callers are
passing the values directly in to this function, and there's not much
that happens between the function starting and these calls.

The more worrisome stretch is that we likely call strbuf functions while
holding on to a getenv() pointer. And those potentially do things like
xmalloc(), which looks at GIT_ALLOC_LIMIT, etc. But though POSIX
promises only one getenv() result at a time, we definitely don't adhere
to that (after all, we routinely pass the results of three separate
getenv() calls to fmt_ident!). As you well know, because mingw_getenv()
has a circular buffer hack to deal with this. :)

So it certainly isn't making anything worse, but I'd be surprised if it
actually helped at all.

-Peff

  reply	other threads:[~2020-10-27  7:23 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-23  5:48 committer-date-is-author-date flag removes email in "Commit" VenomVendor
2020-10-23  7:07 ` Jeff King
2020-10-23  7:08   ` [PATCH 1/3] t3436: check --committer-date-is-author-date result more carefully Jeff King
2020-10-23 10:10     ` Phillip Wood
2020-10-23  7:09   ` [PATCH 2/3] am: fix broken email with --committer-date-is-author-date Jeff King
2020-10-23  7:26     ` [PATCH 4/3] am, sequencer: stop parsing our own committer ident Jeff King
2020-10-23  7:45       ` Jeff King
2020-10-23 17:29         ` Taylor Blau
2020-10-26 16:25         ` Johannes Schindelin
2020-10-27  7:23           ` Jeff King [this message]
2020-10-23 14:06       ` Phillip Wood
2020-10-26 17:12       ` Junio C Hamano
2020-10-27  7:24         ` Jeff King
2020-10-23  7:10   ` [PATCH 3/3] rebase: fix broken email with --committer-date-is-author-date Jeff King
2020-10-23 15:23   ` committer-date-is-author-date flag removes email in "Commit" Junio C Hamano
2020-10-23 17:32     ` Phillip Wood
2020-10-23 17:59       ` 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=20201027072309.GE3005508@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=info@venomvendor.com \
    --cc=phillip.wood@dunelm.org.uk \
    /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).