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

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

From
Junio C Hamano <junkio@cox.net>
Date
Sep 28, 2006, 00:09 UTC
Message-ID
<7vac4k97if.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<Pine.LNX.4.63.0609271315470.14200@wbgn013.biozentrum.uni-wuerzburg.de>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 28 quoted lines
> 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).

Previous: Johannes SchindelinNext: Johannes Schindelin
Message 2 of 5 in “runstatus: do not recurse into subdirectories if not needed”
  1. runstatus: do not recurse into subdirectories if not neededJohannes Schindelin, Sep 27, 2006
  2. Junio C HamanoSep 28, 2006
  3. Johannes SchindelinSep 28, 2006
  4. runstatus: do not recurse into subdirectories if not neededJohannes Schindelin, Sep 28, 2006
  5. Junio C HamanoSep 28, 2006

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.