diff options
| author | Vicent Martà <vicent@github.com> | 2012-08-19 01:26:06 -0700 |
|---|---|---|
| committer | Vicent Martà <vicent@github.com> | 2012-08-19 01:26:06 -0700 |
| commit | f98c32f3fea0d5532db2d5733418aa62648b9e93 (patch) | |
| tree | 5b53901f1848d73a72765ec014e2ad5188316eb4 /src/index.c | |
| parent | 1a10fded40875f986164b80c6efd414cd1507cb8 (diff) | |
| parent | eb87800ab631d19a7655f01ece130455b1cc976a (diff) | |
| download | libgit2-f98c32f3fea0d5532db2d5733418aa62648b9e93.tar.gz | |
Merge pull request #778 from ben/clone
Clone
Diffstat (limited to 'src/index.c')
| -rw-r--r-- | src/index.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/index.c b/src/index.c index b6b1b779e..a1042b723 100644 --- a/src/index.c +++ b/src/index.c @@ -986,12 +986,19 @@ int git_index_entry_stage(const git_index_entry *entry) return (entry->flags & GIT_IDXENTRY_STAGEMASK) >> GIT_IDXENTRY_STAGESHIFT; } +typedef struct read_tree_data { + git_index *index; + git_indexer_stats *stats; +} read_tree_data; + static int read_tree_cb(const char *root, const git_tree_entry *tentry, void *data) { - git_index *index = data; + read_tree_data *rtd = data; git_index_entry *entry = NULL; git_buf path = GIT_BUF_INIT; + rtd->stats->total++; + if (git_tree_entry__is_tree(tentry)) return 0; @@ -1006,7 +1013,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(index, entry, 0) < 0) { + if (index_insert(rtd->index, entry, 0) < 0) { index_entry_free(entry); return -1; } @@ -1014,9 +1021,16 @@ 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) +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}; + + 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, index); + return git_tree_walk(tree, read_tree_cb, GIT_TREEWALK_POST, &rtd); } |
