Documentation ¶
Overview ¶
Package gitdiff parses and applies patches generated by Git. It supports line-oriented text patches, binary patches, and can also parse standard unified diffs generated by other tools.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BinaryFragment ¶
type BinaryFragment struct { Method BinaryPatchMethod Size int64 Data []byte }
BinaryFragment describes changes to a binary file.
type BinaryPatchMethod ¶
type BinaryPatchMethod int
BinaryPatchMethod is the method used to create and apply the binary patch.
const ( // BinaryPatchDelta indicates the data uses Git's packfile encoding BinaryPatchDelta BinaryPatchMethod = iota // BinaryPatchLiteral indicates the data is the exact file content BinaryPatchLiteral )
type Commit ¶
func EmitCommit ¶
type File ¶
type File struct { OldName string NewName string IsNew bool IsDelete bool IsCopy bool IsRename bool OldMode os.FileMode NewMode os.FileMode OldOIDPrefix string NewOIDPrefix string Score int // TextFragments contains the fragments describing changes to a text file. It // may be empty if the file is empty or if only the mode changes. TextFragments []*TextFragment // IsBinary is true if the file is a binary file. If the patch includes // binary data, BinaryFragment will be non-nil and describe the changes to // the data. If the patch is reversible, ReverseBinaryFragment will also be // non-nil and describe the changes needed to restore the original file // after applying the changes in BinaryFragment. IsBinary bool BinaryFragment *BinaryFragment ReverseBinaryFragment *BinaryFragment }
File describes changes to a single file. It can be either a text file or a binary file.
type LineOp ¶
type LineOp int
LineOp describes the type of a text fragment line: context, added, or removed.
type Patches ¶
type Patches struct { FilesToSha map[*File]string ShaToFiles map[string][]*File ShaToCommit map[string]Commit }
func (*Patches) AppendFile ¶
type TextFragment ¶
type TextFragment struct { Comment string OldPosition int64 OldLines int64 NewPosition int64 NewLines int64 LinesAdded int64 LinesDeleted int64 LeadingContext int64 TrailingContext int64 Lines []Line }
TextFragment describes changed lines starting at a specific line in a text file.
func (*TextFragment) FuncNames ¶
func (f *TextFragment) FuncNames() []string
func (*TextFragment) Header ¶
func (f *TextFragment) Header() string
Header returns the canonical header of this fragment.
Source Files ¶
Click to show internal directories.
Click to hide internal directories.