git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [BUG] :(attr) pathspecs can die("BUG") in the tree-walker

From
Jeff King <peff@peff.net>
Date
May 10, 2017, 01:25 UTC
Message-ID
<20170510012550.3qs3ra2c7ehbnixs@sigill.intra.peff.net>
In-Reply-To
<20170509225219.GB106700@google.com>
On Tue, May 09, 2017 at 03:52:19PM -0700, Brandon Williams wrote:
Show 14 quoted lines
> >   $ git log HEAD -- ':(attr:-diff)'
> >   fatal: BUG:tree-walk.c:947: unsupported magic 40
> > 
> > Whoops. This is presumably ls-tree is protected, but I think we are
> > missing a GUARD_PATHSPEC call somewhere.
> > 
> > This isn't a huge deal, as the correct behavior is probably to die like
> > ls-tree does, but we probably shouldn't be hitting BUG assertions as a
> > general rule.
> 
> The die("BUG: ..."); is from a GAURD_PATHSPEC call.  What really needs
> to happen is to update the magic_mask passed into the parse_pathspec
> call which initializes the pathspec object.  Its this magic_mask which
> catches unsupported magic and prints a better message.

Ah, right, I always get the pathspec safety bits mixed up. I think the parse_pathspec() call in setup_revisions is a bit permissive:

  parse_pathspec(&revs->prune_data, 0, 0,
		 revs->prefix, prune_data.path);

You _shouldn't_ need to audit all the callers when you add new pathspec magic. The callers should be masking out the bits that they know they support, but this one isn't. It looks like there are a number of such permissive calls, though. I guess it was an attempt to not have to list them manually at each call site (but then we suffer from the exact problem I ran into).

> I guess this means I (or someone else :D) should audit all the
> parse_pathspec calls and ensure that 'attr' magic is turned off until we
> won't run into these GAURD_PATHSPEC die's.

Of course it would be nicer still if the 'attr' magic actually worked via the tree-walking code. :)

-Peff
Previous: Brandon Williams
Message 3 of 3 in “[BUG] :(attr) pathspecs can die("BUG") in the tree-walker”
  1. Jeff KingMay 9, 2017
  2. Brandon WilliamsMay 9, 2017
  3. Jeff KingMay 10, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.