Nix 2.26.3
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 "types.hh"
9#include "serialise.hh"
10#include "hash.hh"
11#include "source-path.hh"
12#include "fs-sink.hh"
13
14namespace nix::git {
15
16enum struct ObjectType {
17 Blob,
18 Tree,
19 //Commit,
20 //Tag,
21};
22
23using RawMode = uint32_t;
24
25enum struct Mode : RawMode {
26 Directory = 0040000,
27 Regular = 0100644,
28 Executable = 0100755,
29 Symlink = 0120000,
30};
31
32std::optional<Mode> decodeMode(RawMode m);
33
38{
39 Mode mode;
40 Hash hash;
41
42 bool operator ==(const TreeEntry &) const = default;
43 auto operator <=>(const TreeEntry &) const = default;
44};
45
52using Tree = std::map<std::string, TreeEntry>;
53
68using SinkHook = void(const CanonPath & name, TreeEntry entry);
69
75ObjectType parseObjectType(
76 Source & source,
77 const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings);
78
85enum struct BlobMode : RawMode
86{
87 Regular = static_cast<RawMode>(Mode::Regular),
88 Executable = static_cast<RawMode>(Mode::Executable),
89 Symlink = static_cast<RawMode>(Mode::Symlink),
90};
91
92void parseBlob(
93 FileSystemObjectSink & sink, const CanonPath & sinkPath,
94 Source & source,
95 BlobMode blobMode,
96 const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings);
97
98void parseTree(
99 FileSystemObjectSink & sink, const CanonPath & sinkPath,
100 Source & source,
101 std::function<SinkHook> hook,
102 const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings);
103
111void parse(
112 FileSystemObjectSink & sink, const CanonPath & sinkPath,
113 Source & source,
114 BlobMode rootModeIfBlob,
115 std::function<SinkHook> hook,
116 const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings);
117
121std::optional<Mode> convertMode(SourceAccessor::Type type);
122
130
134void restore(FileSystemObjectSink & sink, Source & source, std::function<RestoreHook> hook);
135
141void dumpBlobPrefix(
142 uint64_t size, Sink & sink,
143 const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings);
144
148void dumpTree(
149 const Tree & entries, Sink & sink,
150 const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings);
151
161using DumpHook = TreeEntry(const SourcePath & path);
162
163Mode dump(
164 const SourcePath & path,
165 Sink & sink,
166 std::function<DumpHook> hook,
167 PathFilter & filter = defaultPathFilter,
168 const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings);
169
175TreeEntry dumpHash(
176 HashAlgorithm ha,
177 const SourcePath & path,
178 PathFilter & filter = defaultPathFilter);
179
200 enum struct Kind {
201 Symbolic,
202 Object
203 };
204 Kind kind;
205 std::string target;
206 std::optional<std::string> reference;
207};
208
212std::optional<LsRemoteRefLine> parseLsRemoteLine(std::string_view line);
213
214}
Definition canon-path.hh:41
std::function< bool(const Path &path)> PathFilter
Definition file-system.hh:365
void(const CanonPath &name, TreeEntry entry) SinkHook
Definition git.hh:68
SourcePath(Hash) RestoreHook
Definition git.hh:129
BlobMode
Definition git.hh:86
TreeEntry(const SourcePath &path) DumpHook
Definition git.hh:161
uint32_t line
Definition lexer.l:6526
ValueType type
Definition lexer.l:7098
const std::string_view & name
Definition lexer.l:1709
SourcePath.
Definition config.hh:382
Definition fs-sink.hh:27
Definition hash.hh:45
Definition serialise.hh:20
Type
Definition source-accessor.hh:82
Definition source-path.hh:22
Definition serialise.hh:68
Definition git.hh:199
Definition git.hh:38