Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Introduce a refs iterator #1385

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
May 11, 2013
Merged

Introduce a refs iterator #1385

merged 9 commits into from
May 11, 2013

Conversation

carlosmn
Copy link
Member

@carlosmn carlosmn commented Mar 2, 2013

This is a proof-of-concept for #1384. It's only tested as far as it compiles, but the idea is there. For loose refs, we might also need a path iterator.

As we're about to merge the refs backend work, I'll be holding off until that's done to see how it fits in that. This would then become part of the file-based backend.

@vmg
Copy link
Member

vmg commented Mar 2, 2013

Dude, @ethomson has just rewritten the whole reference backend. You might want to base this concept on top of his branch. :)

@carlosmn
Copy link
Member Author

carlosmn commented Mar 2, 2013

Right, but the packed/loose code stays as-is, no? Just moved into a backend? This code would move there then, just with slightly different function names. The reference "front"-end, git_reference_next() et al. would just call the backend's ->next() so that'd be a few lines there that call this code.

@carlosmn
Copy link
Member Author

carlosmn commented Mar 2, 2013

This is now based on top of Ed's refdb work. I'm not sure what to do with the iterator object, or if we should have a function like git_reference_iter_next() instead of adding a function to the refdb interface.

@carlosmn
Copy link
Member Author

carlosmn commented May 3, 2013

I've updated this and made it work.

It still needs a test to make sure we don't crash and burn when the refdb doesn't have any backends, but turns out that writing that test makes it crash and burn because of the namespaces, so I've left it for now.

@carlosmn
Copy link
Member Author

carlosmn commented May 4, 2013

The scope of this might be getting a bit out of hand, so I'll stop converting functions.

Glob matching is done in the frontend if the backend doesn't provide support for it; and the _foreach functions are siimply wrappers around the iterators.

I've also removed the stupid OID/SYMBOLIC filtering rules, so every binding is going to break.

@@ -427,7 +427,7 @@ int git_tag_foreach(git_repository *repo, git_tag_foreach_cb cb, void *cb_data)
data.cb_data = cb_data;
data.repo = repo;

return git_reference_foreach(repo, GIT_REF_OID, &tags_cb, &data);
return git_reference_foreach(repo, &tags_cb, &data);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you kill off the oid/symbolic filtering, I think that the tag iterator will need to load the reference and and filter out symbolic refs.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there some rule that says a tag can't be a symref?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

git is fine with symrefs as tags

% git symbolic-ref refs/tags/sometag refs/heads/master
% git tag
sometag

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then you fixed a bug! I'm really glad to see that filter gone then.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm really glad to see that filter gone

So am I!

@ethomson
Copy link
Member

This is very pretty indeed.

carlosmn added 9 commits May 11, 2013 11:20
This allows us to get a list of reference names in a loop instead of callbacks.
Selecting wether to list loose or packed references is not something
we want to support anymore, so remove a test for this.
Nobody should ever be using anything other than ALL at this level, so
remove the option altogether.

As part of this, git_reference_foreach_glob is now implemented in the
frontend using an iterator. Backends will later regain the ability of
doing the glob filtering in the backend.
If the backend doesn't provide support for it, the matching is done in
refdb on top of a normal iterator.
ethomson pushed a commit that referenced this pull request May 11, 2013
@ethomson ethomson merged commit b6cc559 into libgit2:development May 11, 2013
@carlosmn carlosmn deleted the refs-iter branch May 11, 2013 09:44
phatblat pushed a commit to phatblat/libgit2 that referenced this pull request Sep 13, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants