Commit 764b9e71469f9edc0839c2cf4207ed7ab4a222ce

Vicent Martí 2013-01-28T14:54:19

Merge pull request #1289 from jwiegley/development Added git_treebuilder_entrycount

diff --git a/include/git2/tree.h b/include/git2/tree.h
index 3861102..73bfc86 100644
--- a/include/git2/tree.h
+++ b/include/git2/tree.h
@@ -259,6 +259,14 @@ GIT_EXTERN(int) git_treebuilder_create(
 GIT_EXTERN(void) git_treebuilder_clear(git_treebuilder *bld);
 
 /**
+ * Get the number of entries listed in a treebuilder
+ *
+ * @param tree a previously loaded treebuilder.
+ * @return the number of entries in the treebuilder
+ */
+GIT_EXTERN(unsigned int) git_treebuilder_entrycount(git_treebuilder *bld);
+
+/**
  * Free a tree builder
  *
  * This will clear all the entries and free to builder.
diff --git a/src/tree.c b/src/tree.c
index c34e9b9..f64ff32 100644
--- a/src/tree.c
+++ b/src/tree.c
@@ -340,6 +340,12 @@ size_t git_tree_entrycount(const git_tree *tree)
 	return tree->entries.length;
 }
 
+unsigned int git_treebuilder_entrycount(git_treebuilder *bld)
+{
+	assert(bld);
+	return bld->entries.length;
+}
+
 static int tree_error(const char *str, const char *path)
 {
 	if (path)