Skip to content

Commit b924adf

Browse files
committed
Add missing copy constructor for tree::entry
1 parent f1475c3 commit b924adf

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

include/cppgit2/tree.hpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,17 @@ class tree : public libgit2_api {
3535
// Default construction
3636
entry() : c_ptr_(nullptr), owner_(ownership::libgit2) {}
3737

38+
// copy constructor
39+
entry(const entry &e)
40+
: c_ptr_(e.c_ptr_), owner_(e.owner_) {
41+
42+
if (c_ptr_ && owner_ == ownership::user) {
43+
if (git_tree_entry_dup(&c_ptr_, e.c_ptr_)){
44+
throw git_exception();
45+
}
46+
}
47+
}
48+
3849
// Construct from libgit2 C ptr
3950
// If owned by user, will be free'd in destructor
4051
entry(git_tree_entry *c_ptr, ownership owner = ownership::libgit2)

0 commit comments

Comments
 (0)