git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [BUG] :(attr) pathspecs can die("BUG") in the tree-walker
@ 2017-05-09 22:24 Jeff King
  2017-05-09 22:52 ` Brandon Williams
  0 siblings, 1 reply; 3+ messages in thread
From: Jeff King @ 2017-05-09 22:24 UTC (permalink / raw)
  To: Brandon Williams; +Cc: git

I was playing with the new :(attr) pathspecs in the upcoming v2.13
today, and noticed:

  $ git ls-files -- ':(attr:-diff)'
  t/t0110/url-1
  t/t0110/url-10
  [etc]

So far so good.

  $ git ls-tree HEAD -- ':(attr:-diff)'
  fatal: :(attr:-diff): pathspec magic not supported by this command: 'attr'

Bummer, but I understand that sometimes the options need to be plumbed
through to work everywhere.

  $ 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.

-Peff

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [BUG] :(attr) pathspecs can die("BUG") in the tree-walker
  2017-05-09 22:24 [BUG] :(attr) pathspecs can die("BUG") in the tree-walker Jeff King
@ 2017-05-09 22:52 ` Brandon Williams
  2017-05-10  1:25   ` Jeff King
  0 siblings, 1 reply; 3+ messages in thread
From: Brandon Williams @ 2017-05-09 22:52 UTC (permalink / raw)
  To: Jeff King; +Cc: git

On 05/09, Jeff King wrote:
> I was playing with the new :(attr) pathspecs in the upcoming v2.13
> today, and noticed:
> 
>   $ git ls-files -- ':(attr:-diff)'
>   t/t0110/url-1
>   t/t0110/url-10
>   [etc]
> 
> So far so good.
> 
>   $ git ls-tree HEAD -- ':(attr:-diff)'
>   fatal: :(attr:-diff): pathspec magic not supported by this command: 'attr'
> 
> Bummer, but I understand that sometimes the options need to be plumbed
> through to work everywhere.
> 
>   $ 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.
> 
> -Peff

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.

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.

-- 
Brandon Williams

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [BUG] :(attr) pathspecs can die("BUG") in the tree-walker
  2017-05-09 22:52 ` Brandon Williams
@ 2017-05-10  1:25   ` Jeff King
  0 siblings, 0 replies; 3+ messages in thread
From: Jeff King @ 2017-05-10  1:25 UTC (permalink / raw)
  To: Brandon Williams; +Cc: git

On Tue, May 09, 2017 at 03:52:19PM -0700, Brandon Williams wrote:

> >   $ 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-05-10  1:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-09 22:24 [BUG] :(attr) pathspecs can die("BUG") in the tree-walker Jeff King
2017-05-09 22:52 ` Brandon Williams
2017-05-10  1:25   ` Jeff King

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).