Enable stats on git_index_read_tree. Replace with the contents of git_index_read_tree_with_stats() and improve documentation comments.
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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
diff --git a/include/git2/index.h b/include/git2/index.h
index 85f8cfc..c88a170 100644
--- a/include/git2/index.h
+++ b/include/git2/index.h
@@ -336,18 +336,6 @@ GIT_EXTERN(const git_index_entry_unmerged *) git_index_get_unmerged_byindex(git_
GIT_EXTERN(int) git_index_entry_stage(const git_index_entry *entry);
/**
- * Read a tree into the index file
- *
- * The current index contents will be replaced by the specified tree.
- *
- * @param index an existing index object
- * @param tree tree to read
- * @return 0 or an error code
- */
-GIT_EXTERN(int) git_index_read_tree(git_index *index, git_tree *tree);
-
-
-/**
* Read a tree into the index file with stats
*
* The current index contents will be replaced by the specified tree. The total
@@ -355,10 +343,10 @@ GIT_EXTERN(int) git_index_read_tree(git_index *index, git_tree *tree);
*
* @param index an existing index object
* @param tree tree to read
- * @param stats structure that receives the total node count
+ * @param stats structure that receives the total node count (may be NULL)
* @return 0 or an error code
*/
-GIT_EXTERN(int) git_index_read_tree_with_stats(git_index *index, git_tree *tree, git_indexer_stats *stats);
+GIT_EXTERN(int) git_index_read_tree(git_index *index, git_tree *tree, git_indexer_stats *stats);
/** @} */
GIT_END_DECL
diff --git a/src/checkout.c b/src/checkout.c
index 3eed002..87116ba 100644
--- a/src/checkout.c
+++ b/src/checkout.c
@@ -191,7 +191,7 @@ int git_checkout_head(git_repository *repo, git_checkout_opts *opts, git_indexer
if (!git_repository_head_tree(&tree, repo)) {
git_index *idx;
if (!(retcode = git_repository_index(&idx, repo))) {
- if (!(retcode = git_index_read_tree_with_stats(idx, tree, stats))) {
+ if (!(retcode = git_index_read_tree(idx, tree, stats))) {
retcode = git_tree_walk(tree, checkout_walker, GIT_TREEWALK_POST, &payload);
}
git_index_free(idx);
diff --git a/src/index.c b/src/index.c
index 434c1f1..5f62065 100644
--- a/src/index.c
+++ b/src/index.c
@@ -1020,7 +1020,7 @@ static int read_tree_cb(const char *root, const git_tree_entry *tentry, void *da
return 0;
}
-int git_index_read_tree_with_stats(git_index *index, git_tree *tree, git_indexer_stats *stats)
+int git_index_read_tree(git_index *index, git_tree *tree, git_indexer_stats *stats)
{
git_indexer_stats dummy_stats;
read_tree_data rtd = {index, NULL};
@@ -1033,8 +1033,3 @@ int git_index_read_tree_with_stats(git_index *index, git_tree *tree, git_indexer
return git_tree_walk(tree, read_tree_cb, GIT_TREEWALK_POST, &rtd);
}
-
-int git_index_read_tree(git_index *index, git_tree *tree)
-{
- return git_index_read_tree_with_stats(index, tree, NULL);
-}
diff --git a/src/reset.c b/src/reset.c
index 14f7a23..1379f64 100644
--- a/src/reset.c
+++ b/src/reset.c
@@ -80,7 +80,7 @@ int git_reset(
goto cleanup;
}
- if (git_index_read_tree(index, tree) < 0) {
+ if (git_index_read_tree(index, tree, NULL) < 0) {
giterr_set(GITERR_INDEX, "%s - Failed to update the index.", ERROR_MSG);
goto cleanup;
}
diff --git a/tests-clar/index/read_tree.c b/tests-clar/index/read_tree.c
index c657d4f..0479332 100644
--- a/tests-clar/index/read_tree.c
+++ b/tests-clar/index/read_tree.c
@@ -33,7 +33,7 @@ void test_index_read_tree__read_write_involution(void)
/* read-tree */
git_tree_lookup(&tree, repo, &expected);
- cl_git_pass(git_index_read_tree(index, tree));
+ cl_git_pass(git_index_read_tree(index, tree, NULL));
git_tree_free(tree);
cl_git_pass(git_tree_create_fromindex(&tree_oid, index));
diff --git a/tests-clar/status/worktree.c b/tests-clar/status/worktree.c
index d84cb77..6e21e44 100644
--- a/tests-clar/status/worktree.c
+++ b/tests-clar/status/worktree.c
@@ -484,7 +484,7 @@ static void fill_index_wth_head_entries(git_repository *repo, git_index *index)
cl_git_pass(git_commit_lookup(&commit, repo, &oid));
cl_git_pass(git_commit_tree(&tree, commit));
- cl_git_pass(git_index_read_tree(index, tree));
+ cl_git_pass(git_index_read_tree(index, tree, NULL));
cl_git_pass(git_index_write(index));
git_tree_free(tree);