Documentation
¶
Overview ¶
Package gitdiff answers which lines of a checkout differ from a ref.
It exists for `kivgraph impact`, which maps changed lines onto the symbols of the graph. It runs git rather than reimplementing it, because the question "what changed since this ref" has rules -- renames, binary files, untracked files -- that git already knows, and it reads the answer in the one form that does not depend on them: the line ranges of the new side of each hunk.
Index ¶
Constants ¶
const WholeFile = int(^uint(0) >> 1)
WholeFile is the end of a range that covers a file whatever its length.
Variables ¶
var ErrUnknownRef = errors.New("unknown ref")
ErrUnknownRef is returned when the ref names no commit.
Functions ¶
Types ¶
type Change ¶
type Change struct {
// Path is slash-separated and relative to the checkout root.
Path string
// Deleted says the file no longer exists: its lines are gone and there is
// nothing in the working tree to map them onto.
Deleted bool
// Ranges are the lines that differ. A file that is new, or untracked, is one
// range over every line.
Ranges []Range
// Untracked says git has never been told about the file. Whatever the
// graph does not hold of those is not a change anyone made: a build
// directory, a tool's own state.
Untracked bool
}
Change is one file that differs from the ref.
type Diff ¶
type Diff struct {
// BaseCommit is the commit the ref names, spelled in full.
BaseCommit string
Changes []Change
}
Diff is the answer for one ref.
type Range ¶
Range is a run of lines of the working tree, 1-based and inclusive.
Between marks a change that removed lines and added none: it sits between Start and End -- two neighbouring lines of the new file -- and belongs to a symbol only when that symbol holds both of them. A deletion between two functions touches neither.