summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2013-01-08 13:39:15 -0800
committerRussell Belfer <rb@github.com>2013-01-15 09:49:32 -0800
commit4b181037553601a0747ad39ccdd85ebd3b184055 (patch)
tree1f4bb97ad79bd9f86337d372317e68f862fa1b3c /src
parentfacc0650b12655c9637732bb992d1053cd946057 (diff)
downloadlibgit2-4b181037553601a0747ad39ccdd85ebd3b184055.tar.gz
Minor iterator API cleanups
In preparation for further iterator changes, this cleans up a few small things in the iterator API: * removed the git_iterator_for_repo_index_range API * made git_iterator_free not be inlined * minor param name and test function name tweaks
Diffstat (limited to 'src')
-rw-r--r--src/iterator.c30
-rw-r--r--src/iterator.h52
-rw-r--r--src/submodule.c4
3 files changed, 31 insertions, 55 deletions
diff --git a/src/iterator.c b/src/iterator.c
index 08e2e79e4..3d75dd8b5 100644
--- a/src/iterator.c
+++ b/src/iterator.c
@@ -485,20 +485,6 @@ int git_iterator_for_index_range(
return 0;
}
-int git_iterator_for_repo_index_range(
- git_iterator **iter,
- git_repository *repo,
- const char *start,
- const char *end)
-{
- int error;
- git_index *index;
-
- if ((error = git_repository_index__weakptr(&index, repo)) < 0)
- return error;
-
- return git_iterator_for_index_range(iter, index, start, end);
-}
typedef struct workdir_iterator_frame workdir_iterator_frame;
struct workdir_iterator_frame {
@@ -988,6 +974,22 @@ fail:
return -1;
}
+
+void git_iterator_free(git_iterator *iter)
+{
+ if (iter == NULL)
+ return;
+
+ iter->cb->free(iter);
+
+ git__free(iter->start);
+ git__free(iter->end);
+
+ memset(iter, 0, sizeof(*iter));
+
+ git__free(iter);
+}
+
git_index *git_iterator_index_get_index(git_iterator *iter)
{
if (iter->type == GIT_ITERATOR_INDEX)
diff --git a/src/iterator.h b/src/iterator.h
index 8a4356e3e..727da97b3 100644
--- a/src/iterator.h
+++ b/src/iterator.h
@@ -44,47 +44,34 @@ struct git_iterator {
bool ignore_case;
};
-extern int git_iterator_for_nothing(git_iterator **iter);
+extern int git_iterator_for_nothing(git_iterator **out);
extern int git_iterator_for_tree_range(
- git_iterator **iter, git_tree *tree,
- const char *start, const char *end);
+ git_iterator **out, git_tree *tree, const char *start, const char *end);
-GIT_INLINE(int) git_iterator_for_tree(
- git_iterator **iter, git_tree *tree)
+GIT_INLINE(int) git_iterator_for_tree(git_iterator **out, git_tree *tree)
{
- return git_iterator_for_tree_range(iter, tree, NULL, NULL);
+ return git_iterator_for_tree_range(out, tree, NULL, NULL);
}
extern int git_iterator_for_index_range(
- git_iterator **iter, git_index *index, const char *start, const char *end);
+ git_iterator **out, git_index *index, const char *start, const char *end);
-GIT_INLINE(int) git_iterator_for_index(
- git_iterator **iter, git_index *index)
+GIT_INLINE(int) git_iterator_for_index(git_iterator **out, git_index *index)
{
- return git_iterator_for_index_range(iter, index, NULL, NULL);
-}
-
-extern int git_iterator_for_repo_index_range(
- git_iterator **iter, git_repository *repo,
- const char *start, const char *end);
-
-GIT_INLINE(int) git_iterator_for_repo_index(
- git_iterator **iter, git_repository *repo)
-{
- return git_iterator_for_repo_index_range(iter, repo, NULL, NULL);
+ return git_iterator_for_index_range(out, index, NULL, NULL);
}
extern int git_iterator_for_workdir_range(
- git_iterator **iter, git_repository *repo,
- const char *start, const char *end);
+ git_iterator **out, git_repository *repo, const char *start, const char *end);
-GIT_INLINE(int) git_iterator_for_workdir(
- git_iterator **iter, git_repository *repo)
+GIT_INLINE(int) git_iterator_for_workdir(git_iterator **out, git_repository *repo)
{
- return git_iterator_for_workdir_range(iter, repo, NULL, NULL);
+ return git_iterator_for_workdir_range(out, repo, NULL, NULL);
}
+extern void git_iterator_free(git_iterator *iter);
+
/* Spool all iterator values, resort with alternative ignore_case value
* and replace callbacks with spoolandsort alternates.
*/
@@ -130,21 +117,6 @@ GIT_INLINE(int) git_iterator_reset(
return iter->cb->reset(iter, start, end);
}
-GIT_INLINE(void) git_iterator_free(git_iterator *iter)
-{
- if (iter == NULL)
- return;
-
- iter->cb->free(iter);
-
- git__free(iter->start);
- git__free(iter->end);
-
- memset(iter, 0, sizeof(*iter));
-
- git__free(iter);
-}
-
GIT_INLINE(git_iterator_type_t) git_iterator_type(git_iterator *iter)
{
return iter->type;
diff --git a/src/submodule.c b/src/submodule.c
index a72326602..5283322f2 100644
--- a/src/submodule.c
+++ b/src/submodule.c
@@ -1130,10 +1130,12 @@ static int load_submodule_config_from_index(
git_repository *repo, git_oid *gitmodules_oid)
{
int error;
+ git_index *index;
git_iterator *i;
const git_index_entry *entry;
- if ((error = git_iterator_for_repo_index(&i, repo)) < 0)
+ if ((error = git_repository_index__weakptr(&index, repo)) < 0 ||
+ (error = git_iterator_for_index(&i, index)) < 0)
return error;
error = git_iterator_current(i, &entry);