pub struct Repo { /* private fields */ }
Expand description

Wrapper around git2::Repository.

Implementations

Get the Git repository associated with the given directory.

Get the Git repository associated with the current directory.

Open a new copy of the repository.

Get the path to the .git directory for the repository.

Get the path to the packed-refs file for the repository.

Get the path to the directory inside the .git directory which contains state used for the current rebase (if any).

Get the path to the working copy for this repository. If the repository is bare (has no working copy), returns None.

Get the index file for this repository.

Get the configuration object for the repository.

Warning: This object should only be used for read operations. Write operations should go to the config file under the .git/branchless directory.

Get the file where git-branchless-specific Git configuration is stored.

Get the directory where the DAG for the repository is stored.

Get the directory to store man-pages. Note that this is the man directory, and not a subsection thereof. git-branchless man-pages must go into the man/man1 directory to be found by man.

Get a directory suitable for storing temporary files.

In particular, this directory is guaranteed to be on the same filesystem as the Git repository itself, so you can move files between them atomically. See https://github.com/arxanas/git-branchless/discussions/120.

Get the connection to the SQLite database for this repository.

Get a snapshot of information about a given reference.

Get the OID for the repository’s HEAD reference.

Set the HEAD reference directly to the provided oid. Does not touch the working copy.

Detach HEAD by making it point directly to its current OID, rather than to a branch. If HEAD is unborn, logs a warning.

Detect if an interactive rebase has started but not completed.

Git will send us spurious post-rewrite events marked as amend during an interactive rebase, indicating that some of the commits have been rewritten as part of the rebase plan, but not all of them. This function attempts to detect when an interactive rebase is underway, and if the current post-rewrite event is spurious.

There are two practical issues for users as a result of this Git behavior:

  • During an interactive rebase, we may see many “processing 1 rewritten commit” messages, and then a final “processing X rewritten commits” message once the rebase has concluded. This is potentially confusing for users, since the operation logically only rewrote the commits once, but we displayed the message multiple times.

  • During an interactive rebase, we may warn about abandoned commits, when the next operation in the rebase plan fixes up the abandoned commit. This can happen even if no conflict occurred and the rebase completed successfully without any user intervention.

Get the type current multi-step operation (such as rebase or cherry-pick) which is underway. Returns None if there is no such operation.

Find the merge-base between two commits. Returns None if a merge-base could not be found.

Get the patch for a commit, i.e. the diff between that commit and its parent.

If the commit has more than one parent, returns None.

Get the diff between two trees. This is more performant than calling libgit2’s diff_tree_to_tree directly since it dehydrates commits before diffing them.

Returns the set of paths currently staged to the repository’s index.

Get the file paths which were added, removed, or changed by the given commit.

If the commit has no parents, returns all of the file paths in that commit’s tree.

If the commit has more than one parent, returns None.

Get the patch ID for this commit.

Attempt to parse the user-provided object descriptor.

Find all references in the repository.

Check if the repository has staged or unstaged changes. Untracked files are not included. This operation may take a while.

Returns the current status of the repo index and working copy.

Create a new reference or update an existing one.

Get a list of all remote names.

Look up a reference with the given name. Returns None if not found.

Get all local branches in the repository.

Look up the branch with the given name. Returns None if not found.

Look up a commit with the given OID. Returns None if not found.

Like find_commit, but raises a generic error if the commit could not be found.

Look up a blob with the given OID. Returns None if not found.

Like find_blob, but raises a generic error if the blob could not be found.

Look up the commit with the given OID and render a friendly description of it, or render an error message if not found.

Read a file from disk and create a blob corresponding to its contents. If the file doesn’t exist on disk, returns None instead.

Create a blob corresponding to the provided byte slice.

Create a new commit.

Cherry-pick a commit in memory and return the resulting index.

Cherry-pick a commit in memory and return the resulting tree.

The libgit2 routines operate on entire Indexes, which contain one entry per file in the repository. When operating on a large repository, this is prohibitively slow, as it takes several seconds just to write the index to disk. To improve performance, we reduce the size of the involved indexes by filtering out any unchanged entries from the input trees, then call into libgit2, then add back the unchanged entries to the output tree.

Look up the tree with the given OID. Returns None if not found.

Like find_tree, but raises a generic error if the commit could not be found.

Write the provided in-memory index as a tree into Git`s object database. There must be no merge conflicts in the index.

Amends the provided parent commit in memory and returns the resulting tree.

Only amends the files provided in the options, and only supports amending from either the working tree or the index, but not both.

See Repo::cherry_pick_fast for motivation for performing the operation in-memory.

Trait Implementations

Formats the value using the given formatter. Read more
Get the Reference for the main branch for the repository.
Get the OID corresponding to the main branch.
Get a mapping from OID to the names of branches which point to that OID. Read more
Get the positions of references in the repository.

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.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

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

Set the foreground color generically Read more
Set the background color generically. Read more
Change the foreground color to black
Change the background color to black
Change the foreground color to red
Change the background color to red
Change the foreground color to green
Change the background color to green
Change the foreground color to yellow
Change the background color to yellow
Change the foreground color to blue
Change the background color to blue
Change the foreground color to magenta
Change the background color to magenta
Change the foreground color to purple
Change the background color to purple
Change the foreground color to cyan
Change the background color to cyan
Change the foreground color to white
Change the background color to white
Change the foreground color to the terminal default
Change the background color to the terminal default
Change the foreground color to bright black
Change the background color to bright black
Change the foreground color to bright red
Change the background color to bright red
Change the foreground color to bright green
Change the background color to bright green
Change the foreground color to bright yellow
Change the background color to bright yellow
Change the foreground color to bright blue
Change the background color to bright blue
Change the foreground color to bright magenta
Change the background color to bright magenta
Change the foreground color to bright purple
Change the background color to bright purple
Change the foreground color to bright cyan
Change the background color to bright cyan
Change the foreground color to bright white
Change the background color to bright white
Make the text bold
Make the text dim
Make the text italicized
Make the text italicized
Make the text blink
Make the text blink (but fast!)
Swap the foreground and background colors
Hide the text
Cross out the text
Set the foreground color at runtime. Only use if you do not know which color will be used at compile-time. If the color is constant, use either OwoColorize::fg or a color-specific method, such as OwoColorize::green, Read more
Set the background color at runtime. Only use if you do not know what color to use at compile-time. If the color is constant, use either OwoColorize::bg or a color-specific method, such as OwoColorize::on_yellow, Read more
Set the foreground color to a specific RGB value.
Set the background color to a specific RGB value.
Sets the foreground color to an RGB value.
Sets the background color to an RGB value.
Apply a runtime-determined style
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
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.
Calls the given closure and return the result. Read more
Calls the given closure on self.
Calls the given closure on self.
Calls the given closure if condition == true.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more