-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Conversation
Dude, @ethomson has just rewritten the whole reference backend. You might want to base this concept on top of his branch. :) |
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, |
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 |
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. |
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 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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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!
This is very pretty indeed. |
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.
Introduce a refs iterator
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.