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

Re: [PATCH] Speedup scanning for excluded files.

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 30, 2007, 00:00 UTC
Message-ID
<7vzly1sc7p.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<118833cc0710291559kbd874a8o8111b9495090ef27@mail.gmail.com>
"Morten Welinder" <mwelinder@gmail.com> writes:
Show 5 quoted lines
>> +                               } else if (x->flags & EXC_FLAG_ENDSWITH) {
>> +                                       if (!strcmp(exclude + 1, pathname + pathlen -x->patternlen + 1))
>
> Is there some guarantee that the result of that subtraction is still within
> the string?
Good eyes.

If pattern is "*.exe", patternlen is 5, and strcmp wants to compare 4 chars, so pathlen is better be at least that long, and we do allow that pattern to match a hidden file ".exe".

Like this?
	if (x->patternlen - 1 <= pathlen &&
        	!strcmp(exclude + 1, pathname + pathlen - x->patternlen + 1))
		return to_exclude;
Previous: Morten WelinderNext: Lars Knoll
Message 6 of 8 in “Speedup scanning for excluded files.”
  1. Speedup scanning for excluded files.Lars Knoll, Oct 29, 2007
  2. Pierre HabouzitOct 29, 2007
  3. Lars KnollOct 29, 2007
  4. Junio C HamanoOct 29, 2007
  5. Morten WelinderOct 29, 2007
  6. Junio C HamanoOct 30, 2007
  7. Lars KnollOct 30, 2007
  8. Speedup scanning for excluded files.Lars Knoll, Oct 30, 2007

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.