gitdiff

package
v0.27.1 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: Apache-2.0 Imports: 7 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 gitdiff produces the live diff for a session's working directory by shelling out to git. It never modifies the repository.

Index

Constants

View Source
const MaxPatchBytes = 200 << 10

MaxPatchBytes bounds each file's patch in the response.

Variables

View Source
var ErrNotARepo = errors.New("not a git repository")

ErrNotARepo means cwd is not inside a git work tree (→ HTTP 409).

Functions

This section is empty.

Types

type FileDiff

type FileDiff struct {
	Path      string `json:"path"`
	Status    string `json:"status"` // modified | added | deleted | renamed | untracked
	Additions int    `json:"additions"`
	Deletions int    `json:"deletions"`
	Patch     string `json:"patch,omitempty"`
	Binary    bool   `json:"binary,omitempty"`
}

FileDiff is one changed file.

type Result

type Result struct {
	Root   string     `json:"root"`
	Branch string     `json:"branch"`
	Files  []FileDiff `json:"files"`
	Stat   string     `json:"stat"`
}

Result is the diff of a working tree.

func Diff

func Diff(ctx context.Context, cwd string) (*Result, error)

Diff returns working-tree changes vs HEAD (staged + unstaged) plus untracked files.

Jump to

Keyboard shortcuts

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