#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[cfg(any(feature = "blocking-network-client", feature = "async-network-client"))]
pub(crate) enum DryRun {
Yes,
No,
}
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[cfg(any(feature = "blocking-network-client", feature = "async-network-client"))]
pub(crate) enum WritePackedRefs {
Never,
Only,
}
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum Tags {
All,
Included,
None,
}
impl Default for Tags {
fn default() -> Self {
Tags::Included
}
}
impl Tags {
pub fn to_refspec(&self) -> Option<git_refspec::RefSpecRef<'static>> {
match self {
Tags::All | Tags::Included => Some(
git_refspec::parse("refs/tags/*:refs/tags/*".into(), git_refspec::parse::Operation::Fetch)
.expect("valid"),
),
Tags::None => None,
}
}
}
#[derive(Default, Debug, Clone)]
#[cfg(any(feature = "blocking-network-client", feature = "async-network-client"))]
pub struct RefMap {
pub mappings: Vec<Mapping>,
pub extra_refspecs: Vec<git_refspec::RefSpec>,
pub fixes: Vec<git_refspec::match_group::validate::Fix>,
pub remote_refs: Vec<git_protocol::handshake::Ref>,
pub handshake: git_protocol::handshake::Outcome,
pub object_hash: git_hash::Kind,
}
#[derive(Debug, Clone)]
#[cfg(any(feature = "blocking-network-client", feature = "async-network-client"))]
pub enum Source {
ObjectId(git_hash::ObjectId),
Ref(git_protocol::handshake::Ref),
}
#[cfg(any(feature = "blocking-network-client", feature = "async-network-client"))]
impl Source {
pub fn as_id(&self) -> Option<&git_hash::oid> {
match self {
Source::ObjectId(id) => Some(id),
Source::Ref(r) => r.unpack().1,
}
}
pub fn as_name(&self) -> Option<&crate::bstr::BStr> {
match self {
Source::ObjectId(_) => None,
Source::Ref(r) => match r {
git_protocol::handshake::Ref::Unborn { full_ref_name, .. }
| git_protocol::handshake::Ref::Symbolic { full_ref_name, .. }
| git_protocol::handshake::Ref::Direct { full_ref_name, .. }
| git_protocol::handshake::Ref::Peeled { full_ref_name, .. } => Some(full_ref_name.as_ref()),
},
}
}
}
#[cfg(any(feature = "blocking-network-client", feature = "async-network-client"))]
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, Ord, PartialOrd)]
pub enum SpecIndex {
ExplicitInRemote(usize),
Implicit(usize),
}
#[cfg(any(feature = "blocking-network-client", feature = "async-network-client"))]
impl SpecIndex {
pub fn get<'a>(
self,
refspecs: &'a [git_refspec::RefSpec],
extra_refspecs: &'a [git_refspec::RefSpec],
) -> Option<&'a git_refspec::RefSpec> {
match self {
SpecIndex::ExplicitInRemote(idx) => refspecs.get(idx),
SpecIndex::Implicit(idx) => extra_refspecs.get(idx),
}
}
pub fn implicit_index(self) -> Option<usize> {
match self {
SpecIndex::Implicit(idx) => Some(idx),
SpecIndex::ExplicitInRemote(_) => None,
}
}
}
#[derive(Debug, Clone)]
#[cfg(any(feature = "blocking-network-client", feature = "async-network-client"))]
pub struct Mapping {
pub remote: Source,
pub local: Option<crate::bstr::BString>,
pub spec_index: SpecIndex,
}
#[cfg(any(feature = "blocking-network-client", feature = "async-network-client"))]
pub use super::connection::fetch::{negotiate, prepare, refs, Error, Outcome, Prepare, RefLogMessage, Status};