packbuilder: add accessors for the number of total and written objects
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 41 42 43 44 45 46
diff --git a/include/git2/pack.h b/include/git2/pack.h
index 7e28a67..94d5fc6 100644
--- a/include/git2/pack.h
+++ b/include/git2/pack.h
@@ -88,6 +88,20 @@ GIT_EXTERN(int) git_packbuilder_write(git_packbuilder *pb, const char *file);
GIT_EXTERN(int) git_packbuilder_foreach(git_packbuilder *pb, int (*cb)(void *buf, size_t size, void *data), void *data);
/**
+ * Get the total number of objects the packbuilder will write out
+ *
+ * @param pb the packbuilder
+ */
+GIT_EXTERN(uint32_t) git_packbuilder_object_count(git_packbuilder *pb);
+
+/**
+ * Get the number of objects the packbuilder has already written out
+ *
+ * @param pb the packbuilder
+ */
+GIT_EXTERN(uint32_t) git_packbuilder_written(git_packbuilder *pb);
+
+/**
* Free the packbuilder and all associated data
*
* @param pb The packbuilder
diff --git a/src/pack-objects.c b/src/pack-objects.c
index 8861084..7136d87 100644
--- a/src/pack-objects.c
+++ b/src/pack-objects.c
@@ -1292,6 +1292,16 @@ int git_packbuilder_insert_tree(git_packbuilder *pb, const git_oid *oid)
return 0;
}
+uint32_t git_packbuilder_object_count(git_packbuilder *pb)
+{
+ return pb->nr_objects;
+}
+
+uint32_t git_packbuilder_written(git_packbuilder *pb)
+{
+ return pb->nr_written;
+}
+
void git_packbuilder_free(git_packbuilder *pb)
{
if (pb == NULL)