summaryrefslogtreecommitdiff
path: root/src/checkout.c
diff options
context:
space:
mode:
authorVicent Martí <vicent@github.com>2013-05-31 14:36:08 -0700
committerVicent Martí <vicent@github.com>2013-05-31 14:36:08 -0700
commitefd5a4e16a55ff32ce0b300d3792e44aed4157f8 (patch)
tree33fa5cceec1bbb24ab919ccb21732cd1487d4fec /src/checkout.c
parent1ed356dcfef449313bac3ce795f26d19423c744c (diff)
parentcee695ae6b9a9f586d32d0b9460a358bfdc4fe1b (diff)
downloadlibgit2-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/checkout.c')
-rw-r--r--src/checkout.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/src/checkout.c b/src/checkout.c
index c28fcdee0..7a2e68300 100644
--- a/src/checkout.c
+++ b/src/checkout.c
@@ -495,12 +495,9 @@ static int checkout_action(
if (cmp == 0) {
if (wd->mode == GIT_FILEMODE_TREE) {
/* case 2 - entry prefixed by workdir tree */
- if ((error = git_iterator_advance_into(&wd, workdir)) < 0) {
- if (error != GIT_ENOTFOUND ||
- git_iterator_advance(&wd, workdir) < 0)
- goto fail;
- }
-
+ error = git_iterator_advance_into_or_over(&wd, workdir);
+ if (error && error != GIT_ITEROVER)
+ goto fail;
*wditem_ptr = wd;
continue;
}
@@ -515,8 +512,10 @@ static int checkout_action(
}
/* case 1 - handle wd item (if it matches pathspec) */
- if (checkout_action_wd_only(data, workdir, wd, pathspec) < 0 ||
- git_iterator_advance(&wd, workdir) < 0)
+ if (checkout_action_wd_only(data, workdir, wd, pathspec) < 0)
+ goto fail;
+ if ((error = git_iterator_advance(&wd, workdir)) < 0 &&
+ error != GIT_ITEROVER)
goto fail;
*wditem_ptr = wd;
@@ -539,8 +538,9 @@ static int checkout_action(
if (delta->status == GIT_DELTA_TYPECHANGE) {
if (delta->old_file.mode == GIT_FILEMODE_TREE) {
act = checkout_action_with_wd(data, delta, wd);
- if (git_iterator_advance_into(&wd, workdir) < 0)
- wd = NULL;
+ if ((error = git_iterator_advance_into(&wd, workdir)) < 0 &&
+ error != GIT_ENOTFOUND)
+ goto fail;
*wditem_ptr = wd;
return act;
}
@@ -550,8 +550,9 @@ static int checkout_action(
delta->old_file.mode == GIT_FILEMODE_COMMIT)
{
act = checkout_action_with_wd(data, delta, wd);
- if (git_iterator_advance(&wd, workdir) < 0)
- wd = NULL;
+ if ((error = git_iterator_advance(&wd, workdir)) < 0 &&
+ error != GIT_ITEROVER)
+ goto fail;
*wditem_ptr = wd;
return act;
}
@@ -582,6 +583,9 @@ static int checkout_remaining_wd_items(
error = git_iterator_advance(&wd, workdir);
}
+ if (error == GIT_ITEROVER)
+ error = 0;
+
return error;
}
@@ -603,7 +607,8 @@ static int checkout_get_actions(
git_pathspec_init(&pathspec, &data->opts.paths, &pathpool) < 0)
return -1;
- if ((error = git_iterator_current(&wditem, workdir)) < 0)
+ if ((error = git_iterator_current(&wditem, workdir)) < 0 &&
+ error != GIT_ITEROVER)
goto fail;
deltas = &data->diff->deltas;