Enable stats on git_index_read_tree.

Replace with the contents of 
git_index_read_tree_with_stats() and improve
documentation comments.
This commit is contained in:
Ben Straub 2012-07-30 14:52:46 -07:00
parent 84595a30c0
commit 4bf5115642
6 changed files with 7 additions and 24 deletions

View File

@ -335,18 +335,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); 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 * Read a tree into the index file with stats
* *
@ -355,10 +343,10 @@ GIT_EXTERN(int) git_index_read_tree(git_index *index, git_tree *tree);
* *
* @param index an existing index object * @param index an existing index object
* @param tree tree to read * @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 * @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 GIT_END_DECL

View File

@ -191,7 +191,7 @@ int git_checkout_head(git_repository *repo, git_checkout_opts *opts, git_indexer
if (!git_repository_head_tree(&tree, repo)) { if (!git_repository_head_tree(&tree, repo)) {
git_index *idx; git_index *idx;
if (!(retcode = git_repository_index(&idx, repo))) { 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); retcode = git_tree_walk(tree, checkout_walker, GIT_TREEWALK_POST, &payload);
} }
git_index_free(idx); git_index_free(idx);

View File

@ -1020,7 +1020,7 @@ static int read_tree_cb(const char *root, const git_tree_entry *tentry, void *da
return 0; 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; git_indexer_stats dummy_stats;
read_tree_data rtd = {index, NULL}; 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); 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);
}

View File

@ -80,7 +80,7 @@ int git_reset(
goto cleanup; 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); giterr_set(GITERR_INDEX, "%s - Failed to update the index.", ERROR_MSG);
goto cleanup; goto cleanup;
} }

View File

@ -33,7 +33,7 @@ void test_index_read_tree__read_write_involution(void)
/* read-tree */ /* read-tree */
git_tree_lookup(&tree, repo, &expected); 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); git_tree_free(tree);
cl_git_pass(git_tree_create_fromindex(&tree_oid, index)); cl_git_pass(git_tree_create_fromindex(&tree_oid, index));

View File

@ -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_lookup(&commit, repo, &oid));
cl_git_pass(git_commit_tree(&tree, commit)); 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)); cl_git_pass(git_index_write(index));
git_tree_free(tree); git_tree_free(tree);