Nix 2.36.0
Nix, the purely functional package manager; unstable internal interfaces
Loading...
Searching...
No Matches
git.hh
Go to the documentation of this file.
1#pragma once
3
4#include <string>
5#include <string_view>
6#include <optional>
7
8#include "nix/util/types.hh"
10#include "nix/util/hash.hh"
12#include "nix/util/fs-sink.hh"
14
15namespace nix::git {
16
17enum struct ObjectType {
18 Blob,
19 Tree,
20 // Commit,
21 // Tag,
22};
23
24// Backwards compatibility aliases
25using merkle::Mode;
26using merkle::TreeEntry;
27using nix::RawMode;
28
35using Tree = std::map<std::string, TreeEntry>;
36
37inline std::optional<Mode> decodeMode(RawMode m)
38{
39 return merkle::decodeMode(m);
40}
41
47ObjectType parseObjectType(Source & source);
48
55uint64_t parseBlob(Source & source);
56
60void parseTree(merkle::DirectorySink & sink, Source & source, HashAlgorithm hashAlgo);
61
65std::optional<Mode> convertMode(SourceAccessor::Type type);
66
70void dumpBlobPrefix(uint64_t size, Sink & sink);
71
75void dumpTree(const Tree & entries, Sink & sink);
76
86using DumpHook = TreeEntry(const SourcePath & path);
87
88Mode dump(const SourcePath & path, Sink & sink, fun<DumpHook> hook, PathFilter & filter = defaultPathFilter);
89
95TreeEntry dumpHash(HashAlgorithm ha, const SourcePath & path, PathFilter & filter = defaultPathFilter);
96
117{
118 enum struct Kind { Symbolic, Object };
119 Kind kind;
120 std::string target;
121 std::optional<std::string> reference;
122};
123
127std::optional<LsRemoteRefLine> parseLsRemoteLine(std::string_view line);
128
129} // namespace nix::git
Definition fun.hh:19
fun< bool(const std::string &path)> PathFilter
Definition file-system.hh:494
std::map< std::string, TreeEntry > Tree
Definition git.hh:35
TreeEntry(const SourcePath &path) DumpHook
Definition git.hh:86
Mode
Definition merkle-files.hh:20
SourcePath.
Definition serialise.hh:18
Type
Definition source-accessor.hh:99
Definition source-path.hh:22
Definition serialise.hh:95
Definition git.hh:117
Definition merkle-files.hh:57
Definition merkle-files.hh:44