dir.c: stop ignoring opendir() error in open_cached_dir()
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy committed
Jan 24, 2018 at 16:30 UTC
b6731550749c7326f0dcf26211e7c2e55de00e28
1 file changed
+6
-1
dir.c
+6
-1
@@ -1787,11 +1787,16 @@ static int open_cached_dir(struct cached_dir *cdir,
1787
struct strbuf *path,
1788
int check_only)
1789
{
1790
+ const char *c_path;
1791
+
1792
memset(cdir, 0, sizeof(*cdir));
1793
cdir->untracked = untracked;
1794
if (valid_cached_dir(dir, untracked, istate, path, check_only))
1795
return 0;
1794
- cdir->fdir = opendir(path->len ? path->buf : ".");
1796
+ c_path = path->len ? path->buf : ".";
1797
+ cdir->fdir = opendir(c_path);
1798
+ if (!cdir->fdir)
1799
+ warning_errno(_("could not open directory '%s'"), c_path);
1800
if (dir->untracked) {
1801
invalidate_directory(dir->untracked, untracked);
1802
dir->untracked->dir_opened++;