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
gitDirectory
LocalPathPath to the
.git
directory.objectHash
Sha1HashHash 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
index
PackIndexGit pack index to search the objects in.
gitDirectory
LocalPathPath to the repository's
.git
directory.objectHash
Sha1HashHash of the object.
Returns
ReadHeaderFromStream(Stream)
Reads the object header from an object stream.
public static ObjectHeader ReadHeaderFromStream(Stream input)
Parameters
input
Stream
Returns
WriteHeader(GitObjectType, long, Stream)
Writes the object header to the object stream.
public static void WriteHeader(GitObjectType type, long size, Stream output)
Parameters
type
GitObjectTypeObject type.
size
longObject size in bytes.
output
StreamOutput 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
type
GitObjectTypeObject type.
input
StreamThe body of the input object (no header).
headed
MemoryStreamThe 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
gitDirectory
LocalPathPath to the
.git
directory.object
MemoryStreamUnpacked object content.
hash
Sha1HashObject hash.