MCPcopy Index your code
hub / github.com/git/git / open_submodule

Function open_submodule

submodule.c:511–528  ·  view source on GitHub ↗

* Initialize a repository struct for a submodule based on the provided 'path'. * * Returns the repository struct on success, * NULL when the submodule is not present. */

Source from the content-addressed store, hash-verified

509 * NULL when the submodule is not present.
510 */
511static struct repository *open_submodule(const char *path)
512{
513 struct strbuf sb = STRBUF_INIT;
514 struct repository *out = xmalloc(sizeof(*out));
515
516 if (submodule_to_gitdir(the_repository, &sb, path) ||
517 repo_init(out, sb.buf, NULL)) {
518 strbuf_release(&sb);
519 free(out);
520 return NULL;
521 }
522
523 /* Mark it as a submodule */
524 out->submodule_prefix = xstrdup(path);
525
526 strbuf_release(&sb);
527 return out;
528}
529
530/*
531 * Helper function to display the submodule header line prior to the full

Callers 2

Calls 5

submodule_to_gitdirFunction · 0.85
repo_initFunction · 0.85
strbuf_releaseFunction · 0.85
xstrdupFunction · 0.85
xmallocFunction · 0.70

Tested by

no test coverage detected