Ggit.Submodule

Fields

None

Methods

get_fetch_recurse ()

get_head_id ()

get_ignore ()

get_index_id ()

get_name ()

get_owner ()

get_path ()

get_update ()

get_url ()

get_workdir_id ()

init (overwrite)

open ()

ref ()

reload (force)

sync ()

unref ()

update (init, options)

Details

class Ggit.Submodule

Represents a git submodule.

get_fetch_recurse()
Returns:

whether or not fetch recursively.

Return type:

bool

Gets whether to fetch recursively. See see gitmodules(5) fetchRecurseSubmodules.

get_head_id()
Return type:

Ggit.OId

get_ignore()
Returns:

the Ggit.SubmoduleIgnore.

Return type:

Ggit.SubmoduleIgnore

Gets a Ggit.SubmoduleIgnore. See see gitmodules(5) ignore.

get_index_id()
Returns:

the OID for the submodule in the index or None.

Return type:

Ggit.OId or None

Gets the OID for the submodule in the index or None if there is no index.

get_name()
Returns:

the name of the submodule from .gitmodules or None.

Return type:

str or None

Gets the name of the submodule from .gitmodules.

get_owner()
Returns:

the containing repository for a submodule or None.

Return type:

Ggit.Repository or None

Gets the containing repository for a submodule.

get_path()
Returns:

the path to the submodule from the repo working directory or None.

Return type:

str or None

Gets the path to the submodule from the repo working directory. It is almost always the same as the name. See Ggit.Submodule.get_name().

get_update()
Returns:

the Ggit.SubmoduleUpdate.

Return type:

Ggit.SubmoduleUpdate

Gets a Ggit.SubmoduleUpdate. See see gitmodules(5) update.

get_url()
Returns:

the url for the submodule or None.

Return type:

str or None

Gets the url for the submodule or None if the submodule has been deleted but not yet committed.

get_workdir_id()
Returns:

the OID for the submodule in the current working directory or None.

Return type:

Ggit.OId or None

Gets the OID for the submodule in the current working directory. Corresponds to looking up ‘HEAD’ in the checked out submodule. If there are pending changes in the index or anything else, this won’t notice that. You should call ggit_submodule_status() for a more complete picture about the state of the working directory.

init(overwrite)
Parameters:

overwrite (bool) – forces existing entries to be updated.

Raises:

GLib.Error

Just like “git submodule init”, this copies information about the submodule into “.git/config”. You can use the accessor functions above to alter the in-memory git_submodule object and control what is written to the config, overriding what is in .gitmodules.

open()
Raises:

GLib.Error

Returns:

the opened Ggit.Repository or None in case of an error.

Return type:

Ggit.Repository or None

Open the repository for a submodule. Multiple calls to this function will return distinct Ggit.Repository objects. Only submodules which are checked out in the working directory can be opened.

ref()
Returns:

the passed in Ggit.Submodule or None.

Return type:

Ggit.Submodule or None

Atomically increments the reference count of self by one. This function is MT-safe and may be called from any thread.

reload(force)
Parameters:

force (bool) – reload even if the data doesn’t seem out of date.

Raises:

GLib.Error

Rereads submodule info from config, index, and HEAD. Call this if you have reason to believe that it has changed.

sync()
Raises:

GLib.Error

Copies the information about the submodules URL into the checked out submodule config, acting like “git submodule sync”. This is useful if you have altered the URL for the submodule (or it has been altered by a fetch of upstream changes) and you need to update your local repo.

unref()

Atomically decrements the reference count of self by one. If the reference count drops to 0, remote is freed.

update(init, options)
Parameters:
  • init (bool) – If the submodule is not initialized, setting this flag to true will initialize the submodule before updating. Otherwise, this will return an error if attempting to update an uninitialzed repository. but setting this to true forces them to be updated.

  • options (Ggit.SubmoduleUpdateOptions) – a Ggit.SubmoduleUpdateOptions object.

Raises:

GLib.Error

Update a submodule. This will clone a missing submodule and checkout the subrepository to the commit specified in the index of the containing repository. If the submodule repository doesn’t contain the target commit (e.g. because fetchRecurseSubmodules isn’t set), then the submodule is fetched using the fetch options supplied in options.