diff options
author | Russell Belfer <rb@github.com> | 2013-03-06 15:16:34 -0800 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2013-03-06 16:52:01 -0800 |
commit | 9bea03ce776ed864b0556815d94d71d300ac1da3 (patch) | |
tree | 128cf7d4beaf62cafbd5bd92818f5947d5883f8f /src/checkout.c | |
parent | cc216a01ee512a41320056efc9b588daf9129f7a (diff) | |
download | libgit2-9bea03ce776ed864b0556815d94d71d300ac1da3.tar.gz |
Add INCLUDE_TREES, DONT_AUTOEXPAND iterator flags
This standardizes iterator behavior across all three iterators
(index, tree, and working directory). Previously the working
directory iterator behaved differently from the other two.
Each iterator can now operate in one of three modes:
1. *No tree results, auto expand trees* means that only non-
tree items will be returned and when a tree/directory is
encountered, we will automatically descend into it.
2. *Tree results, auto expand trees* means that results will
be given for every item found, including trees, but you
only need to call normal git_iterator_advance to yield
every item (i.e. trees returned with pre-order iteration).
3. *Tree results, no auto expand* means that calling the
normal git_iterator_advance when looking at a tree will
not descend into the tree, but will skip over it to the
next entry in the parent.
Previously, behavior 1 was the only option for index and tree
iterators, and behavior 3 was the only option for workdir.
The main public API implications of this are that the
`git_iterator_advance_into()` call is now valid for all
iterators, not just working directory iterators, and all the
existing uses of working directory iterators explicitly use
the GIT_ITERATOR_DONT_AUTOEXPAND (for now).
Interestingly, the majority of the implementation was in the
index iterator, since there are no tree entries there and now
have to fake them. The tree and working directory iterators
only required small modifications.
Diffstat (limited to 'src/checkout.c')
-rw-r--r-- | src/checkout.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/checkout.c b/src/checkout.c index 41de0d7d4..68ebbe31d 100644 --- a/src/checkout.c +++ b/src/checkout.c @@ -1243,7 +1243,8 @@ int git_checkout_iterator( if ((error = git_iterator_reset(target, data.pfx, data.pfx)) < 0 || (error = git_iterator_for_workdir( - &workdir, data.repo, iterflags, data.pfx, data.pfx)) < 0 || + &workdir, data.repo, iterflags | GIT_ITERATOR_DONT_AUTOEXPAND, + data.pfx, data.pfx)) < 0 || (error = git_iterator_for_tree( &baseline, data.opts.baseline, iterflags, data.pfx, data.pfx)) < 0) goto cleanup; |