Re: [PATCH] runstatus: do not recurse into subdirectories if not needed

From: Junio C Hamano <junkio@cox.net>
Date: 2006-09-28 10:09:28
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:

> This speeds up the case when you run git-status, having an untracked
> subdirectory containing huge amounts of files.
>
> It also clarifies the handling of hide_empty_directories; the old version
> worked, but was hard to understand.
>
> Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
> ---
>  dir.c |   24 +++++++++++++++---------
>  1 files changed, 15 insertions(+), 9 deletions(-)
>
> diff --git a/dir.c b/dir.c
> index e2f472b..e69663c 100644
> --- a/dir.c
> +++ b/dir.c
> @@ -274,6 +274,15 @@ static int dir_exists(const char *dirnam
>  	return !strncmp(active_cache[pos]->name, dirname, len);
>  }
>  
> +static int dir_is_empty(const char *dirname)
> +{
> +	DIR *fdir = opendir(dirname);
> +	int result = (readdir(fdir) == NULL);
> +
> +	closedir(fdir);
> +	return result;
> +}
> +

Does this really check if the directory is empty (I think you
would read "." and ".." out of it at least)?

When the original code recurses into subdirectory, it seems to
behave identically for a truly empty directory and a directory
that has only ".git" (or excluded files in it under !show_ignored).

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Received on Thu Sep 28 10:09:57 2006

This archive was generated by hypermail 2.1.8 : 2006-09-28 10:10:52 EST