Signed-off-by: Stefan Beller <sbel...@google.com>
---
 builtin/submodule--helper.c | 21 +++++++++++++++++++++
 git-submodule.sh            | 10 ----------
 2 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 73954ac..7a2fd4e 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -300,6 +300,7 @@ static int module_list_or_clone(int argc, const char 
**argv, const char *prefix)
                const struct cache_entry *ce = list.entries[i];
                struct strbuf sb = STRBUF_INIT;
                const char *update_module = NULL;
+               const char *url = NULL;
 
                char *env_prefix = getenv("prefix");
                if (ce_stage(ce)) {
@@ -329,6 +330,26 @@ static int module_list_or_clone(int argc, const char 
**argv, const char *prefix)
                        continue;
                }
 
+               /*
+                * Looking up the url in .git/config.
+                * We cannot fall back to .gitmodules as we only want to process
+                * configured submodules. This renders the submodule lookup API
+                * useless, as it cannot lookup without fallback.
+                */
+               strbuf_reset(&sb);
+               strbuf_addf(&sb, "submodule.%s.url", sub->name);
+               git_config_get_string_const(sb.buf, &url);
+               if (!url) {
+                       /*
+                        * Only mention uninitialized submodules when its
+                        * path have been specified
+                        */
+                       if (pathspec.nr)
+                               fprintf(stderr, _("Submodule path '%s' not 
initialized\n"
+                                       "Maybe you want to use 'update 
--init'?"), displaypath);
+                       continue;
+               }
+
                printf("%06o %s %d\t", ce->ce_mode, sha1_to_hex(ce->sha1), 
ce_stage(ce));
                utf8_fprintf(stdout, "%s\n", ce->name);
        }
diff --git a/git-submodule.sh b/git-submodule.sh
index 227fed6..80f41b2 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -677,16 +677,6 @@ cmd_update()
 
                displaypath=$(relative_path "$prefix$sm_path")
 
-               if test -z "$url"
-               then
-                       # Only mention uninitialized submodules when its
-                       # path have been specified
-                       test "$#" != "0" &&
-                       say >&2 "$(eval_gettext "Submodule path '\$displaypath' 
not initialized
-Maybe you want to use 'update --init'?")"
-                       continue
-               fi
-
                if ! test -d "$sm_path"/.git && ! test -f "$sm_path"/.git
                then
                        git submodule--helper clone ${GIT_QUIET:+--quiet} 
--prefix "$prefix" --path "$sm_path" --name "$name" --url "$url" "$reference" 
"$depth" || exit
-- 
2.5.0.277.gfdc362b.dirty

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to