I'm trying to upgrade to the latest gix-protocol, and so I'm dealing with changing over from the old gix_protocol::ls_refs function to the new LsRefsCommand.
My trouble here is that the documentation does not really help me figure out how to wield it properly.
I'll walk you through how I was trying to achieve this, and maybe that'll help understand where documentation could improve 😊
I have prefixes that I wanted to pass to ls_refs, at the moment they're the reference prefixes as BStrings. So, I need to turn them into RefSpec somehow, and I go to the Refspec docs, and I'm faced with:
An owned refspec.
I have no other information to follow, but thankfully I know what a refspec is. My issue is then that there are no obvious constructors. I need to find out how these are generally constructed from an API perspective.
I'm able to search docs.rs and use the "In Return Types", and see that there's a impl From for RefSpecRef.
I follow the trail to the RefSpecRef docs, and I see:
A refspec with references to the memory it was parsed from.
and again, there's no obvious information that points to how to construct one of these. So, I do the same trick again and find parse.
Unfortunately, this does not tell me what format spec should be in. I presume it follows https://git-scm.com/book/en/v2/Git-Internals-The-Refspec.
Then I check what Operation is.
It's at this point that I'm a confused about how a RefSpec is used for a prefix:
- I'm not sure how
Operation plays with LsRefsCommand, if I'm trying to ls_refs from a remote should I always use Operation::Fetch?
- How is a spec with
src and dst used to prefix references?
Before, we were passing ref-prefix <reference>, so I'm not sure how that maps to this new way/
Thanks for your help, as always!
I hope this helps guide some improvements in the documentation. Generally, the way I try to think about these things is, "How can I construct this thing?" and "How can I use this thing?"
And also, any help on the usage above would be greatly appreciated 😄 🙏
I'm trying to upgrade to the latest
gix-protocol, and so I'm dealing with changing over from the oldgix_protocol::ls_refsfunction to the newLsRefsCommand.My trouble here is that the documentation does not really help me figure out how to wield it properly.
I'll walk you through how I was trying to achieve this, and maybe that'll help understand where documentation could improve 😊
I have prefixes that I wanted to pass to
ls_refs, at the moment they're the reference prefixes asBStrings. So, I need to turn them intoRefSpecsomehow, and I go to theRefspecdocs, and I'm faced with:I have no other information to follow, but thankfully I know what a refspec is. My issue is then that there are no obvious constructors. I need to find out how these are generally constructed from an API perspective.
I'm able to search
docs.rsand use the "In Return Types", and see that there's aimpl FromforRefSpecRef.I follow the trail to the
RefSpecRefdocs, and I see:and again, there's no obvious information that points to how to construct one of these. So, I do the same trick again and find
parse.Unfortunately, this does not tell me what format
specshould be in. I presume it follows https://git-scm.com/book/en/v2/Git-Internals-The-Refspec.Then I check what
Operationis.It's at this point that I'm a confused about how a
RefSpecis used for a prefix:Operationplays withLsRefsCommand, if I'm trying tols_refsfrom a remote should I always useOperation::Fetch?srcanddstused to prefix references?Before, we were passing
ref-prefix <reference>, so I'm not sure how that maps to this new way/Thanks for your help, as always!
I hope this helps guide some improvements in the documentation. Generally, the way I try to think about these things is, "How can I construct this thing?" and "How can I use this thing?"
And also, any help on the usage above would be greatly appreciated 😄 🙏