Skip to content

jwdevantier/patch-review

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

patch-review

A CLI tool for managing git worktrees during patch review workflows.

Installation

Build from source:

CGO_ENABLED=0 go build

Or use go install to fetch and build the binary, installing it into $HOME/go/bin/patch-review:

CGO_ENABLED=0 GOPROXY=direct go install github.com/jwdevantier/patch-review@latest

Quick Start

  1. Create a configuration file at ~/.config/patch-review/patch-review.config.toml:
[settings]
branch_prefix = "review"
default_source = "qemu"

[sources.qemu]
path = "~/repos/qemu"
branch = "nvme.next"
remote = "staging"

[sources.linux]
path = "/path/to/linux"
branch = "main"
remote = "origin"
  1. Create a review directory:
patch-review reset ~/reviews/my-patch

This creates a new git worktree with a fresh branch based on the latest upstream code.

  1. Apply a patch:
patch-review apply ~/reviews/my-patch.patch ~/reviews/my-patch
  1. Clean up when done:
patch-review rm ~/reviews/my-patch

Commands

reset

Creates or refreshes a git worktree directory.

patch-review reset [--source <name>] <review-dir>
  • Fetches latest updates from the configured remote
  • Creates a new branch from the upstream branch
  • Creates a new worktree at the specified path
  • If the worktree already exists, it removes and recreates it

Use --source to specify a source (defaults to default_source in config).

rm

Removes a worktree and cleans up git state.

patch-review rm <review-dir>
  • Validates the path is a known worktree
  • Removes the worktree directory
  • Deletes the associated git branch
  • Updates state tracking

apply

Applies a patch file to a worktree.

patch-review apply <review-dir> <patch-file>
  • Validates the worktree path is known
  • Applies the patch using git am

Configuration

Config files are stored in ~/.config/patch-review/ by default. Override with --dir.

patch-review.config.toml

[settings]
branch_prefix = "review"       # Prefix for created branches
default_source = "qemu"        # Default source when --source not specified

[sources.<name>]
path = "~/repos/qemu"          # Path to repository
branch = "nvme.next"           # Branch to use as base
remote = "staging"             # Git remote to fetch from

State File

patch-review.state.json tracks active worktrees. Do not edit manually.

Global Flags

  • --dir <path>: Override config directory location

Developer Notes

Project Structure

.
├── main.go              # Entry point, CLI setup
├── cmds/
│   ├── reset.go         # reset command
│   ├── rm.go            # rm command
│   └── apply.go         # apply command
├── internal/
│   ├── config.go        # Configuration loading (TOML)
│   ├── state.go         # State persistence (JSON)
│   └── git.go           # Git operations
├── go.mod / go.sum      # Dependencies
└── DESIGN.md           # Design document

Dependencies

Building

go build .

Running Tests

go test ./...

About

utility to create and manage git worktrees

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages