diff

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package diff builds whole-file line models for changed files: every line of the new file with deletions interleaved, ready to render with changed lines highlighted in full context.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureFile

func EnsureFile(driver *git.Driver, set *Set, index int)

EnsureFile lazily loads a file skipped past the eager cap.

Types

type FileDiff

type FileDiff struct {
	File      git.ChangedFile
	Stat      git.FileStat
	Lines     []Line
	OldTotal  int
	NewTotal  int
	Changes   []int // indices where add/del runs begin, for jump keys
	Binary    bool
	Truncated bool
	Err       error
	// contains filtered or unexported fields
}

func BuildFile

func BuildFile(oldContent, newContent []byte, file git.ChangedFile, stat git.FileStat) FileDiff

BuildFile diffs two file versions into the whole-file line model: every new-file line in order, with deleted old lines interleaved ahead of the lines that replaced them.

func (*FileDiff) SideBySideRows

func (fd *FileDiff) SideBySideRows() []Row

func (*FileDiff) StatKnown added in v0.6.0

func (fd *FileDiff) StatKnown() bool

StatKnown reports whether Stat holds a real count rather than an unknown one.

type Line

type Line struct {
	Kind   LineKind
	OldNum int // 0 when the line only exists in the new file
	NewNum int // 0 when the line only exists in the old file
	Text   string
	Spans  []Span
	Pair   int // index of the counterpart Del/Add line; -1 when unpaired
}

type LineKind

type LineKind uint8
const (
	Same LineKind = iota
	Add
	Del
)

type Row

type Row struct {
	Left, Right int
}

Row addresses one side-by-side display row; -1 means a blank cell.

type Set

type Set struct {
	Repo         git.Repo
	Scope        git.Scope
	BaseDesc     string
	BaseRef      string
	BaseOverride string
	Files        []FileDiff
}

func BuildSet

func BuildSet(driver *git.Driver, cwd string, scope git.Scope, baseOverride string) (Set, error)

BuildSet loads and diffs every changed file for a scope. A non-empty baseOverride selects the ScopeBranch base and fails loudly when it no longer resolves; empty keeps auto-detection.

type Span

type Span struct {
	Start, End int
}

Span marks a changed byte range within a line's text.

Jump to

Keyboard shortcuts

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