git

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: MIT Imports: 8 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetContent

func GetContent(cwd, path, revision string, useTextconv bool) ([]byte, error)

GetContent reads a file at a given revision (e.g. "HEAD", a hash, or ":" for index). If revision is empty, it reads the local file on disk (applying textconv filter only if useTextconv is true).

func GetRepoPrefix added in v0.7.0

func GetRepoPrefix(cwd string) (string, error)

GetRepoPrefix returns the path prefix of cwd relative to the Git repository worktree root.

func IsGitRepository

func IsGitRepository(cwd string) bool

IsGitRepository checks if the directory is a Git repository.

func IsTrackedFile added in v0.7.0

func IsTrackedFile(cwd, path string) bool

IsTrackedFile checks if a path is tracked in the Git repository index or tree.

func IsValidRevision

func IsValidRevision(cwd, ref string) bool

IsValidRevision checks if a string is a valid Git revision.

func ListRefs added in v0.9.0

func ListRefs(cwd string, toComplete string) ([]string, error)

ListRefs returns Git revisions for shell completion, optionally filtered by prefix.

func RunGit

func RunGit(cwd string, args ...string) ([]byte, error)

RunGit runs a git command in the specified directory.

Types

type GitFile

type GitFile struct {
	Path     string
	OldPath  string // Non-empty if the file was renamed
	Status   string // 2-character porcelain status code (e.g. " M", "M ", "??")
	Staged   bool   // True if there are staged changes
	Unstaged bool   // True if there are unstaged changes or untracked
	IsBinary bool   // True if the file was identified as binary
}

GitFile represents a modified or untracked file in the repository.

func GetChangedFiles

func GetChangedFiles(cwd, refA, refB string, pathFilter string) ([]GitFile, error)

GetChangedFiles lists files changed between refA and refB. If refA is empty, it returns current working directory status. If refB is empty, it compares refA against the working tree.

func GetStatus

func GetStatus(cwd string, pathFilter string) ([]GitFile, error)

GetStatus returns the Git status of the repository.

Jump to

Keyboard shortcuts

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