setup: add gentle version of resolve_git_dir
authorStefan Beller <sbeller@google.com>
Tue, 24 Jan 2017 23:56:49 +0000 (15:56 -0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 26 Jan 2017 19:00:24 +0000 (11:00 -0800)
This follows a93bedada (setup: add gentle version of read_gitfile,
2015-06-09), and assumes the same reasoning. resolve_git_dir is unsuited
for speculative calls, so we want to use the gentle version to find out
about potential errors.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
cache.h
setup.c
diff --git a/cache.h b/cache.h
index 00a029af3657d319b7df987a36979a519c2dda94..cafa3d10aeffe92de80761de3b1962e9bd4b7cd4 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -509,7 +509,9 @@ extern int is_nonbare_repository_dir(struct strbuf *path);
 #define READ_GITFILE_ERR_TOO_LARGE 8
 extern const char *read_gitfile_gently(const char *path, int *return_error_code);
 #define read_gitfile(path) read_gitfile_gently((path), NULL)
-extern const char *resolve_gitdir(const char *suspect);
+extern const char *resolve_gitdir_gently(const char *suspect, int *return_error_code);
+#define resolve_gitdir(path) resolve_gitdir_gently((path), NULL)
+
 extern void set_git_work_tree(const char *tree);
 
 #define ALTERNATE_DB_ENVIRONMENT "GIT_ALTERNATE_OBJECT_DIRECTORIES"
diff --git a/setup.c b/setup.c
index 1b534a750810f3773ba9c21a5ec221f54857349b..4605fd3c3c4e06255eb5afc23fe47e1db80d075f 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -1017,11 +1017,11 @@ const char *setup_git_directory(void)
        return setup_git_directory_gently(NULL);
 }
 
-const char *resolve_gitdir(const char *suspect)
+const char *resolve_gitdir_gently(const char *suspect, int *return_error_code)
 {
        if (is_git_directory(suspect))
                return suspect;
-       return read_gitfile(suspect);
+       return read_gitfile_gently(suspect, return_error_code);
 }
 
 /* if any standard file descriptor is missing open it to /dev/null */