Nix 2.26.3
Nix, the purely functional package manager; unstable internal interfaces
 
Loading...
Searching...
No Matches
git.hh File Reference
#include <string>
#include <string_view>
#include <optional>
#include "types.hh"
#include "serialise.hh"
#include "hash.hh"
#include "source-path.hh"
#include "fs-sink.hh"

Go to the source code of this file.

Classes

struct  nix::git::TreeEntry
 
struct  nix::git::LsRemoteRefLine
 

Typedefs

using nix::git::RawMode = uint32_t
 
using nix::git::Tree = std::map<std::string, TreeEntry>
 
using nix::git::SinkHook = void(const CanonPath & name, TreeEntry entry)
 
using nix::git::RestoreHook = SourcePath(Hash)
 
using nix::git::DumpHook = TreeEntry(const SourcePath & path)
 

Enumerations

enum struct  ObjectType { Blob , Tree }
 
enum struct  Mode : RawMode { Directory = 0040000 , Regular = 0100644 , Executable = 0100755 , Symlink = 0120000 }
 
enum struct  nix::git::BlobMode : RawMode { Regular = static_cast<RawMode>(Mode::Regular) , Executable = static_cast<RawMode>(Mode::Executable) , Symlink = static_cast<RawMode>(Mode::Symlink) }
 

Functions

std::optional< Mode > nix::git::decodeMode (RawMode m)
 
ObjectType nix::git::parseObjectType (Source &source, const ExperimentalFeatureSettings &xpSettings)
 
void nix::git::parseBlob (FileSystemObjectSink &sink, const CanonPath &sinkPath, Source &source, BlobMode blobMode, const ExperimentalFeatureSettings &xpSettings)
 
void nix::git::parseTree (FileSystemObjectSink &sink, const CanonPath &sinkPath, Source &source, std::function< SinkHook > hook, const ExperimentalFeatureSettings &xpSettings)
 
void nix::git::parse (FileSystemObjectSink &sink, const CanonPath &sinkPath, Source &source, BlobMode rootModeIfBlob, std::function< SinkHook > hook, const ExperimentalFeatureSettings &xpSettings)
 
std::optional< Mode > nix::git::convertMode (SourceAccessor::Type type)
 
void nix::git::restore (FileSystemObjectSink &sink, Source &source, std::function< RestoreHook > hook)
 
void nix::git::dumpBlobPrefix (uint64_t size, Sink &sink, const ExperimentalFeatureSettings &xpSettings)
 
void nix::git::dumpTree (const Tree &entries, Sink &sink, const ExperimentalFeatureSettings &xpSettings)
 
Mode nix::git::dump (const SourcePath &path, Sink &sink, std::function< DumpHook > hook, PathFilter &filter, const ExperimentalFeatureSettings &xpSettings)
 
TreeEntry nix::git::dumpHash (HashAlgorithm ha, const SourcePath &path, PathFilter &filter)
 
std::optional< LsRemoteRefLinenix::git::parseLsRemoteLine (std::string_view line)
 

Typedef Documentation

◆ DumpHook

using nix::git::DumpHook = TreeEntry(const SourcePath & path)

Callback for processing a child with dump

The function should return the Git hash and mode of the file at the given path in the accessor passed to dump.

Note that if the child is a directory, its child in must also be so processed in order to compute this information.

◆ RestoreHook

using nix::git::RestoreHook = SourcePath(Hash)

Simplified version of SinkHook for restore.

Given a Hash, return a SourceAccessor and CanonPath pointing to the file system object with that path.

◆ SinkHook

using nix::git::SinkHook = void(const CanonPath & name, TreeEntry entry)

Callback for processing a child hash with parse

The function should

  1. Obtain the file system objects denoted by gitHash
  2. Ensure they match mode
  3. Feed them into the same sink parse was called with

Implementations may seek to memoize resources (bandwidth, storage, etc.) for the same Git hash.

◆ Tree

using nix::git::Tree = std::map<std::string, TreeEntry>

A Git tree object, fully decoded and stored in memory.

Directory names must end in a / for sake of sorting. See https://github.com/mirage/irmin/issues/352

Enumeration Type Documentation

◆ BlobMode

enum struct nix::git::BlobMode : RawMode
strong

These 3 modes are represented by blob objects.

Sometimes we need this information to disambiguate how a blob is being used to better match our own "file system object" data model.

Function Documentation

◆ convertMode()

std::optional< Mode > nix::git::convertMode ( SourceAccessor::Type type)

Assists with writing a SinkHook step (2).

◆ dumpBlobPrefix()

void nix::git::dumpBlobPrefix ( uint64_t size,
Sink & sink,
const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings )

Dumps a single file to a sink

Parameters
xpSettingsfor testing purposes

◆ dumpHash()

TreeEntry nix::git::dumpHash ( HashAlgorithm ha,
const SourcePath & path,
PathFilter & filter = defaultPathFilter )

Recursively dumps path, hashing as we go.

A smaller wrapper around dump.

◆ dumpTree()

void nix::git::dumpTree ( const Tree & entries,
Sink & sink,
const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings )

Dumps a representation of a git tree to a sink

◆ parse()

void nix::git::parse ( FileSystemObjectSink & sink,
const CanonPath & sinkPath,
Source & source,
BlobMode rootModeIfBlob,
std::function< SinkHook > hook,
const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings )

Helper putting the previous three parse* functions together.

Parameters
rootModeIfBlobHow to interpret a root blob, for which there is no disambiguating dir entry to answer that questino. If the root it not a blob, this is ignored.

◆ parseLsRemoteLine()

std::optional< LsRemoteRefLine > nix::git::parseLsRemoteLine ( std::string_view line)

Parse an LsRemoteRefLine

◆ parseObjectType()

ObjectType nix::git::parseObjectType ( Source & source,
const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings )

Parse the "blob " or "tree " prefix.

Exceptions
ifprefix not recognized

◆ restore()

void nix::git::restore ( FileSystemObjectSink & sink,
Source & source,
std::function< RestoreHook > hook )

Wrapper around parse and RestoreSink