feat: add wt.remover config and --remover flag#144
Merged
k1LoW merged 2 commits intok1LoW:mainfrom Feb 16, 2026
Merged
Conversation
Add support for a custom worktree removal command that replaces `git worktree remove`. When `wt.remover` is set (via config or `--remover` flag), the specified command receives the worktree path as an argument and is used instead of the default removal. After the custom command completes, `git worktree prune` runs automatically to clean up git's internal worktree tracking. This is useful for faster deletion via trash commands (e.g. trash-put) which move directories to the system trash instantly rather than performing a recursive delete. The worktree path is passed safely as a shell positional argument (`"$1"`) to handle paths containing spaces or special characters. Closes k1LoW#143
# Conflicts: # cmd/root.go # e2e/config_test.go # internal/git/config.go
Contributor
Author
|
why we need this. |
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
wt.removerconfig key and--removerCLI flag to replacegit worktree removewith a custom command (e.g.trash-put)git worktree prunecleans up git's internal tracking automatically"$1") to handle spaces and special charactersMotivation
git worktree removeusesrm -rfinternally, which can be slow for large worktrees. Trash commands liketrash-putmove directories to the system trash instantly, providing a much faster alternative.Usage
Files Changed
internal/git/config.go: AddedconfigKeyRemoverconstant,Removerfield toConfig, loading logic inLoadConfig()internal/git/worktree.go: AddedRunRemover()andPruneWorktrees()functionscmd/root.go: Added--removerflag, flag override inloadConfig(), remover branch indeleteWorktrees(), help texte2e/config_test.go: AddedTestE2E_Removerwith 6 subtests, updated completion flag listTest Plan
go build ./...compiles cleanlygo vet ./...passesTestE2E_Completepasses with--removerin expected flagsCloses #143