forked from p-ranav/cppgit2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrefdb.hpp
More file actions
40 lines (33 loc) · 984 Bytes
/
Copy pathrefdb.hpp
File metadata and controls
40 lines (33 loc) · 984 Bytes
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
#pragma once
#include <git2.h>
#include <cppgit2/git_exception.hpp>
#include <cppgit2/libgit2_api.hpp>
#include <cppgit2/ownership.hpp>
#include <string>
namespace cppgit2 {
class refdb : public libgit2_api {
public:
// Default constructor
// Initializes libgit2
refdb() : owner_(ownership::libgit2), c_ptr_(nullptr) {}
// Construct from C API
refdb(git_refdb* c_ptr, ownership owner = ownership::libgit2)
: c_ptr_(c_ptr), owner_(owner) {}
// Free if owned by user
~refdb() {
if (c_ptr_ && owner_ == ownership::user)
git_refdb_free(c_ptr_);
}
// Suggests that the given refdb compress or optimize its references.
// This mechanism is implementation specific. For on-disk reference
// databases, for example, this may pack all loose references.
void compress() {
if (git_refdb_compress(c_ptr_))
throw git_exception();
}
private:
friend class repository;
ownership owner_;
git_refdb* c_ptr_;
};
} // namespace cppgit2