From: Jeff King <peff@peff.net>
To: Johannes Sixt <j.sixt@viscovery.net>
Cc: Mike Frysinger <vapier.adi@gmail.com>,
Junio C Hamano <gitster@pobox.com>,
git@vger.kernel.org
Subject: Re: infinite loop in git-send-email with alias files
Date: Thu, 23 Jul 2009 09:54:09 -0400 [thread overview]
Message-ID: <20090723135408.GA22317@coredump.intra.peff.net> (raw)
In-Reply-To: <4A6857FF.5070401@viscovery.net>
On Thu, Jul 23, 2009 at 02:30:55PM +0200, Johannes Sixt wrote:
> Jeff King schrieb:
> > +my %EXPANDED_ALIASES;
> > +sub expand_one_alias {
> > + my $alias = shift;
> > + if ($EXPANDED_ALIASES{$alias}) {
> > + die "fatal: alias '$alias' expands to itself\n";
> > + }
> > + local $EXPANDED_ALIASES{$alias} = 1;
> > + return $aliases{$alias} ? expand_aliases(@{$aliases{$alias}}) : $alias;
>
> What does 'local' make local here? Only the assignment of the slot
> $EXPANDED_ALIASES{$alias}? Or the whole %EXPANDED_ALIASES? If the latter,
> does this copy the existing %EXPANDED_ALIASES before the assignment is
> made; otherwise, how can this work if only ever a single slot of
> %EXPANDED_ALIASES is filled in?
It localizes just that slot. But remember that 'local' is about
_dynamic_ scoping, not _lexical_ scoping. So that slot is now set for
the duration of the expand_one_alias call, and is visible to its
subroutines (i.e., the recursive calls). So each level of recursion sets
one more field in $EXPANDED_ALIASES, and when we leave the function,
perl automatically restores it to its previous value.
-Peff
prev parent reply other threads:[~2009-07-23 13:54 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-17 1:10 infinite loop in git-send-email with alias files Mike Frysinger
2009-07-23 11:09 ` Jeff King
2009-07-23 12:30 ` Johannes Sixt
2009-07-23 13:54 ` Jeff King [this message]
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=20090723135408.GA22317@coredump.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=j.sixt@viscovery.net \
--cc=vapier.adi@gmail.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).