Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx> writes: > The call invalidate_directory() between opendir() and warning_errno() in > theory could make some system calls and change errno. Prevent that by > warning immediately after opendir(). > > Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx> > --- > This is on top of nd/fix-untracked-cache-invalidation which is now on > 'next'. Sorry I waited too long to send the replacement and it's now > too late. Well, we'll see a rewind of 'next' soonish anyway, so you can just tell me to tentatively kick it back to 'pu' to be replaced with a reroll if you prefer. > dir.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/dir.c b/dir.c > index dd1e50c328..55736d3e2a 100644 > --- a/dir.c > +++ b/dir.c > @@ -1795,14 +1795,14 @@ static int open_cached_dir(struct cached_dir *cdir, > return 0; > 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++; > } > - if (!cdir->fdir) { > - warning_errno(_("could not open directory '%s'"), c_path); > + if (!cdir->fdir) > return -1; > - } > return 0; > }