Commit 7064cdafbd25f66de016467b381d9f4474fba40a

Vicent Marti 2014-06-10T12:56:11

Merge pull request #2416 from libgit2/cmn/treebuilder-insert-sorted treebuilder: insert sorted

diff --git a/src/tree.c b/src/tree.c
index 94f779e..b64efe4 100644
--- a/src/tree.c
+++ b/src/tree.c
@@ -460,7 +460,7 @@ static int append_entry(
 	git_oid_cpy(&entry->oid, id);
 	entry->attr = (uint16_t)filemode;
 
-	if (git_vector_insert(&bld->entries, entry) < 0) {
+	if (git_vector_insert_sorted(&bld->entries, entry, NULL) < 0) {
 		git__free(entry);
 		return -1;
 	}
@@ -671,7 +671,7 @@ int git_treebuilder_insert(
 		entry = alloc_entry(filename);
 		GITERR_CHECK_ALLOC(entry);
 
-		if (git_vector_insert(&bld->entries, entry) < 0) {
+		if (git_vector_insert_sorted(&bld->entries, entry, NULL) < 0) {
 			git__free(entry);
 			return -1;
 		}