libgit2

git_submodule_lookup

Version:

Lookup submodule information by name or path.

Given either the submodule name or path (they are usually the same), this returns a structure describing the submodule.

There are two expected error scenarios:

  • The submodule is not mentioned in the HEAD, the index, and the config, but does "exist" in the working directory (i.e. there is a subdirectory that appears to be a Git repository). In this case, this function returns GIT_EEXISTS to indicate a sub-repository exists but not in a state where a git_submodule can be instantiated.
  • The submodule is not mentioned in the HEAD, index, or config and the working directory doesn't contain a value git repo at that path. There may or may not be anything else at that path, but nothing that looks like a submodule. In this case, this returns GIT_ENOTFOUND.

You must call git_submodule_free when done with the submodule.

Signature

int git_submodule_lookup(git_submodule **out, git_repository *repo, const char *name);

Parameters

In
out

Output ptr to submodule; pass NULL to just get return code

In
repo

The parent repository

const char *
In
name

The name of or path to the submodule; trailing slashes okay

Returns

int

0 on success, GIT_ENOTFOUND if submodule does not exist, GIT_EEXISTS if a repository is found in working directory only, -1 on other errors.

Versions