diff options
author | Vicent Martà <vicent@github.com> | 2013-05-31 14:36:08 -0700 |
---|---|---|
committer | Vicent Martà <vicent@github.com> | 2013-05-31 14:36:08 -0700 |
commit | efd5a4e16a55ff32ce0b300d3792e44aed4157f8 (patch) | |
tree | 33fa5cceec1bbb24ab919ccb21732cd1487d4fec /src/submodule.c | |
parent | 1ed356dcfef449313bac3ce795f26d19423c744c (diff) | |
parent | cee695ae6b9a9f586d32d0b9460a358bfdc4fe1b (diff) | |
download | libgit2-vmg/full-ref-iterator.tar.gz |
Merge pull request #1627 from arrbee/iterator-api-improvementsvmg/full-ref-iterator
Make iterators use GIT_ITEROVER & smart advance
Diffstat (limited to 'src/submodule.c')
-rw-r--r-- | src/submodule.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/submodule.c b/src/submodule.c index f4fbcd35a..16114d8ac 100644 --- a/src/submodule.c +++ b/src/submodule.c @@ -1143,9 +1143,7 @@ static int load_submodule_config_from_index( (error = git_iterator_for_index(&i, index, 0, NULL, NULL)) < 0) return error; - error = git_iterator_current(&entry, i); - - while (!error && entry != NULL) { + while (!(error = git_iterator_advance(&entry, i))) { if (S_ISGITLINK(entry->mode)) { error = submodule_load_from_index(repo, entry); @@ -1158,10 +1156,11 @@ static int load_submodule_config_from_index( if (strcmp(entry->path, GIT_MODULES_FILE) == 0) git_oid_cpy(gitmodules_oid, &entry->oid); } - - error = git_iterator_advance(&entry, i); } + if (error == GIT_ITEROVER) + error = 0; + git_iterator_free(i); return error; @@ -1183,9 +1182,7 @@ static int load_submodule_config_from_head( return error; } - error = git_iterator_current(&entry, i); - - while (!error && entry != NULL) { + while (!(error = git_iterator_advance(&entry, i))) { if (S_ISGITLINK(entry->mode)) { error = submodule_load_from_head(repo, entry->path, &entry->oid); @@ -1199,10 +1196,11 @@ static int load_submodule_config_from_head( git_oid_iszero(gitmodules_oid)) git_oid_cpy(gitmodules_oid, &entry->oid); } - - error = git_iterator_advance(&entry, i); } + if (error == GIT_ITEROVER) + error = 0; + git_iterator_free(i); git_tree_free(head); |