Function git_protocol::handshake::refs::from_v2_refs
source · pub fn from_v2_refs(
in_refs: &mut dyn ReadlineBufRead
) -> Result<Vec<Ref>, Error>
Available on crate feature
blocking-client
and (crate features blocking-client
or async-client
) only.Expand description
Parse refs from the given input line by line. Protocol V2 is required for this to succeed.
Examples found in repository?
src/ls_refs.rs (line 101)
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
pub async fn ls_refs(
mut transport: impl Transport,
capabilities: &Capabilities,
prepare_ls_refs: impl FnOnce(
&Capabilities,
&mut Vec<BString>,
&mut Vec<(&str, Option<Cow<'static, str>>)>,
) -> std::io::Result<Action>,
progress: &mut impl Progress,
) -> Result<Vec<Ref>, Error> {
let ls_refs = Command::LsRefs;
let mut ls_features = ls_refs.default_features(git_transport::Protocol::V2, capabilities);
let mut ls_args = ls_refs.initial_arguments(&ls_features);
if capabilities
.capability("ls-refs")
.and_then(|cap| cap.supports("unborn"))
.unwrap_or_default()
{
ls_args.push("unborn".into());
}
let refs = match prepare_ls_refs(capabilities, &mut ls_args, &mut ls_features) {
Ok(Action::Skip) => Vec::new(),
Ok(Action::Continue) => {
ls_refs.validate_argument_prefixes_or_panic(
git_transport::Protocol::V2,
capabilities,
&ls_args,
&ls_features,
);
progress.step();
progress.set_name("list refs");
let mut remote_refs = transport
.invoke(
ls_refs.as_str(),
ls_features.into_iter(),
if ls_args.is_empty() {
None
} else {
Some(ls_args.into_iter())
},
)
.await?;
from_v2_refs(&mut remote_refs).await?
}
Err(err) => {
indicate_end_of_interaction(transport).await?;
return Err(err.into());
}
};
Ok(refs)
}