gitx

package
v0.24.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 12, 2026 License: MIT Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package gitx runs the few git commands loupe needs against the user's clone.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BatchCheckSizes

func BatchCheckSizes(clone string, oids []string) (map[string]int64, error)

BatchCheckSizes returns the size of each object, keyed as given. A missing object is an error.

func Blob

func Blob(clone, ref, path string) ([]byte, error)

Blob returns path's bytes at ref. cat-file applies no textconv or filter, as Diff applies none.

func BranchUpstream

func BranchUpstream(clone, branch string) (remote, merge string, err error)

BranchUpstream returns branch.<branch>.remote and branch.<branch>.merge, each empty when unset.

func CommonDir

func CommonDir(dir string) (string, error)

CommonDir returns the repository directory that every worktree of dir shares. Git prints it relative to dir, and --path-format=absolute needs Git 2.31.

func ConfigBool

func ConfigBool(clone, key string) (bool, error)

ConfigBool reads key as Git reads a bool, so yes, on and 1 are true. An unset key is false.

func CurrentBranch

func CurrentBranch(clone string) (string, error)

CurrentBranch treats any fatal git failure, such as clone not being a repository, as no run being selectable rather than a defect, because the branch is only consulted when nothing else named a run.

func Diff

func Diff(clone, baseRef, headRef string) ([]byte, error)

Diff compares the head against its merge base with the base, as GitHub's pull request diff does, so lines the base gained after the branch point are not offered for comments.

func DiffLiteral

func DiffLiteral(clone, base, tree string, paths []string) ([]byte, error)

DiffLiteral is Diff's pinned output over exactly paths. git diff has no --pathspec-from-file, so the paths go as :(literal) arguments, which no path can turn into a glob. Sections for different files are independent, so the joined calls parse as one diff.

func FetchPR

func FetchPR(clone string, number int, baseSHA, baseRef, headRef string) error

FetchPR fetches from origin by name, never from a URL built from the pull request, and disables hooks, maintenance, submodules, tags, pruning and FETCH_HEAD so the pull request head cannot run anything or touch other refs.

func LsTreeNames

func LsTreeNames(clone, treeish string) ([]string, error)

LsTreeNames lists every path in treeish. --full-tree lists from the root even when clone is a subdirectory.

func MergeBase

func MergeBase(clone, baseRef, headRef string) (string, error)

MergeBase returns the commit Diff compares the head against.

func OriginMatches

func OriginMatches(clone, owner, repo string) error

OriginMatches accepts the configured origin URL or its insteadOf expansion: a clone whose github.com URL is rewritten to a mirror is still that repository, and insteadOf is the user's own config, not pull request input.

func OriginURLs

func OriginURLs(clone string) ([]string, error)

OriginURLs returns the configured origin URL and its insteadOf expansion, or nothing when there is no origin.

func ParseGitHubURL

func ParseGitHubURL(s string) (owner, repo string, ok bool)

ParseGitHubURL accepts https://github.com/o/r, git@github.com:o/r and ssh://git@github.com/o/r, each with an optional .git suffix.

func RemoteURLs

func RemoteURLs(clone, remote string) ([]string, error)

RemoteURLs returns the configured URL of remote and its insteadOf expansion, or nothing when it has no URL.

func RevParse

func RevParse(clone, ref string) (string, error)

func Toplevel

func Toplevel(dir string) (string, error)

Toplevel returns the root of the working tree that holds dir.

Types

type ConvertedError

type ConvertedError struct {
	Paths []string
}

ConvertedError is StageWorktree's refusal to stage tracked files whose bytes on disk differ from HEAD's while Git converts them on checkout. Without running the conversion, which capture never does, an edit and the conversion look the same.

func (*ConvertedError) Error

func (e *ConvertedError) Error() string

type Index

type Index struct {
	// contains filtered or unexported fields
}

Index runs git against a temporary index file, so the user's .git/index is never written or locked. Only the stat check for untouched filtered files reads it.

func WithIndex

func WithIndex(clone, indexPath string) *Index

WithIndex returns an Index on indexPath, which MUST be absolute.

func (*Index) ReadTree

func (ix *Index) ReadTree(treeish string) error

func (*Index) StageWorktree

func (ix *Index) StageWorktree() error

StageWorktree stages the working tree as git add -A would, with each file's bytes exactly as they are on disk. It hashes with --no-filters, so no clean or process filter from the user's config runs and no line ending changes: a filter is a command, and capture runs none. It expects the index to hold HEAD, from ReadTree. A tracked file whose bytes differ from HEAD's while Git converts it on checkout refuses with a *ConvertedError.

func (*Index) WriteTree

func (ix *Index) WriteTree() (string, error)

type Numstat

type Numstat struct {
	Path           string
	Binary         bool
	Added, Deleted int
}

Numstat counts a file's changed lines. Binary is set, and the counts are zero, where numstat prints -.

func NumstatZ

func NumstatZ(clone, base, tree string) ([]Numstat, error)

type RawEntry

type RawEntry struct {
	SrcMode, DstMode string
	SrcOID, DstOID   string
	Status           string
	Path             string
}

func DiffRawZ

func DiffRawZ(clone, base, tree string) ([]RawEntry, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL