pub struct Prepare<'remote, 'repo, T, P>where
    T: Transport,
{ /* private fields */ }
Available on crate feature blocking-network-client and (crate features async-network-client or blocking-network-client) only.
Expand description

A structure to hold the result of the handshake with the remote and configure the upcoming fetch operation.

Implementations

Receive the pack and perform the operation as configured by git via git-config or overridden by various builder methods. Return Ok(None) if there was nothing to do because all remote refs are at the same state as they are locally, or Ok(Some(outcome)) to inform about all the changes that were made.

Negotiation

“fetch.negotiationAlgorithm” describes algorithms git uses currently, with the default being consecutive and skipping being experimented with. We currently implement something we could call ‘naive’ which works for now.

Pack .keep files

That packs that are freshly written to the object database are vulnerable to garbage collection for the brief time that it takes between them being placed and the respective references to be written to disk which binds their objects to the commit graph, making them reachable.

To circumvent this issue, a .keep file is created before any pack related file (i.e. .pack or .idx) is written, which indicates the garbage collector (like git maintenance, git gc) to leave the corresponding pack file alone.

If there were any ref updates or the received pack was empty, the .keep file will be deleted automatically leaving in its place at write_pack_bundle.keep_path a None. However, if no ref-update happened the path will still be present in write_pack_bundle.keep_path and is expected to be handled by the caller. A known application for this behaviour is in remote-helper implementations which should send this path via lock <path> to stdout to inform git about the file that it will remove once it updated the refs accordingly.

Deviation

When updating refs, the git-fetch docs state that the following:

Unlike when pushing with git-push, any updates outside of refs/{tags,heads}/* will be accepted without + in the refspec (or –force), whether that’s swapping e.g. a tree object for a blob, or a commit for another commit that’s doesn’t have the previous commit as an ancestor etc.

We explicitly don’t special case those refs and expect the user to take control. Note that by its nature, force only applies to refs pointing to commits and if they don’t, they will be updated either way in our implementation as well.

Return the ref_map (that includes the server handshake) which was part of listing refs prior to fetching a pack.

Builder

If dry run is enabled, no change to the repository will be made.

This works by not actually fetching the pack after negotiating it, nor will refs be updated.

Set the reflog message to use when updating refs after fetching a pack.

Trait Implementations

Executes the destructor for this type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
Should always be Self
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.