Class Objects
Low-level functions related to Git as an object storage.
[CompilationMapping(SourceConstructFlags.Module)]
public static class Objects
- Inheritance
-
Objects
- Inherited Members
Methods
GetRawObjectPath(LocalPath, Sha1Hash)
Calculates a path to the designated object's file in the .git directory.
public static LocalPath GetRawObjectPath(LocalPath gitDirectory, Sha1Hash objectHash)
Parameters
gitDirectoryLocalPathPath to the
.gitdirectory.objectHashSha1HashHash of the object to seek.
Returns
- LocalPath
Remarks
Note that this file is not guaranteed to exist even if an object exists in the repository — in case the object is packed. To seek for both an object in both packed and non-packed form, use this function in combination with ReadPackedObject(PackIndex, Sha1Hash).
Guillotine(Stream, Stream)
Removes a header from an object, writes the result into the output stream.
public static int Guillotine(Stream input, Stream output)
Parameters
Returns
- int
Written byte count.
ReadHeader(PackIndex, LocalPath, Sha1Hash)
Reads the header of any object in the Git storage.
public static Task<ObjectHeader> ReadHeader(PackIndex index, LocalPath gitDirectory, Sha1Hash objectHash)
Parameters
indexPackIndexGit pack index to search the objects in.
gitDirectoryLocalPathPath to the repository's
.gitdirectory.objectHashSha1HashHash of the object.
Returns
ReadHeaderFromStream(Stream)
Reads the object header from an object stream.
public static ObjectHeader ReadHeaderFromStream(Stream input)
Parameters
inputStream
Returns
WriteHeader(GitObjectType, long, Stream)
Writes the object header to the object stream.
public static void WriteHeader(GitObjectType type, long size, Stream output)
Parameters
typeGitObjectTypeObject type.
sizelongObject size in bytes.
outputStreamOutput stream to write to.
WriteObject(GitObjectType, Stream, MemoryStream)
Writes object header followed by the passed object to the output stream.
public static Sha1Hash WriteObject(GitObjectType type, Stream input, MemoryStream headed)
Parameters
typeGitObjectTypeObject type.
inputStreamThe body of the input object (no header).
headedMemoryStreamThe output stream to out the data into.
Returns
- Sha1Hash
Hash of the object.
WriteToFile(LocalPath, MemoryStream, Sha1Hash)
Writes a full object stream to a corresponding file in the repository.
public static void WriteToFile(LocalPath gitDirectory, MemoryStream @object, Sha1Hash hash)
Parameters
gitDirectoryLocalPathPath to the
.gitdirectory.objectMemoryStreamUnpacked object content.
hashSha1HashObject hash.