make is_submodule_populated gently

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>

Stefan Beller committed Mar 14, 2017 at 14:46 UTC 15cdc6477634e0227e4211de464c6443a68172c9
3 files changed +10 -7
builtin/grep.c
+1 -1
@@ -616,7 +616,7 @@ static int grep_submodule(struct grep_opt *opt, const unsigned char *sha1,
616 {
617 if (!is_submodule_initialized(path))
618 return 0;
619 - if (!is_submodule_populated(path)) {
619 + if (!is_submodule_populated_gently(path, NULL)) {
620 /*
621 * If searching history, check for the presense of the
622 * submodule's gitdir before skipping the submodule.
submodule.c
+2 -5
@@ -234,15 +234,12 @@ int is_submodule_initialized(const char *path)
234 return ret;
235 }
236
237 -/*
238 - * Determine if a submodule has been populated at a given 'path'
239 - */
240 -int is_submodule_populated(const char *path)
237 +int is_submodule_populated_gently(const char *path, int *return_error_code)
238 {
239 int ret = 0;
240 char *gitdir = xstrfmt("%s/.git", path);
241
245 - if (resolve_gitdir(gitdir))
242 + if (resolve_gitdir_gently(gitdir, return_error_code))
243 ret = 1;
244
245 free(gitdir);
submodule.h
+7 -1
@@ -41,7 +41,13 @@ extern int submodule_config(const char *var, const char *value, void *cb);
41 extern void gitmodules_config(void);
42 extern void gitmodules_config_sha1(const unsigned char *commit_sha1);
43 extern int is_submodule_initialized(const char *path);
44 -extern int is_submodule_populated(const char *path);
44 +/*
45 + * Determine if a submodule has been populated at a given 'path' by checking if
46 + * the <path>/.git resolves to a valid git repository.
47 + * If return_error_code is NULL, die on error.
48 + * Otherwise the return error code is the same as of resolve_gitdir_gently.
49 + */
50 +extern int is_submodule_populated_gently(const char *path, int *return_error_code);
51 extern int parse_submodule_update_strategy(const char *value,
52 struct submodule_update_strategy *dst);
53 extern const char *submodule_strategy_to_string(const struct submodule_update_strategy *s);