make is_submodule_populated gently
authorStefan Beller <sbeller@google.com>
Tue, 14 Mar 2017 21:46:31 +0000 (14:46 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 16 Mar 2017 01:15:54 +0000 (18:15 -0700)
We need the gentle version in a later patch. As we have just one caller,
migrate the caller.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/grep.c
submodule.c
submodule.h
index 2c727ef499c0fa7b44c0cf1890cc44427dc8921f..b17835aed65df04eb790ff3139203a7467a891db 100644 (file)
@@ -616,7 +616,7 @@ static int grep_submodule(struct grep_opt *opt, const unsigned char *sha1,
 {
        if (!is_submodule_initialized(path))
                return 0;
-       if (!is_submodule_populated(path)) {
+       if (!is_submodule_populated_gently(path, NULL)) {
                /*
                 * If searching history, check for the presense of the
                 * submodule's gitdir before skipping the submodule.
index 45e93a1d55003d1a480e5eff2d1e3d8752d24c1e..04d185738ff2e8b10ec0564e02aad18dba2a9b4d 100644 (file)
@@ -234,15 +234,12 @@ int is_submodule_initialized(const char *path)
        return ret;
 }
 
-/*
- * Determine if a submodule has been populated at a given 'path'
- */
-int is_submodule_populated(const char *path)
+int is_submodule_populated_gently(const char *path, int *return_error_code)
 {
        int ret = 0;
        char *gitdir = xstrfmt("%s/.git", path);
 
-       if (resolve_gitdir(gitdir))
+       if (resolve_gitdir_gently(gitdir, return_error_code))
                ret = 1;
 
        free(gitdir);
index 05ab674f069282b3d5b20ca69d9a1fe8f295879b..0b915bd3ac8cde1a081bf675cf90ac6af807effd 100644 (file)
@@ -41,7 +41,13 @@ extern int submodule_config(const char *var, const char *value, void *cb);
 extern void gitmodules_config(void);
 extern void gitmodules_config_sha1(const unsigned char *commit_sha1);
 extern int is_submodule_initialized(const char *path);
-extern int is_submodule_populated(const char *path);
+/*
+ * Determine if a submodule has been populated at a given 'path' by checking if
+ * the <path>/.git resolves to a valid git repository.
+ * If return_error_code is NULL, die on error.
+ * Otherwise the return error code is the same as of resolve_gitdir_gently.
+ */
+extern int is_submodule_populated_gently(const char *path, int *return_error_code);
 extern int parse_submodule_update_strategy(const char *value,
                struct submodule_update_strategy *dst);
 extern const char *submodule_strategy_to_string(const struct submodule_update_strategy *s);