Repository navigation
docs(extending): add aliases for moving in-progress changes - #2084
worktrunk-bot wants to merge 1 commit into
Conversation
worktrunk-bot
left a comment
There was a problem hiding this comment.
This PR overlaps almost entirely with #2083 (opened ~2 minutes earlier by another concurrent run). Both close #938, both add the same three aliases (move-changes / copy-changes / copy-staged) with byte-identical alias bodies, and both target docs/content/extending.md. They should be consolidated into one — recommend closing this PR in favour of #2083, which has clearer per-alias explanations (a "How they work" bullet list instead of a single trailing paragraph).
Two smaller observations on the content of this PR if it's the one that ends up merged:
- The
### Common patternsheading collides with the existing### Common patternsunder Hooks (line 83 of the same file). Zola will disambiguate the slugs to#common-patterns-1, but a more specific heading (e.g.### Carrying changes into a new worktree) avoids the collision and reads better in the TOC. - The trailing paragraph mentions
--base, but none of the three aliases as written expose a base flag —wt switch --create {{ to }}always branches from HEAD. The reference to--baseis dead text from the reader's perspective; either drop it or rewrite to show how to extend the alias with--base.
| copy-staged = '''if git diff --cached --quiet; then wt switch --create {{ to }}; else p=$(mktemp) && git diff --cached > "$p" && wt switch --create {{ to }} --execute="git apply --index '$p' && rm '$p'"; fi''' | ||
| ``` | ||
|
|
||
| `--index` preserves the staged-vs-unstaged split when popping. The `git diff --quiet HEAD` guard skips the stash dance when the source is already clean, avoiding noise and never touching a pre-existing stash. If `--base` differs from `HEAD`, `git apply` and `git stash pop` may reject hunks that don't match — the same constraint a native flag would face. |
There was a problem hiding this comment.
The --base clause refers to a flag that the aliases as written never expose — wt switch --create {{ to }} always branches from HEAD, so a reader has no scenario in which this caveat applies. Suggest dropping it (or rewriting to show how to thread --base through the alias if that's the intent):
| `--index` preserves the staged-vs-unstaged split when popping. The `git diff --quiet HEAD` guard skips the stash dance when the source is already clean, avoiding noise and never touching a pre-existing stash. If `--base` differs from `HEAD`, `git apply` and `git stash pop` may reject hunks that don't match — the same constraint a native flag would face. | |
| `--index` preserves the staged-vs-unstaged split when popping. The `git diff --quiet HEAD` guard skips the stash dance when the source is already clean, avoiding noise and never touching a pre-existing stash. |
|
Agreed on all three points. Closing this in favour of #2083, which landed ~2 minutes earlier and uses the cleaner per-alias bullet structure. The heading collision and the |
|
Closing as duplicate of #2083. |
Summary
[aliases]recipes to the new Extending Worktrunk page that move or copy uncommitted changes into a new worktree (move-changes,copy-changes,copy-staged), addressing the use case from Worktree friction: copy staged and unstaged changes when creating new worktree #938.wt switch --createwith--execute, relying on the directive-file passthrough that landed in fix: pass directive file throughwt stepaliases #2077 — so thecdand the inner stash/apply step both reach the parent shell from inside an alias body.Test plan
cargo test --test integration test_command_pages_and_skill_files_are_in_sync(auto-syncsskills/worktrunk/reference/extending.md)Closes #938