# Module cargo::sources::git::utils

source ·
Expand description

Utilities for handling git repositories, mainly around authentication/cloning.

## Structs

- GitCheckout
  `GitCheckout` is a local checkout of a particular revision. Calling `clone_into` with a reference will resolve the reference into a revision, and return an `anyhow::Error` if no revision for that reference was found.
- GitDatabase
  `GitDatabase` is a local clone of a remote repository’s database. Multiple `GitCheckouts` can be cloned from this `GitDatabase`.
- GitRemote
  `GitRemote` represents a remote repository. It gets cloned into a local `GitDatabase`.
- GitShortID

## Enums

- FastPathRev 🔒

## Functions

- clean_repo_temp_files 🔒
  Removes temporary files left from previous activity.
- fetch
  Note that `history` is a complex computed value to determine whether it’s acceptable to perform shallow clones at all. It’s needed to allow the caller to determine the correct position of the destination repository or move it into place should its position change.
- fetch_with_cli 🔒
- github_fast_path 🔒
  Updating the index is done pretty regularly so we want it to be as fast as possible. For registries hosted on GitHub (like the crates.io index) there’s a fast path available to use 1 to tell us that there’s no updates to be made.
- has_shallow_lock_file 🔒
  `gitoxide` uses shallow locks to assure consistency when fetching to and to avoid races, and to write files atomically. Cargo has its own lock files and doesn’t need that mechanism for race protection, so a stray lock means a signal interrupted a previous shallow fetch and doesn’t mean a race is happening.
- init 🔒
- is_github 🔒
- is_short_hash_of 🔒
- looks_like_commit_hash 🔒
- maybe_gc_repo 🔒
  Cargo has a bunch of long-lived git repositories in its global cache and some, like the index, are updated very frequently. Right now each update creates a new “pack file” inside the git database, and over time this can cause bad performance and bad current behavior in libgit2.
- reinitialize 🔒
- reset 🔒
- serialize_str 🔒
- with_authentication 🔒
  Prepare the authentication callbacks for cloning a git repository.
- with_fetch_options