Parser for the git index file format.
Function pathsplit Split a /-delimited path into a directory part and a basename.
Function pathjoin Join a /-delimited path.
Function read_cache_time Read a cache time.
Function write_cache_time Write a cache time.
Function read_cache_entry Read an entry from a cache file.
Function write_cache_entry Write an index entry to a file.
Function read_index Read an index file, yielding the individual entries.
Function read_index_dict Read an index file and return it as a dictionary.
Function write_index Write an index file.
Function write_index_dict Write an index file based on the contents of a dictionary.
Function cleanup_mode Cleanup a mode value.
Class Index A Git Index file.
Function commit_tree Commit a new tree.
Function commit_index Create a new tree from an index.
Function changes_from_tree Find the differences between the contents of a tree and a working copy.
Function index_entry_from_stat Create a new index entry from a stat value.
Function build_file_from_blob Build a file or symlink on disk based on a Git object.
Function validate_path_element_default Undocumented
Function validate_path_element_ntfs Undocumented
Function validate_path Default path validator that just checks for .git/.
Function build_index_from_tree Generate and materialize index from a tree
Function blob_from_path_and_stat Create a blob from a path and a stat object.
Function read_submodule_head Read the head commit of a submodule.
Function get_unstaged_changes Walk through an index and check for differences against working tree.
Function index_entry_from_path Create an index from a filesystem path.
Function iter_fresh_entries Iterate over current versions of index entries on disk.
Function iter_fresh_blobs Iterate over versions of blobs on disk referenced by index.
Function iter_fresh_objects Iterate over versions of objecs on disk referenced by index.
Function refresh_index Refresh the contents of an index.
Function _tree_to_fs_path Convert a git tree path to a file system path.
Function _fs_to_tree_path Convert a file system path to a git tree path.
def pathsplit(path):
Split a /-delimited path into a directory part and a basename.
ParameterspathThe path to split.
ReturnsTuple with directory name and basename
def pathjoin(*args):
Join a /-delimited path.
def read_cache_time(f):
Read a cache time.
ParametersfFile-like object to read from
ReturnsTuple with seconds and nanoseconds
def write_cache_time(f, t):
Write a cache time.
ParametersfFile-like object to write to
tTime to write (as int, float or tuple with secs and nsecs)
def read_cache_entry(f):
Read an entry from a cache file.
ParametersfFile-like object to read from
Returnstuple with: device, inode, mode, uid, gid, size, sha, flags
def write_cache_entry(f, entry):
Write an index entry to a file.
ParametersfFile object
entryEntry to write, tuple with: (name, ctime, mtime, dev, ino, mode, uid, gid, size, sha, flags)
def read_index(f):
Read an index file, yielding the individual entries.
def read_index_dict(f):
Read an index file and return it as a dictionary.
ParametersfFile object to read from
def write_index(f, entries):
Write an index file.
ParametersfFile-like object to write to
entriesIterable over the entries to write
def write_index_dict(f, entries):
Write an index file based on the contents of a dictionary.
def cleanup_mode(mode):

Cleanup a mode value.

This will return a mode that can be stored in a tree object.

ParametersmodeMode to clean up.
def commit_tree(object_store, blobs):
Commit a new tree.
Parametersobject_storeObject store to add trees to
blobsIterable over blob path, sha, mode entries
ReturnsSHA1 of the created tree.
def commit_index(object_store, index):
Create a new tree from an index.
Parametersobject_storeObject store to save the tree in
indexIndex file
ReturnsRoot tree sha.
NoteThis function is deprecated, use index.commit() instead.
def changes_from_tree(names, lookup_entry, object_store, tree, want_unchanged=False):
Find the differences between the contents of a tree and a working copy.
ParametersnamesIterable of names in the working copy
lookup_entryFunction to lookup an entry in the working copy
object_storeObject store to use for retrieving tree contents
treeSHA1 of the root tree, or None for an empty tree
want_unchangedWhether unchanged files should be reported
ReturnsIterator over tuples with (oldpath, newpath), (oldmode, newmode), (oldsha, newsha)
def index_entry_from_stat(stat_val, hex_sha, flags, mode=None):
Create a new index entry from a stat value.
Parametersstat_valPOSIX stat_result instance
hex_shaHex sha of the object
flagsIndex flags
def build_file_from_blob(blob, mode, target_path, honor_filemode=True):
Build a file or symlink on disk based on a Git object.
ParametersobjThe git object
modeFile mode
target_pathPath to write to
honor_filemodeAn optional flag to honor core.filemode setting in config file, default is core.filemode=True, change executable bit
Returnsstat object for the file
def validate_path_element_default(element):
Undocumented
def validate_path_element_ntfs(element):
Undocumented
def validate_path(path, element_validator=validate_path_element_default):
Default path validator that just checks for .git/.
def build_index_from_tree(root_path, index_path, object_store, tree_id, honor_filemode=True, validate_path_element=validate_path_element_default):

Generate and materialize index from a tree

:note:: existing index is wiped and contents are not merged
in a working dir. Suitable only for fresh clones.
Parameterstree_idTree to materialize
root_pathTarget dir for materialized index files
index_pathTarget path for generated index
object_storeNon-empty object store holding tree contents
honor_filemodeAn optional flag to honor core.filemode setting in config file, default is core.filemode=True, change executable bit
validate_path_elementFunction to validate path elements to check out; default just refuses .git and .. directories.
def blob_from_path_and_stat(fs_path, st):
Create a blob from a path and a stat object.
Parametersfs_pathFull file system path to file
stA stat object
ReturnsA Blob object
def read_submodule_head(path):
Read the head commit of a submodule.
Parameterspathpath to the submodule
ReturnsHEAD sha, None if not a valid head/repository
def get_unstaged_changes(index, root_path):
Walk through an index and check for differences against working tree.
Parametersindexindex to check
root_pathpath in which to find files
Returnsiterator over paths with unstaged changes
def _tree_to_fs_path(root_path, tree_path):
Convert a git tree path to a file system path.
Parametersroot_pathRoot filesystem path
tree_pathGit tree path as bytes
ReturnsFile system path.
def _fs_to_tree_path(fs_path, fs_encoding=None):
Convert a file system path to a git tree path.
Parametersfs_pathFile system path.
fs_encodingFile system encoding
ReturnsGit tree path as bytes
def index_entry_from_path(path, object_store=None):

Create an index from a filesystem path.

This returns an index value for files, symlinks and tree references. for directories and non-existant files it returns None

ParameterspathPath to create an index entry for
object_storeOptional object store to save new blobs in
ReturnsAn index entry
def iter_fresh_entries(paths, root_path, object_store=None):
Iterate over current versions of index entries on disk.
ParameterspathsPaths to iterate over
root_pathRoot path to access from
storeOptional store to save new blobs in
ReturnsIterator over path, index_entry
def iter_fresh_blobs(index, root_path):

Iterate over versions of blobs on disk referenced by index.

Don't use this function; it removes missing entries from index.

ParametersindexIndex file
root_pathRoot path to access from
include_deletedInclude deleted entries with sha and mode set to None
ReturnsIterator over path, sha, mode
def iter_fresh_objects(paths, root_path, include_deleted=False, object_store=None):
Iterate over versions of objecs on disk referenced by index.
ParametersindexIndex file
root_pathRoot path to access from
include_deletedInclude deleted entries with sha and mode set to None
object_storeOptional object store to report new items to
ReturnsIterator over path, sha, mode
def refresh_index(index, root_path):

Refresh the contents of an index.

This is the equivalent to running 'git commit -a'.

ParametersindexIndex to update
root_pathRoot filesystem path
API Documentation for Dulwich, generated by pydoctor at 2018-11-17 19:05:54.