patch

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package patch provides functionality for generating patches from selections.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generate

func Generate(
	parsed *diff.ParsedDiff, selections []*diff.FileSelection,
) ([]byte, error)

Generate creates a patch containing only the selected lines. The patch can be applied with `git apply --cached`.

Every selection must contribute at least one line. A selection naming a path or a range with no changes fails the whole patch rather than being dropped from it, so a caller that mistypes one of several selections is told, instead of being handed a patch that silently stages less than it asked for.

func GenerateForFile

func GenerateForFile(file *diff.FileDiff) []byte

GenerateForFile creates a patch for a single file with all its changes.

func GenerateForHunk

func GenerateForHunk(file *diff.FileDiff, hunk *diff.Hunk) []byte

GenerateForHunk creates a patch for a single hunk.

Types

This section is empty.

Jump to

Keyboard shortcuts

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