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

Re: [PATCH 5/5] dir.c: stop ignoring opendir() error in open_cached_dir()

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Feb 1, 2018, 23:00 UTC
Message-ID
<87d11omi2o.fsf@evledraar.gmail.com>
In-Reply-To
<20180124093023.9071-6-pclouds@gmail.com>
On Wed, Jan 24 2018, Nguyễn Thái Ngọc Duy jotted:
Show 33 quoted lines
> A follow-up to the recently fixed bugs in the untracked
> invalidation. If opendir() fails it should show a warning, perhaps
> this should die, but if this ever happens the error is probably
> recoverable for the user, and dying would just make things worse.
>
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
> ---
>  dir.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/dir.c b/dir.c
> index 44b4dd2ec8..55736d3e2a 100644
> --- a/dir.c
> +++ b/dir.c
> @@ -1787,11 +1787,16 @@ static int open_cached_dir(struct cached_dir *cdir,
>  			   struct strbuf *path,
>  			   int check_only)
>  {
> +	const char *c_path;
> +
>  	memset(cdir, 0, sizeof(*cdir));
>  	cdir->untracked = untracked;
>  	if (valid_cached_dir(dir, untracked, istate, path, check_only))
>  		return 0;
> -	cdir->fdir = opendir(path->len ? path->buf : ".");
> +	c_path = path->len ? path->buf : ".";
> +	cdir->fdir = opendir(c_path);
> +	if (!cdir->fdir)
> +		warning_errno(_("could not open directory '%s'"), c_path);
>  	if (dir->untracked) {
>  		invalidate_directory(dir->untracked, untracked);
>  		dir->untracked->dir_opened++;

I haven't found the root cause yet, but we should not release a 2.17 with this patch.

I tried deploying a 2.16.1 + various patches (including this) internally today, and on a test set of 236 machines with existing checkouts (already using untracked cache) 79 would spew "warning: could not open directory" warnings, warning about a lot of directories that did not exist at the currently checked-out commit.

The warnings go away on a one-off:
    git -c core.untrackedCache=false status

So there's some issue where an existing index with stale UC will be used by a newer version of git, and will start very verbosely warning about every directory referenced that can't be found anymore.

Previous: Nguyễn Thái Ngọc DuyNext: Ævar Arnfjörð Bjarmason
Message 10 of 12 in “dir.c: print correct errno when opendir() fails”
  1. dir.c: print correct errno when opendir() failsNguyễn Thái Ngọc Duy, Jan 18, 2018
  2. Junio C HamanoJan 19, 2018
  3. Duy NguyenJan 21, 2018
  4. 0/5 nd/fix-untracked-cache-invalidation updatesNguyễn Thái Ngọc Duy, Jan 24, 2018
  5. 1/5 status: add a failing test showing a core.untrackedCache bugNguyễn Thái Ngọc Duy, Jan 24, 2018
  6. 2/5 dir.c: avoid stat() in valid_cached_dir()Nguyễn Thái Ngọc Duy, Jan 24, 2018
  7. 3/5 dir.c: fix missing dir invalidation in untracked codeNguyễn Thái Ngọc Duy, Jan 24, 2018
  8. 4/5 update-index doc: note a fixed bug in the untracked cacheNguyễn Thái Ngọc Duy, Jan 24, 2018
  9. 5/5 dir.c: stop ignoring opendir() error in open_cached_dir()Nguyễn Thái Ngọc Duy, Jan 24, 2018
  10. Ævar Arnfjörð BjarmasonFeb 1, 2018
  11. Ævar Arnfjörð BjarmasonJan 24, 2018
  12. Junio C HamanoJan 24, 2018

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.