/* Only loads from .gitmodules, no overlay with .git/config */
gitmodules_config();
- sub = submodule_from_path(null_sha1, path);
-
if (prefix) {
strbuf_addf(&sb, "%s%s", prefix, path);
displaypath = strbuf_detach(&sb, NULL);
} else
- displaypath = xstrdup(sub->path);
+ displaypath = xstrdup(path);
+
+ sub = submodule_from_path(null_sha1, path);
+
+ if (!sub)
+ die(_("No url found for submodule path '%s' in .gitmodules"),
+ displaypath);
/*
* Copy url setting when it is not set yet.
git branch initial
'
+test_expect_success 'submodule init aborts on missing .gitmodules file' '
+ test_when_finished "git update-index --remove sub" &&
+ git update-index --add --cacheinfo 160000,$(git rev-parse HEAD),sub &&
+ # missing the .gitmodules file here
+ test_must_fail git submodule init 2>actual &&
+ test_i18ngrep "No url found for submodule path" actual
+'
+
test_expect_success 'configuration parsing' '
test_when_finished "rm -f .gitmodules" &&
cat >.gitmodules <<-\EOF &&