mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-28 19:47:52 +00:00
index: remove read_tree() progress indicator
git_index_read_tree() was exposing a parameter to provide the user with a progress indicator. Unfortunately, due to the recursive nature of the tree walk, the maximum number of items to process was unknown. Thus, the indicator was only counting processed entries, without providing any information how the number of remaining items.
This commit is contained in:
parent
2b7efe0340
commit
0ae81fc479
@ -343,10 +343,9 @@ GIT_EXTERN(int) git_index_entry_stage(const git_index_entry *entry);
|
||||
*
|
||||
* @param index an existing index object
|
||||
* @param tree tree to read
|
||||
* @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(git_index *index, git_tree *tree, git_indexer_stats *stats);
|
||||
GIT_EXTERN(int) git_index_read_tree(git_index *index, git_tree *tree);
|
||||
|
||||
/** @} */
|
||||
GIT_END_DECL
|
||||
|
@ -403,7 +403,7 @@ int git_checkout_tree(
|
||||
if ((error = git_repository_index(&index, repo)) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if ((error = git_index_read_tree(index, tree, NULL)) < 0)
|
||||
if ((error = git_index_read_tree(index, tree)) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if ((error = git_index_write(index)) < 0)
|
||||
|
17
src/index.c
17
src/index.c
@ -1039,12 +1039,10 @@ typedef struct read_tree_data {
|
||||
|
||||
static int read_tree_cb(const char *root, const git_tree_entry *tentry, void *data)
|
||||
{
|
||||
read_tree_data *rtd = data;
|
||||
git_index *index = (git_index *)data;
|
||||
git_index_entry *entry = NULL;
|
||||
git_buf path = GIT_BUF_INIT;
|
||||
|
||||
rtd->stats->total++;
|
||||
|
||||
if (git_tree_entry__is_tree(tentry))
|
||||
return 0;
|
||||
|
||||
@ -1059,7 +1057,7 @@ static int read_tree_cb(const char *root, const git_tree_entry *tentry, void *da
|
||||
entry->path = git_buf_detach(&path);
|
||||
git_buf_free(&path);
|
||||
|
||||
if (index_insert(rtd->index, entry, 0) < 0) {
|
||||
if (index_insert(index, entry, 0) < 0) {
|
||||
index_entry_free(entry);
|
||||
return -1;
|
||||
}
|
||||
@ -1067,16 +1065,9 @@ static int read_tree_cb(const char *root, const git_tree_entry *tentry, void *da
|
||||
return 0;
|
||||
}
|
||||
|
||||
int git_index_read_tree(git_index *index, git_tree *tree, git_indexer_stats *stats)
|
||||
int git_index_read_tree(git_index *index, git_tree *tree)
|
||||
{
|
||||
git_indexer_stats dummy_stats;
|
||||
read_tree_data rtd = {index, NULL};
|
||||
|
||||
if (!stats) stats = &dummy_stats;
|
||||
stats->total = 0;
|
||||
rtd.stats = stats;
|
||||
|
||||
git_index_clear(index);
|
||||
|
||||
return git_tree_walk(tree, read_tree_cb, GIT_TREEWALK_POST, &rtd);
|
||||
return git_tree_walk(tree, read_tree_cb, GIT_TREEWALK_POST, index);
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ int git_reset(
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (git_index_read_tree(index, tree, NULL) < 0) {
|
||||
if (git_index_read_tree(index, tree) < 0) {
|
||||
giterr_set(GITERR_INDEX, "%s - Failed to update the index.", ERROR_MSG);
|
||||
goto cleanup;
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ static void reset_index_to_treeish(git_object *treeish)
|
||||
cl_git_pass(git_object_peel(&tree, treeish, GIT_OBJ_TREE));
|
||||
|
||||
cl_git_pass(git_repository_index(&index, g_repo));
|
||||
cl_git_pass(git_index_read_tree(index, (git_tree *)tree, NULL));
|
||||
cl_git_pass(git_index_read_tree(index, (git_tree *)tree));
|
||||
cl_git_pass(git_index_write(index));
|
||||
|
||||
git_object_free(tree);
|
||||
|
@ -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, NULL));
|
||||
cl_git_pass(git_index_read_tree(index, tree));
|
||||
git_tree_free(tree);
|
||||
|
||||
cl_git_pass(git_tree_create_fromindex(&tree_oid, index));
|
||||
|
@ -486,7 +486,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, NULL));
|
||||
cl_git_pass(git_index_read_tree(index, tree));
|
||||
cl_git_pass(git_index_write(index));
|
||||
|
||||
git_tree_free(tree);
|
||||
|
Loading…
Reference in New Issue
Block a user