From b6731550749c7326f0dcf26211e7c2e55de00e28 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Wed, 24 Jan 2018 16:30:23 +0700 Subject: [PATCH] dir.c: stop ignoring opendir() error in open_cached_dir() MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- 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++; -- 2.11.4.GIT