Re: [PATCH] config: add conditional include
- From
Jeff King <peff@peff.net>
- Date
- Jun 27, 2016, 16:20 UTC
- Message-ID
- <20160627162052.GA4532@sigill.intra.peff.net>
- In-Reply-To
- <CACsJy8DAMe3YH-f_Qm8FEmanXepnwF2z1L6DDGoJf1eysmW2xQ@mail.gmail.com>
On Mon, Jun 27, 2016 at 06:14:17PM +0200, Duy Nguyen wrote:
Show 15 quoted lines
> >> + } else if (!strchr(pattern.buf, '/')) {
> >> + /* no slashes match one directory component */
> >> + strbuf_insert(&pattern, 0, "**/", 3);
> >> + strbuf_addstr(&pattern, "/**");
> >> + }
> >
> > I guess it's a little funny that "foo" and "foo/bar" are matched quite
> > differently. I wonder if a simpler rule would just be: relative paths
> > are unanchored.
>
> I modeled it after .gitignore patterns, but that's probably not a good
> fit here. Making all relative paths un-anchored means I can't say
> "paths that end with this suffix". How useful that statement is, I
> can't say though. Or if you mean only prepend "**/" to relative paths,
> not "/**" then that door is still open.I didn't really mean anything, as I had not thought about it that carefully. :)
You do allow distinguishing the suffix thing with "/" at the end in the rule above, though. So between the two rules:
- slash at the end is a shorthand for "/**"
- no-slash at the beginning (i.e., a non-absolute path) is a shorthand
for "**/" at the beginningyou should be able to specify anything.
I do agree that there's value in trying to make the rules consistent with other parts of git, though. I don't know the corner cases of gitignore and gitattributes well enough to compare off the top of my head, though (though I suspect you do. :) ).
-Peff