Make git_tree_clear_entries visible to the user
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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
diff --git a/src/git2/tree.h b/src/git2/tree.h
index fedf2b7..6f79ac4 100644
--- a/src/git2/tree.h
+++ b/src/git2/tree.h
@@ -205,6 +205,16 @@ GIT_EXTERN(int) git_tree_remove_entry_byindex(git_tree *tree, int idx);
GIT_EXTERN(int) git_tree_remove_entry_byname(git_tree *tree, const char *filename);
/**
+ * Clear all the entries in a tree.
+ *
+ * This will mark the tree as modified; the modified entry will
+ * be written back to disk on the next git_object_write().
+ *
+ * @param tree Tree object whose entries are to be sorted
+ */
+GIT_EXTERN(void) git_tree_clear_entries(git_tree *tree);
+
+/**
* Change the SHA1 id of a tree entry.
*
* This will mark the tree that contains the entry as modified;
diff --git a/src/tree.c b/src/tree.c
index c4def2a..605af8b 100644
--- a/src/tree.c
+++ b/src/tree.c
@@ -48,7 +48,7 @@ int entry_sort_cmp(const void *a, const void *b)
return strcmp(entry_a->filename, entry_b->filename);
}
-static void clear_entries(git_tree *tree)
+void git_tree_clear_entries(git_tree *tree)
{
unsigned int i;
@@ -64,6 +64,8 @@ static void clear_entries(git_tree *tree)
}
git_vector_clear(&tree->entries);
+
+ tree->object.modified = 1;
}
@@ -90,7 +92,7 @@ git_tree *git_tree__new(void)
void git_tree__free(git_tree *tree)
{
- clear_entries(tree);
+ git_tree_clear_entries(tree);
git_vector_free(&tree->entries);
free(tree);
}
@@ -282,7 +284,7 @@ static int tree_parse_buffer(git_tree *tree, char *buffer, char *buffer_end)
expected_size = (tree->object.source.raw.len / avg_entry_size) + 1;
- clear_entries(tree);
+ git_tree_clear_entries(tree);
while (buffer < buffer_end) {
git_tree_entry *entry;