#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< LsRemoteRefLine > | nix::git::parseLsRemoteLine (std::string_view line) |
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.
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.
using nix::git::SinkHook = void(const CanonPath & name, TreeEntry entry) |
Callback for processing a child hash with parse
The function should
gitHash
mode
parse
was called withImplementations may seek to memoize resources (bandwidth, storage, etc.) for the same Git hash.
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
|
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.
std::optional< Mode > nix::git::convertMode | ( | SourceAccessor::Type | type | ) |
Assists with writing a SinkHook
step (2).
void nix::git::dumpBlobPrefix | ( | uint64_t | size, |
Sink & | sink, | ||
const ExperimentalFeatureSettings & | xpSettings = experimentalFeatureSettings ) |
Dumps a single file to a sink
xpSettings | for testing purposes |
TreeEntry nix::git::dumpHash | ( | HashAlgorithm | ha, |
const SourcePath & | path, | ||
PathFilter & | filter = defaultPathFilter ) |
Recursively dumps path, hashing as we go.
A smaller wrapper around dump
.
void nix::git::dumpTree | ( | const Tree & | entries, |
Sink & | sink, | ||
const ExperimentalFeatureSettings & | xpSettings = experimentalFeatureSettings ) |
Dumps a representation of a git tree to a sink
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.
rootModeIfBlob | How 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. |
std::optional< LsRemoteRefLine > nix::git::parseLsRemoteLine | ( | std::string_view | line | ) |
Parse an LsRemoteRefLine
ObjectType nix::git::parseObjectType | ( | Source & | source, |
const ExperimentalFeatureSettings & | xpSettings = experimentalFeatureSettings ) |
Parse the "blob " or "tree " prefix.
if | prefix not recognized |
void nix::git::restore | ( | FileSystemObjectSink & | sink, |
Source & | source, | ||
std::function< RestoreHook > | hook ) |
Wrapper around parse
and RestoreSink