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

Re: [PATCH 3/3] implement pattern matching in ce_path_match

From
Clemens Buchacher <drizzd@aon.at>
Date
Jan 14, 2009, 19:23 UTC
Message-ID
<20090114192341.GA26703@localhost>
In-Reply-To
<7vljtd20m6.fsf@gitster.siamese.dyndns.org>
On Wed, Jan 14, 2009 at 10:39:29AM -0800, Junio C Hamano wrote:
Show 8 quoted lines
> Clemens Buchacher <drizzd@aon.at> writes:
> 
> > With this patch ce_path_match uses match_pathspec in order to perform
> > pattern matching.
> 
> We have two conflicting definitions of pattern matching in our system.
> I'd make it more explicit which kind of pattern matching you are talking
> about here.
Right, will fix.
Show 9 quoted lines
> In the longer term we really should unify them by teaching the former to
> fall back to globbing without getting undue performance hit, and this
> patch may be a step in the right direction.  There are optimizations that
> assume the "leading path" semantics to trim the input early and avoid
> opening and descending into a tree object if pathspec patterns cannot
> possibly match (see tree-diff.c::tree_entry_interesting() for an example),
> and we need to teach them to notice a glob wildcard in an earlier part of
> a pathspec and to descend into some trees that they would have skipped
> with the old definition of pathspec.
I see. I can probably fix that this weekend.
Show 13 quoted lines
> > @@ -49,7 +60,7 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix,
> >  		rev->always_show_header = 0;
> >  	if (DIFF_OPT_TST(&rev->diffopt, FOLLOW_RENAMES)) {
> >  		rev->always_show_header = 0;
> > -		if (rev->diffopt.nr_paths != 1)
> > +		if (rev->diffopt.nr_paths != 1 || has_special(rev->diffopt.paths[0]))
> >  			usage("git logs can only follow renames on one pathname at a time");
> >  	}
> 
> The reason match_pathspec() first tries exact match and then falls back to
> globbing is so that the user can say "I have a file whose name ends with a
> question mark, please match it literally."  This patch defeats it, but it
> probably is a minor point.

I was wondering actually if we should disallow such paths altogether, since there would be no way to match only 'a?', if something like 'ab' also exists. So if you added 'a?' by accident, you cannot even remove it without also removing 'ab'.

I think we could at least add an option to disable globbing. Then we can also disable the above check conditioned on that. If we allowed globbing pattern for following renames wouldn't that result in following the first file (or last in history) to match the pattern, which is potentially confusing?

Previous: Junio C HamanoNext: Junio C Hamano
Message 11 of 16 in “fix "git add" pattern matching”
  1. 0/3 fix "git add" pattern matchingClemens Buchacher, Jan 14, 2009
  2. 1/3 clean up pathspec matchingClemens Buchacher, Jan 14, 2009
  3. 2/3 remove pathspec_match, use match_pathspec insteadClemens Buchacher, Jan 14, 2009
  4. 3/3 implement pattern matching in ce_path_matchClemens Buchacher, Jan 14, 2009
  5. Clemens BuchacherJan 14, 2009
  6. Johannes SchindelinJan 14, 2009
  7. Sverre RabbelierJan 14, 2009
  8. Samuel TardieuJan 14, 2009
  9. Jeff KingJan 14, 2009
  10. Junio C HamanoJan 14, 2009
  11. Clemens BuchacherJan 14, 2009
  12. Junio C HamanoJan 14, 2009
  13. Clemens BuchacherJan 15, 2009
  14. Junio C HamanoJan 16, 2009
  15. Johannes SchindelinJan 14, 2009
  16. Clemens BuchacherJan 14, 2009

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.