libgit2

git_submodule_add_setup

Version:

Set up a new git submodule for checkout.

This does "git submodule add" up to the fetch and checkout of the submodule contents. It preps a new submodule, creates an entry in .gitmodules and creates an empty initialized repository either at the given path in the working directory or in .git/modules with a gitlink from the working directory to the new repo.

To fully emulate "git submodule add" call this function, then open the submodule repo and perform the clone step as needed. Lastly, call git_submodule_add_finalize() to wrap up adding the new submodule and .gitmodules to the index to be ready to commit.

Signature

int git_submodule_add_setup(git_submodule **submodule, git_repository *repo, const char *url, const char *path, int use_gitlink);

Parameters

In
submodule

The newly created submodule ready to open for clone

In
repo

Superproject repository to contain the new submodule

const char *
In
url

URL for the submodules remote

const char *
In
path

Path at which the submodule should be created

int
In
use_gitlink

Should workdir contain a gitlink to the repo in .git/modules vs. repo directly in workdir.

Returns

int

0 on success, GIT_EEXISTS if submodule already exists, -1 on other errors.

Versions