Skip to content

Commit 92e1b05

Browse files
committed
Fix bad population of tree:entries() result
1 parent 772afc2 commit 92e1b05

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

include/cppgit2/tree.hpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ class tree : public libgit2_api {
3333
class entry : public libgit2_api {
3434
public:
3535
// Default construction
36-
entry() : c_ptr_(nullptr), owner_(ownership::libgit2) {}
36+
entry() : c_ptr_(nullptr), owner_(ownership::libgit2) {
37+
}
3738

3839
// copy constructor
3940
entry(const entry &e)
@@ -49,11 +50,13 @@ class tree : public libgit2_api {
4950
// Construct from libgit2 C ptr
5051
// If owned by user, will be free'd in destructor
5152
entry(git_tree_entry *c_ptr, ownership owner = ownership::libgit2)
52-
: c_ptr_(c_ptr), owner_(owner) {}
53+
: c_ptr_(c_ptr), owner_(owner) {
54+
}
5355

5456
entry(const git_tree_entry *c_ptr)
5557
: c_ptr_(const_cast<git_tree_entry *>(c_ptr)),
56-
owner_(ownership::libgit2) {}
58+
owner_(ownership::libgit2) {
59+
}
5760

5861
// Clean up tree entry
5962
~entry() {
@@ -134,7 +137,7 @@ class tree : public libgit2_api {
134137
entry lookup_entry_by_index(size_t index) const;
135138

136139
// Lookup tree entry by its filename
137-
// Returned entry is owned by the tree
140+
// Returned entry is owned by the tree
138141
entry lookup_entry_by_name(const std::string &filename) const;
139142

140143
// Lookup tree entry given its relative path
@@ -143,11 +146,11 @@ class tree : public libgit2_api {
143146

144147
// Number of entries in tree
145148
size_t size() const;
146-
149+
147150
// get a vector of all tree entries
148151
std::vector<entry> entries() {
149152
auto size_= size();
150-
auto result = std::vector<entry>(size_);
153+
auto result = std::vector<entry>();
151154
for (size_t i=0; i < size_ ; i++) {
152155
result.push_back(lookup_entry_by_index(i));
153156
}

0 commit comments

Comments
 (0)