-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommit.h
50 lines (36 loc) · 1.04 KB
/
commit.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#ifndef TOG_COMMIT_H
#define TOG_COMMIT_H
#include <filesystem>
#include <optional>
#include <string>
#include "handle.h"
#include "object.h"
#include "tree.h"
namespace tog {
// A commit represents a single commit in a repository
class Commit : public TogObject {
public:
Commit(Handle<Tree> tree, std::optional<Handle<Commit>> parent,
std::string message);
const std::vector<unsigned char>& serialize();
Handle<Tree>& tree() {
return _tree;
}
const std::string& message() const {
return _message;
}
const std::optional<Handle<Commit>>& parent() {
return _parent;
}
private:
// the top-level tree of the commit (i.e. the worktree)
Handle<Tree> _tree;
// the preceding commit to this commit (if any)
std::optional<Handle<Commit>> _parent;
// the user-specified commit message
std::string _message;
// cached serialized commit, for lazy serialization
std::optional<std::vector<unsigned char>> _serialized;
};
} // namespace tog
#endif // TOG_COMMIT_H