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 is a valid self-contained git repo). In this case, this function returns GIT_EEXISTS to indicate the the submodule 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.

The submodule object is owned by the containing repo and will be freed when the repo is freed. The caller need not free the submodule.

Signature

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

Parameters

In
submodule

Pointer to submodule description object pointer..

In
repo

The repository.

const char *
In
name

The name of the submodule. Trailing slashes will be ignored.

Returns

int

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

Versions