Commit 0be421994e34e2d8e200f15b64894dd0c09c4eec

Scott Chacon 2010-11-10T13:43:55

accessor for index entry count

diff --git a/src/git/index.h b/src/git/index.h
index bdfb7e1..8220e62 100644
--- a/src/git/index.h
+++ b/src/git/index.h
@@ -147,6 +147,14 @@ GIT_EXTERN(int) git_index_add(git_index *index, const git_index_entry *source_en
  */
 GIT_EXTERN(git_index_entry *) git_index_get(git_index *index, int n);
 
+/**
+ * Get the count of entries currently in the index
+ *
+ * @param index an existing index object
+ * @return integer of count of current entries
+ */
+GIT_EXTERN(unsigned int) git_index_entrycount(git_index *index);
+
 
 /** @} */
 GIT_END_DECL
diff --git a/src/index.c b/src/index.c
index 77de0a8..ed85f91 100644
--- a/src/index.c
+++ b/src/index.c
@@ -221,6 +221,12 @@ int git_index_write(git_index *index)
 	return 0;
 }
 
+unsigned int git_index_entrycount(git_index *index)
+{
+	assert(index);
+	return index->entry_count;
+}
+
 git_index_entry *git_index_get(git_index *index, int n)
 {
 	assert(index);