Table of Contents

Class Objects

Namespace
Fenrir.Git
Assembly
Fenrir.Git.dll

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 LocalPath

Path to the .git directory.

objectHash Sha1Hash

Hash 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

input Stream

Stream with input object.

output Stream

Stream with output object.

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 PackIndex

Git pack index to search the objects in.

gitDirectory LocalPath

Path to the repository's .git directory.

objectHash Sha1Hash

Hash of the object.

Returns

Task<ObjectHeader>

ReadHeaderFromStream(Stream)

Reads the object header from an object stream.

public static ObjectHeader ReadHeaderFromStream(Stream input)

Parameters

input Stream

Returns

ObjectHeader

WriteHeader(GitObjectType, long, Stream)

Writes the object header to the object stream.

public static void WriteHeader(GitObjectType type, long size, Stream output)

Parameters

type GitObjectType

Object type.

size long

Object size in bytes.

output Stream

Output 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 GitObjectType

Object type.

input Stream

The body of the input object (no header).

headed MemoryStream

The 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 LocalPath

Path to the .git directory.

object MemoryStream

Unpacked object content.

hash Sha1Hash

Object hash.