Nix 2.26.3
Nix, the purely functional package manager; unstable internal interfaces
 
Loading...
Searching...
No Matches
git-utils.hh
1#pragma once
2
3#include "filtering-source-accessor.hh"
4#include "fs-sink.hh"
5
6namespace nix {
7
8namespace fetchers { struct PublicKey; }
9
21
22struct GitRepo
23{
24 virtual ~GitRepo()
25 { }
26
27 static ref<GitRepo> openRepo(const std::filesystem::path & path, bool create = false, bool bare = false);
28
29 virtual uint64_t getRevCount(const Hash & rev) = 0;
30
31 virtual uint64_t getLastModified(const Hash & rev) = 0;
32
33 virtual bool isShallow() = 0;
34
35 /* Return the commit hash to which a ref points. */
36 virtual Hash resolveRef(std::string ref) = 0;
37
38 virtual void setRemote(const std::string & name, const std::string & url) = 0;
39
43 struct Submodule
44 {
45 CanonPath path;
46 std::string url;
47 std::string branch;
48 };
49
51 {
52 bool isDirty = false;
53
54 /* The checked out commit, or nullopt if there are no commits
55 in the repo yet. */
56 std::optional<Hash> headRev;
57
58 /* All files in the working directory that are unchanged,
59 modified or added, but excluding deleted files. */
60 std::set<CanonPath> files;
61
62 /* All modified or added files. */
63 std::set<CanonPath> dirtyFiles;
64
65 /* The deleted files. */
66 std::set<CanonPath> deletedFiles;
67
68 /* The submodules listed in .gitmodules of this workdir. */
69 std::vector<Submodule> submodules;
70 };
71
72 virtual WorkdirInfo getWorkdirInfo() = 0;
73
74 static WorkdirInfo getCachedWorkdirInfo(const std::filesystem::path & path);
75
76 /* Get the ref that HEAD points to. */
77 virtual std::optional<std::string> getWorkdirRef() = 0;
78
83 virtual std::vector<std::tuple<Submodule, Hash>> getSubmodules(const Hash & rev, bool exportIgnore) = 0;
84
85 virtual std::string resolveSubmoduleUrl(const std::string & url) = 0;
86
87 virtual bool hasObject(const Hash & oid) = 0;
88
89 virtual ref<SourceAccessor> getAccessor(
90 const Hash & rev,
91 bool exportIgnore,
92 std::string displayPrefix) = 0;
93
94 virtual ref<SourceAccessor> getAccessor(const WorkdirInfo & wd, bool exportIgnore, MakeNotAllowedError makeNotAllowedError) = 0;
95
96 virtual ref<GitFileSystemObjectSink> getFileSystemObjectSink() = 0;
97
98 virtual void flush() = 0;
99
100 virtual void fetch(
101 const std::string & url,
102 const std::string & refspec,
103 bool shallow) = 0;
104
109 virtual void verifyCommit(
110 const Hash & rev,
111 const std::vector<fetchers::PublicKey> & publicKeys) = 0;
112
117 virtual Hash treeHashToNarHash(const Hash & treeHash) = 0;
118
124 virtual Hash dereferenceSingletonDirectory(const Hash & oid) = 0;
125};
126
127ref<GitRepo> getTarballCache();
128
129}
Definition canon-path.hh:41
Definition ref.hh:15
Symbol create(std::string_view s)
Definition lexer.l:1018
const std::string_view & name
Definition lexer.l:1709
virtual std::optional< time_t > getLastModified()
Definition lexer.l:4585
Definition fs-sink.hh:48
Definition git-utils.hh:15
Definition git-utils.hh:44
Definition git-utils.hh:51
Definition git-utils.hh:23
virtual std::vector< std::tuple< Submodule, Hash > > getSubmodules(const Hash &rev, bool exportIgnore)=0
virtual Hash dereferenceSingletonDirectory(const Hash &oid)=0
virtual void verifyCommit(const Hash &rev, const std::vector< fetchers::PublicKey > &publicKeys)=0
virtual Hash treeHashToNarHash(const Hash &treeHash)=0
Definition hash.hh:45
Definition fetchers.hh:283