pub fn fetch<P, T, E>(
negotiate: &mut impl Negotiate,
consume_pack: impl FnOnce(&mut dyn BufRead, &mut dyn DynNestedProgress, &AtomicBool) -> Result<bool, E>,
progress: P,
should_interrupt: &AtomicBool,
_: Context<'_, T>,
_: Options<'_>,
) -> Result<Option<Outcome>, Error>where
P: NestedProgress,
P::SubProgress: 'static,
T: Transport,
E: Into<Box<dyn Error + Send + Sync + 'static>>,
blocking-client
or async-client
) and crate feature fetch
only.Expand description
Perform one fetch operation, relying on a transport
.
negotiate
is used to run the negotiation of objects that should be contained in the pack, if one is to be received.
progress
and should_interrupt
is passed to all potentially long-running parts of the operation.
consume_pack(pack_read, progress, interrupt) -> bool
is always called to consume all bytes that are sent by the server, returning true
if we should assure the pack is read to the end,
or false
to do nothing. Dropping the reader without reading to EOF (i.e. returning false
) is an offense to the server, and
transport
won’t be in the correct state to perform additional operations, or indicate the end of operation.
Note that the passed reader blocking as the pack-writing is blocking as well.
The Context
and Options
further define parts of this fetch
operation.
As opposed to a full git fetch
, this operation does not…
- …update local refs
- …end the interaction after the fetch
Note that the interaction will never be ended, even on error or failure, leaving it up to the caller to do that, maybe
with the help of SendFlushOnDrop
which can wrap transport
.
Generally, the transport
is left in a state that allows for more commands to be run.
Return Ok(None)
if there was nothing to do because all remote refs are at the same state as they are locally,
or there was nothing wanted, or Ok(Some(outcome))
to inform about all the changes that were made.