git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Michael Haggerty <mhagger@alum.mit.edu>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 0/2] config includes, take 2
Date: Mon, 6 Feb 2012 05:16:30 -0500	[thread overview]
Message-ID: <20120206101630.GA5394@sigill.intra.peff.net> (raw)
In-Reply-To: <20120206100622.GC4300@sigill.intra.peff.net>

On Mon, Feb 06, 2012 at 05:06:22AM -0500, Jeff King wrote:

> > If that is the goal, all you have to record is the "include stack"
> > context that caused the currently-being-included file to be read and
> > make sure that the currently-being-included file didn't appear earlier
> > on the stack.  The fact that the same file was included earlier (but
> > not as part of the same include chain) needn't be considered an error.
> 
> I considered this, but decided the complexity wasn't worth it,
> especially because getting it accurate means cooperation from
> git_config_from_file, which otherwise doesn't know or care about this
> mechanism. Instead I keep a simple depth counter and barf at a
> reasonable maximum, printing the "from" and "to" files. Yes, it's not
> nearly as elegant as keeping the whole stack, but I really don't expect
> people to have complex super-deep includes, nor for it to be difficult
> to hunt down the cause of a cycle.

Oh, one other thing: to detect cycles, you have to use a canonical
version of the filename for comparisons. That makes the existing stack
that git_config_from_file keeps useless. Using real_path is hard,
because it will die() if some path components don't exist. Using
absolute_path is a reasonable compromise, but it can actually miss some
cycles if they involve symbolic links.

Not insurmountable if you can accept teaching git_config_from_file to
real_path() each file it reads. But again, it ends up getting complex
for IMHO not much gain. A stupid depth counter can't show you a stack
trace (and it may have false positives), but it's dirt simple and
probably good enough.

-Peff

  reply	other threads:[~2012-02-06 10:16 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-06  6:27 [PATCH 0/2] config includes, take 2 Jeff King
2012-02-06  6:29 ` [PATCH 1/2] imap-send: remove dead code Jeff King
2012-02-06  6:31 ` [PATCH 2/2] config: add include directive Jeff King
2012-02-06  7:41 ` [PATCH 0/2] config includes, take 2 Junio C Hamano
2012-02-06  9:53 ` Michael Haggerty
2012-02-06 10:06   ` Jeff King
2012-02-06 10:16     ` Jeff King [this message]
2012-02-07  5:01 ` David Aguilar
2012-02-07  5:17   ` Jeff King
2012-02-07 10:05     ` David Aguilar
2012-02-07 17:30       ` Jeff King
2012-02-07 18:03         ` Junio C Hamano
2012-02-07 18:29           ` Jeff King
2012-02-07 19:16         ` Jakub Narebski
2012-02-07 19:21           ` Jeff King
2012-02-07 20:15           ` David Aguilar
2012-02-09  3:30           ` Jeff King
2012-02-09 19:24             ` Jakub Narebski
2012-02-09 19:33               ` Jeff King

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=20120206101630.GA5394@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=mhagger@alum.mit.edu \
    /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).