Commit b85929c523d7e61ba76715199831ec05089dc844

Carlos Martín Nieto 2016-11-14T12:44:01

tree: use the sorted update list in our loop The loop is made with the assumption that the inputs are sorted and not using it leads to bad outputs.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
diff --git a/src/tree.c b/src/tree.c
index e338acc..b67b162 100644
--- a/src/tree.c
+++ b/src/tree.c
@@ -1164,8 +1164,8 @@ int git_tree_create_updated(git_oid *out, git_repository *repo, git_tree *baseli
 		goto cleanup;
 
 	for (i = 0; i < nupdates; i++) {
-		const git_tree_update *last_update = i == 0 ? NULL : &updates[i-1];
-		const git_tree_update *update = &updates[i];
+		const git_tree_update *last_update = i == 0 ? NULL : git_vector_get(&entries, i-1);
+		const git_tree_update *update = git_vector_get(&entries, i);
 		size_t common_prefix = 0, steps_up, j;
 		const char *path;