Ggit.Index

g GObject.GInterface GObject.GInterface Gio.Initable Gio.Initable GObject.GInterface->Gio.Initable GObject.Object GObject.Object Ggit.ObjectFactoryBase Ggit.ObjectFactoryBase GObject.Object->Ggit.ObjectFactoryBase Ggit.Index Ggit.Index Ggit.Native Ggit.Native Ggit.Native->Ggit.Index Ggit.ObjectFactoryBase->Ggit.Native Gio.Initable->Ggit.Index

Subclasses:

None

Methods

Inherited:

GObject.Object (37), Gio.Initable (2)

Structs:

GObject.ObjectClass (5)

class

open (file)

add (entry)

add_file (file)

add_path (path)

get_entries ()

get_entries_resolve_undo ()

get_owner ()

has_conflicts ()

read (force)

remove (file, stage)

write ()

write_tree ()

write_tree_to (repository)

Virtual Methods

Inherited:

GObject.Object (7), Gio.Initable (1)

Properties

Inherited:

Ggit.Native (1)

Name

Type

Flags

Short Description

file

Gio.File

r/w/co

File

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Class Details

class Ggit.Index(**kwargs)
Bases:

Ggit.Native, Gio.Initable

Abstract:

No

Structure:

Ggit.IndexClass

Represents an index object.

classmethod open(file)
Parameters:

file (Gio.File) – a Gio.File.

Raises:

GLib.Error

Returns:

a Ggit.Index or None if an error occurred.

Return type:

Ggit.Index or None

Create a new bare Git index object as a memory representation of the Git index file in file, without a repository to back it.

add(entry)
Parameters:

entry (Ggit.IndexEntry) – a Ggit.IndexEntry.

Raises:

GLib.Error

Returns:

True if the file was successfully added, False otherwise.

Return type:

bool

Add a file to the index.

add_file(file)
Parameters:

file (Gio.File) – file to add.

Raises:

GLib.Error

Returns:

True if the file was added to the index or False if there was an error.

Return type:

bool

Add a file to the index. The specified file must be in the working directory and must exist and be readable.

add_path(path)
Parameters:

path (str) – path to the file to add.

Raises:

GLib.Error

Returns:

True if the file was added to the index or False if there was an error.

Return type:

bool

Add a file to the index by path. You can specify both relative paths (to the working directory) and absolute paths. Absolute paths however must reside in the working directory. The specified path must exist and must be readable.

get_entries()
Returns:

a Ggit.IndexEntries or None.

Return type:

Ggit.IndexEntries or None

Get the index entries enumerator.

get_entries_resolve_undo()
Returns:

a Ggit.IndexEntriesResolveUndo or None.

Return type:

Ggit.IndexEntriesResolveUndo or None

Get the resolve undo entries enumerator.

get_owner()
Returns:

the Ggit.Repository that owns this index or None.

Return type:

Ggit.Repository or None

Get the Ggit.Repository that owns the index.

has_conflicts()
Returns:

True if the index has any conflicts, False otherwise.

Return type:

bool

Get whether the index has any conflicts.

read(force)
Parameters:

force (bool) – force read even if there are in-memory changes.

Raises:

GLib.Error

Returns:

True if the index could be read from the file associated with the index, False otherwise.

Return type:

bool

Update the contents of an existing index object in memory by reading from the hard disk.

If force is true, this performs a “hard” read that discards in-memory changes and always reloads the on-disk index data. If there is no on-disk version, the index will be cleared.

If force is false, this does a “soft” read that reloads the index data from disk only if it has changed since the last time it was loaded. Purely in-memory index data will be untouched. Be aware: if there are changes on disk, unwritten in-memory changes are discarded.

remove(file, stage)
Parameters:
  • file (Gio.File) – the file to search.

  • stage (int) – the stage to search.

Raises:

GLib.Error

Returns:

True if the file was successfully removed, False otherwise.

Return type:

bool

Remove a file from the index (specified by position).

write()
Raises:

GLib.Error

Returns:

True if the index was successfully written to disk, False otherwise.

Return type:

bool

Write an existing index object from memory back to disk using an atomic file lock.

write_tree()
Raises:

GLib.Error

Returns:

a Ggit.OId or None in case of an error.

Return type:

Ggit.OId or None

Write a new tree object to disk containing a representation of the current state of the index. The index must be associated to an existing repository and must not contain any files in conflict. You can use the resulting tree to for instance create a commit.

write_tree_to(repository)
Parameters:

repository (Ggit.Repository) – a Ggit.Repository.

Raises:

GLib.Error

Returns:

a Ggit.OId or None in case of an error.

Return type:

Ggit.OId or None

Write a new tree object to repository containing a representation of the current state of the index. The index must not contain any files in conflict. You can use the resulting tree to for instance create a commit.

Property Details

Ggit.Index.props.file
Name:

file

Type:

Gio.File

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

File