Skip to content

vimkim/patchers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Patchers: TUI for diff & patch file creation

I'm tired of scrolling long diff patch files.

A fast, minimal terminal UI for interactively selecting hunks from a unified diff and writing out a filtered patch.
This tool allows you to curate large patches into smaller, reviewable, or cherry-pickable subsets with immediate visual feedback.

Built with Rust, powered by ratatui and crossterm.

image

Features

  • Parse standard unified diffs (git diff, git format-patch, etc.)
  • Interactive TUI hunk browser
  • Live preview with colored additions/removals
  • Toggle hunks on/off and auto-save the filtered patch
  • Preserves original file headers and metadata
  • Fully keyboard-driven
  • Lightweight and dependency-minimal

Demo Workflow

  1. Load a patch file
  2. Navigate between hunks
  3. Toggle only the changes you want
  4. Instantly produce a clean filtered patch for:
    • Partial code reviews
    • Stacked diffs
    • Backports
    • Cherry-picking across branches

Installation

Install with Git

cargo install --git https://github.com/vimkim/patchers.git patchers

Install with Git Clone

git clone https://github.com/yourname/patchers.git
cd patchers
cargo install --path .

Build from Source

git clone https://github.com/yourname/patchers.git
cd patchers
cargo build --release

Binary will be available at:

target/release/patchers

Usage

patchers <INPUT_PATCH> --output <OUTPUT_PATCH>

Example

git diff > diff.patch
patchers diff.patch -o filtered.patch

While running:

Key Action
↑ / k Move up
↓ / j Move down
Space / Enter Toggle hunk & save
q Quit

Each toggle immediately writes the output file, so your filtered patch is always up to date.


Input Format

  • Expects a standard unified diff

  • Fully compatible with:

    • git diff
    • git show
    • git format-patch
  • Handles:

    • Multi-file patches
    • Arbitrary metadata sections
    • \ No newline at end of file

Output Format

  • Writes a valid unified diff

  • Preserves:

    • diff --git headers
    • index, ---, +++ lines
  • Includes only selected hunks

  • Safe to apply with:

git apply filtered.patch

UI Overview

  • Left panel: Hunk list with file labels and previews
  • Right panel: Colored diff preview
  • Bottom panel: Status & key bindings
  • [x] indicates selected hunks
  • [ ] indicates unselected hunks

Error Handling

  • Graceful parsing of malformed diffs
  • Live status feedback on save errors
  • Clean terminal teardown on panic or exit

Dependencies


Use Cases

  • Preparing minimal review patches
  • Splitting large diffs into logical commits
  • Creating safe hotfix patches
  • Extracting specific features from large changes
  • Teaching and demonstration of patch mechanics

Development

cargo run -- diff.patch -o filtered.patch

Formatting:

cargo fmt

Linting:

cargo clippy

License

MIT License. You are free to use, modify, and distribute this tool.


Contributing

Pull requests are welcome. Please follow standard Rust formatting and keep commits focused.

Suggested areas for improvement:

  • File-level toggling
  • Search / filter hunks
  • Unified scroll for large hunks
  • Mouse support
  • Git integration mode

Acknowledgments

  • ratatui for the TUI framework
  • crossterm for cross-platform terminal control
  • Git’s unified diff format

About

TUI for diff & patch file creation.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors