[PATCH v2 1/1] scan-tree: handle error in git_config_from_file()

Christian Hesse list at eworm.de
Wed Mar 9 11:16:35 CET 2016


From: Christian Hesse <mail at eworm.de>

We can live without config, but print an error if it is not readable.
---
 scan-tree.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/scan-tree.c b/scan-tree.c
index 2e87999..bc17d14 100644
--- a/scan-tree.c
+++ b/scan-tree.c
@@ -121,7 +121,10 @@ static void add_repo(const char *base, struct strbuf *path, repo_config_fn fn)
 	config_fn = fn;
 	if (ctx.cfg.enable_git_config) {
 		strbuf_addstr(path, "config");
-		git_config_from_file(gitconfig_config, path->buf, NULL);
+		if (git_config_from_file(gitconfig_config, path->buf, NULL)) {
+			fprintf(stderr, "Error reading config %s: %s (%d)\n",
+				path->buf, strerror(errno), errno);
+		}
 		strbuf_setlen(path, pathlen);
 	}
 
-- 
2.7.2



More information about the CGit mailing list