All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Junio C Hamano <gitster@pobox.com>, Jeff King <peff@peff.net>,
	Michael J Gruber <git@drmicha.warpmail.net>,
	Jon Schewe <jpschewe@mtu.net>,
	spearce@spearce.org, git@vger.kernel.org
Subject: Re: [PATCH] ls-files: fix overeager pathspec optimization
Date: Fri, 08 Jan 2010 15:31:36 -0800	[thread overview]
Message-ID: <7vwrzsp413.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <alpine.LFD.2.00.1001081520240.7821@localhost.localdomain> (Linus Torvalds's message of "Fri\, 8 Jan 2010 15\:24\:13 -0800 \(PST\)")

Linus Torvalds <torvalds@linux-foundation.org> writes:

> On Fri, 8 Jan 2010, Junio C Hamano wrote:
>>
>> Given pathspecs that share a common prefix, ls-files optimized its call
>> into recursive directory reader by starting at the common prefix
>> directory.
>> 
>> If you have a directory "t" with an untracked file "t/junk" in it, but the
>> top-level .gitignore file told us to ignore "t/", this resulted in an
>> unexpected behaviour:
>
> Ok, I'm not sure how "unexpected" this is, since arguably you are 
> overriding the ignore file by _being_ in that directory (the same way 
> index contents override ignore files), but I could go either way on that.
>
> Your patch looks fine, although I think you did this in a very odd way.
>
>> +	at = 0;
>> +	memcpy(path, path_, len);
>> +	while (1) {
>> +		char *cp;
>> +		path[at] = '\0';
>> +		/*
>> +		 * NOTE! NOTE! NOTE!: we might want to actually lstat(2)
>> +		 * path[] to make sure it is a directory.
>> +		 */
>> +		if (excluded(dir, path, &dtype))
>> +			return 1;
>
> The above starts by testing the empty string, and then after that test it 
> goes on to the next directory component. That is just _odd_.
>
> Wouldn't it be more natural to write the loop the other way around, ie 
> _first_ look up the next directory component, and _then_ do the exclude 
> processing for thoose components? 
>
> Or is there some subtle reason I'm missing for actually checking the empty 
> name?

No, just being paranoid in case somebody managed to .gitignore the
top-level of the working tree ;-)

  reply	other threads:[~2010-01-08 23:31 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-08 15:17 Possible bug in git-completion.sh Jon Schewe
2010-01-08 15:40 ` Michael J Gruber
2010-01-08 16:24   ` Jeff King
2010-01-08 16:38     ` Junio C Hamano
2010-01-08 16:41       ` Jeff King
2010-01-08 16:45         ` Junio C Hamano
2010-01-08 16:56           ` Junio C Hamano
2010-01-08 17:24             ` Jeff King
2010-01-08 17:21           ` Jeff King
2010-01-08 18:21           ` Junio C Hamano
2010-01-08 19:58             ` Junio C Hamano
2010-01-08 23:01               ` [PATCH] ls-files: fix overeager pathspec optimization Junio C Hamano
2010-01-08 23:24                 ` Linus Torvalds
2010-01-08 23:31                   ` Junio C Hamano [this message]
2010-01-09  0:06                   ` Junio C Hamano
2010-01-09  0:24                     ` Linus Torvalds
2010-01-09  0:54                       ` Junio C Hamano
2010-01-09  1:07                         ` Linus Torvalds
2010-01-09  5:42                           ` Jeff King
2010-01-09  7:16                           ` Junio C Hamano
2010-01-09  7:35                             ` [PATCH 1/4] t3001: test ls-files -o ignored/dir Junio C Hamano
2010-01-09  7:35                               ` [PATCH 2/4] read_directory_recursive(): refactor handling of a single path into a separate function Junio C Hamano
2010-01-09  7:35                               ` [PATCH 3/4] read_directory(): further split treat_path() Junio C Hamano
2010-01-09  7:35                               ` [PATCH 4/4] ls-files: fix overeager pathspec optimization Junio C Hamano
2010-01-12 16:33                                 ` Jeff King
2010-01-09  8:07                             ` [PATCH] " Junio C Hamano
2010-01-09 18:05                               ` Linus Torvalds
2010-01-10  6:31                                 ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vwrzsp413.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@drmicha.warpmail.net \
    --cc=git@vger.kernel.org \
    --cc=jpschewe@mtu.net \
    --cc=peff@peff.net \
    --cc=spearce@spearce.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.