Re: [PATCH v2] read_directory: avoid invoking exclude machinery on tracked files
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Feb 17, 2013, 23:18 UTC
- Message-ID
- <7vvc9qedh2.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <1360999078-27196-1-git-send-email-pclouds@gmail.com>
Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
Show 8 quoted lines
> If path_handled is returned, contents goes up. And if check_only is > true, the loop could be broken early. These will not happen when > treat_one_path (and its wrapper treat_path) returns > path_ignored. dir_add_name internally does a cache_name_exists() check > so it makes no difference. > > To avoid this behavior change, treat_one_path is instructed to skip > the optimization when check_only or contents is used.
OK, that makes more understandable why this is safe.
Show 18 quoted lines
> @@ -1242,9 +1246,23 @@ enum path_treatment {
> static enum path_treatment treat_one_path(struct dir_struct *dir,
> struct strbuf *path,
> const struct path_simplify *simplify,
> - int dtype, struct dirent *de)
> + int dtype, struct dirent *de,
> + int exclude_shortcut_ok)
> {
> ...
> @@ -1331,18 +1347,29 @@ static int read_directory_recursive(struct dir_struct *dir,
> goto out;
>
> while ((de = readdir(fdir)) != NULL) {
> - switch (treat_path(dir, de, &path, baselen, simplify)) {
> + switch (treat_path(dir, de, &path, baselen,
> + simplify,
> + !check_only && !contents)) {
> ...Between these two places we may want to say what kind of short-cut we are talking about, but there only is one kind of short-cut at this moment, so let's leave that to other people who want to further optimize things in this codepath by adding other short-cuts.
Thanks; will queue.