git-worktrees 0.11.1__tar.gz → 0.12.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/AGENTS.md +113 -8
  2. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/CHANGELOG.md +61 -0
  3. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/PKG-INFO +79 -16
  4. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/README.md +78 -15
  5. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/conf.d/worktrees.fish +1 -1
  6. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/docs/REFERENCE.md +222 -4
  7. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/docs/commands/fast-forward.md +56 -6
  8. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/docs/commands/merge.md +10 -0
  9. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/plugin/.claude-plugin/plugin.json +1 -1
  10. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/plugin/.codex-plugin/plugin.json +1 -1
  11. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/plugin/plugin.json +1 -1
  12. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/plugin/skills/fast-forward/SKILL.md +11 -0
  13. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/plugin/skills/ship-it/SKILL.md +19 -0
  14. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/pyproject.toml +1 -1
  15. git_worktrees-0.12.0/src/worktrees/audit.py +473 -0
  16. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/src/worktrees/branch_cli.py +26 -16
  17. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/src/worktrees/branch_forge.py +50 -0
  18. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/src/worktrees/branches.py +28 -4
  19. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/src/worktrees/cli.py +271 -57
  20. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/src/worktrees/fast_forward.py +360 -26
  21. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/src/worktrees/forge.py +26 -0
  22. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/src/worktrees/git.py +30 -3
  23. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/src/worktrees/merged.py +161 -1
  24. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/src/worktrees/pr_merge.py +49 -0
  25. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/src/worktrees/prune.py +212 -14
  26. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/src/worktrees/render.py +124 -1
  27. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/src/worktrees/repo.py +32 -50
  28. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/src/worktrees/verdicts.py +24 -3
  29. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/src/worktrees/worktree.py +4 -0
  30. git_worktrees-0.12.0/tests/audit_schema.py +264 -0
  31. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/tests/conftest.py +25 -1
  32. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/tests/test_assessment.py +117 -5
  33. git_worktrees-0.12.0/tests/test_audit.py +1119 -0
  34. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/tests/test_branches.py +9 -6
  35. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/tests/test_cli.py +147 -34
  36. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/tests/test_fast_forward.py +388 -0
  37. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/tests/test_gates.py +6 -44
  38. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/tests/test_partial_clone.py +2 -1
  39. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/tests/test_pr_merge.py +67 -0
  40. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/tests/test_removal.py +5 -4
  41. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/tests/test_render.py +76 -0
  42. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/tests/test_worktree.py +1 -1
  43. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/uv.lock +1 -1
  44. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/zsh/plugins/worktrees/worktrees.plugin.zsh +1 -1
  45. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/.claude/settings.json +0 -0
  46. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/.codex/config.toml +0 -0
  47. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/.github/workflows/codeql.yml +0 -0
  48. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/.github/workflows/publish.yml +0 -0
  49. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/.github/workflows/testpypi.yml +0 -0
  50. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/.github/workflows/tests.yml +0 -0
  51. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/.gitignore +0 -0
  52. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/.pre-commit-config.yaml +0 -0
  53. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/.python-version +0 -0
  54. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/.releasetools.yaml +0 -0
  55. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/LICENSE +0 -0
  56. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/Makefile +0 -0
  57. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/completions/gw.fish +0 -0
  58. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/completions/worktrees.fish +0 -0
  59. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/docs/BENCHMARK.md +0 -0
  60. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/docs/DEVELOPMENT.md +0 -0
  61. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/docs/commands/branch-prune.md +0 -0
  62. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/docs/commands/branch-status.md +0 -0
  63. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/docs/commands/ci-checks.md +0 -0
  64. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/docs/plans/2026-11-05-worktree-pruning-design.md +0 -0
  65. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/functions/gw.fish +0 -0
  66. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/functions/gwa.fish +0 -0
  67. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/functions/gwbc.fish +0 -0
  68. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/functions/gwbp.fish +0 -0
  69. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/functions/gwbs.fish +0 -0
  70. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/functions/gwff.fish +0 -0
  71. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/functions/gwl.fish +0 -0
  72. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/functions/gwm.fish +0 -0
  73. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/functions/gwp!.fish +0 -0
  74. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/functions/gwp.fish +0 -0
  75. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/functions/gwpa!.fish +0 -0
  76. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/functions/gwpa.fish +0 -0
  77. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/functions/gwr!.fish +0 -0
  78. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/functions/gwr.fish +0 -0
  79. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/functions/gws.fish +0 -0
  80. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/hatch_build.py +0 -0
  81. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/plugin/README.md +0 -0
  82. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/plugin/hooks/codex.json +0 -0
  83. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/plugin/hooks/hooks.json +0 -0
  84. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/plugin/session.md +0 -0
  85. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/plugin/skills/ci-checks/SKILL.md +0 -0
  86. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/plugin/skills/describe-pr/SKILL.md +0 -0
  87. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/plugin/skills/describe-pr/format.md +0 -0
  88. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/plugin/skills/preflight/SKILL.md +0 -0
  89. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/plugin/skills/preflight/agents/openai.yaml +0 -0
  90. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/plugin/skills/preflight/rules.json +0 -0
  91. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/plugin/skills/prune/SKILL.md +0 -0
  92. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/plugin/skills/ship-it/rights.md +0 -0
  93. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/renovate.json +0 -0
  94. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/scripts/README.md +0 -0
  95. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/scripts/benchmark.py +0 -0
  96. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/scripts/bump_version.py +0 -0
  97. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/scripts/verify-publish.bash +0 -0
  98. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/src/worktrees/__init__.py +0 -0
  99. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/src/worktrees/ci.py +0 -0
  100. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/src/worktrees/errors.py +0 -0
  101. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/src/worktrees/layout.py +0 -0
  102. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/src/worktrees/new_branch.py +0 -0
  103. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/src/worktrees/pick.py +0 -0
  104. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/src/worktrees/progress.py +0 -0
  105. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/src/worktrees/sync.py +0 -0
  106. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/tests/test_benchmark.py +0 -0
  107. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/tests/test_branch_forge.py +0 -0
  108. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/tests/test_ci.py +0 -0
  109. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/tests/test_command_defaults.py +0 -0
  110. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/tests/test_completions.py +0 -0
  111. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/tests/test_fixture.py +0 -0
  112. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/tests/test_forge.py +0 -0
  113. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/tests/test_git_records.py +0 -0
  114. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/tests/test_new_branch.py +0 -0
  115. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/tests/test_path_boundaries.py +0 -0
  116. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/tests/test_plugin.py +0 -0
  117. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/tests/test_shims.py +0 -0
  118. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/tests/test_spec.py +0 -0
  119. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/tests/test_sync.py +0 -0
  120. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/tests/test_version.py +0 -0
  121. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/zsh/plugins/worktrees/completions/_gw +0 -0
  122. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/zsh/plugins/worktrees/functions/gw +0 -0
  123. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/zsh/plugins/worktrees/functions/gwa +0 -0
  124. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/zsh/plugins/worktrees/functions/gwbc +0 -0
  125. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/zsh/plugins/worktrees/functions/gwbp +0 -0
  126. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/zsh/plugins/worktrees/functions/gwbs +0 -0
  127. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/zsh/plugins/worktrees/functions/gwff +0 -0
  128. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/zsh/plugins/worktrees/functions/gwl +0 -0
  129. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/zsh/plugins/worktrees/functions/gwm +0 -0
  130. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/zsh/plugins/worktrees/functions/gwp +0 -0
  131. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/zsh/plugins/worktrees/functions/gwp! +0 -0
  132. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/zsh/plugins/worktrees/functions/gwpa +0 -0
  133. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/zsh/plugins/worktrees/functions/gwpa! +0 -0
  134. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/zsh/plugins/worktrees/functions/gwr +0 -0
  135. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/zsh/plugins/worktrees/functions/gwr! +0 -0
  136. {git_worktrees-0.11.1 → git_worktrees-0.12.0}/zsh/plugins/worktrees/functions/gws +0 -0
@@ -137,9 +137,22 @@ command under `WORKTREES_OFFLINE=1`.
137
137
 
138
138
  A branch whose open request targets another branch with an open request,
139
139
  a stacked one, is levelled with that branch instead of the head ref:
140
- `fast_forward.stacked_on` reads both requests from the forge in the same
140
+ `fast_forward._stack` reads both requests from the forge in the same
141
141
  run, and the branch below levels with the head ref in its own run.
142
142
 
143
+ When the request below merged instead and its branch was kept, the forge
144
+ leaves the open request on that finished branch, where a merge never
145
+ reaches the head branch. `_retarget` moves its base to the head branch,
146
+ the one forge write `gw fast-forward` makes on its own, and `_publish`
147
+ pushes the branch under a lease once it is level; a branch with an open
148
+ request that dropped a parent's merged commits is pushed the same way.
149
+ Commits the finished branch gained after its merge that the head ref
150
+ lacks, by `merged.change_in`, go first: `_rescue` copies them without a
151
+ checkout onto a dated branch from the head ref, pushes it and opens its
152
+ request, and a copy that cannot be made leaves the base where it is.
153
+ `gw merge` refuses a base that stands at a merged request's head commit,
154
+ so a run that skipped this still cannot land there.
155
+
143
156
  Every other branch keeps its name. One with no commits of its own
144
157
  fast-forwards and one with commits is rebased, both with `--no-autostash`
145
158
  unless `--autostash` is given: `merge.autoStash` and `rebase.autoStash`
@@ -226,8 +239,9 @@ of rules writes both. `tests/test_plugin.py` holds every skill's
226
239
  `allowed-tools` to reads, `gw sync` and `gw branch create`: no pattern
227
240
  covers a removal, a merge, a push, a rerun or a checkout that moves. Three
228
241
  exceptions are each skill's job: `describe-pr` may edit a review,
229
- `fast-forward` runs `gw fast-forward` and the conflict loop its own test
230
- lists, and `ship-it`, invoked to publish one change or the reviews it
242
+ `fast-forward` runs `gw fast-forward`, which moves a base left on a merged
243
+ branch and pushes the branch it levelled, and the conflict loop its own
244
+ test lists, and `ship-it`, invoked to publish one change or the reviews it
231
245
  names, commits, pushes, opens and edits the review, reruns CI and merges,
232
246
  as its own test lists. None pre-approves a removal.
233
247
 
@@ -410,6 +424,20 @@ Padding runs on the text and painting after it. The other order counts an
410
424
  escape sequence as width, and every column under a coloured cell sits crooked
411
425
  by exactly the length of the code.
412
426
 
427
+ An assessment prints `render.records`, not `render.table`: a box with one
428
+ record a worktree or branch, a line of short cells and then its reasons
429
+ across the box, so a reason has the terminal's width and not a last column's.
430
+ A reason that is a string is prose and wraps to `render.columns`; one that is
431
+ a `Cell` is a command or a path and is never broken, widening the box when it
432
+ must, so it pastes back. `prune.details` builds them from the row's `Fact`s:
433
+ the evidence, each protection, each of a fact's commands on its own line,
434
+ and `needs:` once, last. The JSON `protections` keep the one-line wording
435
+ with `; pass --delete ...`, which the prune skill reads. The worktree's path
436
+ is in `--json` and the removal disclosure, not in the box. `render.ruled`
437
+ picks box characters for a UTF-8 terminal and `+`, `-` and `|` otherwise;
438
+ `--table` sets `render.plain`, which turns both wrapping and box characters
439
+ off, since a script reads it.
440
+
413
441
  stdout carries the path `cd $(gw add x)` reads and the JSON `jq` parses, so a
414
442
  redirect, a pipe, a non-empty `NO_COLOR`, or `TERM=dumb` mean the bytes go out
415
443
  as they would have without the module. `NO_COLOR=` is not a request to turn it
@@ -524,6 +552,18 @@ head's commits after a fork point. Those are facts about the objects. Nothing
524
552
  outside an assessment keeps them, since `gw fast-forward` fetches and an
525
553
  object missing a moment ago can appear, and a failed answer is never kept.
526
554
 
555
+ Two of those answers outlive the run: `_local_proof` for a tip and
556
+ `change_in` for a reflog commit, each against the head's full SHA, saved in
557
+ `git-worktrees-proofs.json` in the Git common directory and replaced
558
+ atomically when the assessment ends. They have no TTL, since neither commit
559
+ changes; the file holds one head's answers and starts again when the head
560
+ moves, which bounds it. A partial clone saves only a yes, because a fetch
561
+ can bring the object a no lacked without moving the head, and an entry that
562
+ is not the shape `merged.py` wrote is asked again. Nothing a checkout holds
563
+ is saved: `git status`, submodules, an operation in progress, reflogs and
564
+ stashes are read on every run, since they are what stops a worktree with
565
+ work in it being offered.
566
+
527
567
  `git submodule status` is the costliest check, so the store decides alone
528
568
  when it exists, and without one the check runs only where `.gitmodules`
529
569
  exists. The store outlives a deleted `.gitmodules`, which is also when
@@ -545,6 +585,67 @@ pipeline whose parents
545
585
  are the current head and the target's tip. `ci.wait` takes its clock and
546
586
  sleep as arguments, so its tests run in-process without waiting.
547
587
 
588
+ ## The audit log is appended, never edited
589
+
590
+ `audit.py` writes one JSON line per event to `audit-YYYY-MM.jsonl` under
591
+ `$XDG_STATE_HOME/worktrees`, or `WORKTREES_AUDIT_DIR`. Each line is one
592
+ `os.write` on an `O_APPEND` descriptor, and nothing here seeks, truncates,
593
+ renames or deletes a file. A monthly name is what makes that hold: rotation
594
+ by size would need a rename.
595
+
596
+ Recording runs between `audit.begin` and `audit.end`. `_dispatch` begins
597
+ once argparse has the words, so `--help`, which leaves inside `parse_args`,
598
+ and a parsed `--explain` or `--complete` on any subcommand record nothing
599
+ and answer under a `WORKTREES_AUDIT` it does not take; no scan of the raw
600
+ words would know an abbreviated `--hel` or a value after `--`. A usage
601
+ error begins in `main`, as it leaves. Every path from `main` to `_command`
602
+ is inside the `try` whose `finally` ends the run, so no start lacks its end. Outside the pair every
603
+ function returns at once, so a test or a caller that imports the package
604
+ and runs a spec writes nothing.
605
+
606
+ A line is one `os.write` and is never resumed: after a short write
607
+ `_append` closes the fragment with a newline if one fits and raises. Each
608
+ append takes `flock`, reads the last byte and writes under it, and a file
609
+ that does not end in a newline gets one before the line, which carries
610
+ `torn`. What the file ended in at open is never kept: another process can
611
+ tear a line after that, and a look outside the lock races the write. The
612
+ lock is tried for a tenth of a second; without it the line brings its own
613
+ newline whatever the file ends in.
614
+
615
+ Two places see every process: the `@git` wrapper and `forge._run`. Each
616
+ times the run and calls `audit.ran`, filed as `reads`, `mutating` or
617
+ `forge`; `WORKTREES_AUDIT` turns each off by name and `off` turns off the
618
+ log. A spec holding `fetch` is filed as mutating though it is not declared
619
+ `mutates`. What a process printed is kept only when it changes something or
620
+ failed. `audit.clean` walks the whole event as `record` serializes it and
621
+ scrubs every string, so no caller scrubs its own fields and none can forget.
622
+
623
+ `prune.audit_proposed` runs in `prune.plan` and `prune.audit_outcome` after
624
+ `worktree.remove` and `branches.delete`, the second also when the recheck
625
+ refuses. `prune.restores` builds one action per thing taken, with its kind,
626
+ full sha, branch or subject and an unquoted `argv`; `command` and `undo` are
627
+ `shlex.join` of that, so the line a person pastes cannot disagree with the
628
+ fields a program reads. A proposal passes only what would go and an outcome
629
+ only what went, so a kept or retained branch, and its stashes, have none. They ask git for the remote
630
+ only while the log is on. `Moved` carries short shas, so `_audit_moved`
631
+ resolves both ends before it writes one.
632
+
633
+ `tests/audit_schema.py` lists every event's fields, types and values, and
634
+ `events()` in `tests/test_audit.py` holds each event a test reads to it: an
635
+ unlisted field, a missing one or another type fails. The reference is held
636
+ to the same names. `audit.clean` raises on a type it does not know, so a
637
+ new field of an odd type drops its event with a warning; nothing is ever
638
+ written as a Python repr. A failure's kind and a removal's stage are fields
639
+ of their own, `failure` and `failedStage`. A handler in `cli.py` that prints
640
+ a refusal and returns goes through `_refuse`, which hands the kind to the
641
+ log; one that only printed would end its run as `result`. A cut output
642
+ carries its count in `outDropped`, never a mark inside the text.
643
+
644
+ A write that fails turns recording off for the rest of the run and warns
645
+ once through `progress.line`. `conftest.ENV` and an autouse fixture set
646
+ `WORKTREES_AUDIT=off`; `tests/test_audit.py` turns it on at a directory of
647
+ its own. [Audit log](docs/REFERENCE.md#audit-log) lists the events.
648
+
548
649
  ## Every git command is one spec
549
650
 
550
651
  The spec is the command as you would type it, with `$name` where a value goes.
@@ -593,9 +694,10 @@ the subcommands they are; `is_ancestor` beats `merge_base`, because
593
694
  the caller wants.
594
695
 
595
696
  A spec with `ok=` wide enough to swallow an error is a spec that has to be
596
- tested on what it returns rather than on its exit code. `upstream_of` takes
597
- `ok=(0, 1, 128)`, so a typo in one of its flags exits 128, reads as "no
598
- upstream", and turns every branch into `unknown` with nothing failing.
697
+ tested on what it returns rather than on its exit code. `tree_of` takes
698
+ `ok=(0, 128)` for a ref that does not resolve, and a typo in its `^{tree}`
699
+ exits 128 too. The squash proof and the forge proof would then answer no for
700
+ every branch, and nothing would fail.
599
701
 
600
702
  The network calls belong to sync. Their results distinguish failed
601
703
  refs refresh from partial forge refresh; assessments retain usable local
@@ -611,7 +713,9 @@ both ways was 18 of an assessment's 35 calls over nine worktrees.
611
713
  no call site can assemble its way past it. `reset --hard`, a forced `checkout`
612
714
  or `switch`, `clean -f`, a bare `push --force`, `worktree remove --force`,
613
715
  `branch -D` and an `update-ref` delete that names no full sha are refused
614
- absolutely. There is no flag, and `--yes` least of all.
716
+ absolutely. There is no flag, and `--yes` least of all. `gw remove` prints
717
+ `git worktree remove --force PATH` beside a dirty target's refusal, for a
718
+ person who has looked to run; nothing here runs it.
615
719
 
616
720
  Those seven are `RULES`, a tuple, each row carrying the name `--explain`
617
721
  prints, the clause the refusal ends with, and the test. The footer `--explain`
@@ -706,4 +810,5 @@ directory too, since `GIT_CONFIG_GLOBAL` does not reach `git/ignore`, the
706
810
  default `core.excludesFile`. `WORKTREES_OFFLINE=1` in `conftest.ENV` stops
707
811
  a command syncing first, which would fetch a remote at `github.com` for
708
812
  real. `Network.env` clears it for the fake network, and `conftest.online`
709
- for a remote on disk.
813
+ for a remote on disk. The fake network's git answers `push` itself, as it
814
+ does `fetch`, and its `gh` and `glab` answer an edit and a create.
@@ -17,6 +17,67 @@ not in here, whatever it cost to build.
17
17
  A release closes with a `### Choices` section when a decision in it is worth
18
18
  the reader's time: what was chosen, and what the alternative failed to do.
19
19
 
20
+ ## 0.12.0 - 2026-11-16
21
+
22
+ ### Changed
23
+
24
+ `gw prune`, `gw remove` and `gw branch status` print each worktree or
25
+ branch as a record in a box: one line with BRANCH, VERDICT, REASON and
26
+ ELIGIBLE, then its reasons across the full width, wrapped to the
27
+ terminal. The PATH and WORKTREE columns are gone, from `--table` too,
28
+ which draws the box with `+`, `-` and `|` and wraps nothing. A script
29
+ that parsed those columns should read `--json`, whose `why` and
30
+ `protections` keep their wording.
31
+
32
+ A command inside a reason, such as `git show SHA`, gets a line of its own
33
+ and is never broken, and the `--delete` values a row needs are named once,
34
+ as `needs:`. The hint for missing `--delete` values prints its command on
35
+ a line of its own with the worktrees it frees listed under it, and the
36
+ removal disclosure puts each restore and listing command on its own line,
37
+ with a blank line between targets.
38
+
39
+ A dirty worktree's reason says what `git status` found, such as
40
+ `it has uncommitted changes to 9 files and 1 untracked path`, in place
41
+ of `it has uncommitted changes or untracked files`, in tables and in
42
+ the JSON `why` and `protections`. Scripts matching the old text should
43
+ read `reason`, which stays `uncommitted`. The `--delete` help names
44
+ each value beside what it permits.
45
+
46
+ ### Added
47
+
48
+ When `gw remove` keeps a worktree, it names the full command that
49
+ removes it: `gw remove PATH --delete VALUE`, carrying the values you
50
+ passed, as `gw prune` names its own. For uncommitted changes or
51
+ untracked paths it names `git worktree remove --force PATH`, with a
52
+ count of the ignored paths and reflog-only commits that command
53
+ deletes and the branch it keeps; gw never runs it.
54
+
55
+ Every command appends what it ran to an audit log,
56
+ `~/.local/state/worktrees/audit-YYYY-MM.jsonl`: each `git`, `gh` and
57
+ `glab` process with its exit code and duration, and each removal with
58
+ what restores it, as fields and as commands to paste.
59
+ `WORKTREES_AUDIT=off` turns it off, `WORKTREES_AUDIT=reads=off` leaves out
60
+ read-only git commands, and `WORKTREES_AUDIT_DIR` moves it.
61
+
62
+ `gw fast-forward` now moves a pull request left on a merged parent's
63
+ branch to the head branch, pushes the levelled branch under a lease, and
64
+ opens a separate request for commits the parent gained after its merge.
65
+ `gw merge` refuses a base left on a merged branch.
66
+
67
+ An assessment saves each worktree's completion proof in
68
+ `git-worktrees-proofs.json` in the Git common directory, so the next
69
+ `gw prune`, `gw remove` or `gw branch status` against the same head
70
+ commit reads it instead of asking git again. What a checkout holds is
71
+ still read on every run.
72
+
73
+ ## 0.11.2 - 2026-11-15
74
+
75
+ ### Removed
76
+
77
+ `gw --explain` no longer lists `rev-parse --abbrev-ref
78
+ --symbolic-full-name $branch@{upstream}` or `for-each-ref
79
+ --format=%(upstream:track)`. No command ran either of them.
80
+
20
81
  ## 0.11.1 - 2026-11-15
21
82
 
22
83
  ### Added
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: git-worktrees
3
- Version: 0.11.1
3
+ Version: 0.12.0
4
4
  Summary: Git worktree commands that refuse to lose work.
5
5
  Project-URL: Bug reports, https://github.com/MihaiBojin/worktrees/issues/new
6
6
  Project-URL: Source, https://github.com/MihaiBojin/worktrees
@@ -104,7 +104,7 @@ the plugin's tag to the same release, as each manager below describes.
104
104
  ### fish
105
105
 
106
106
  ```console
107
- fisher install MihaiBojin/worktrees@v0.11.1
107
+ fisher install MihaiBojin/worktrees@v0.12.0
108
108
  ```
109
109
 
110
110
  Fisher copies `functions/`, `completions/` and `conf.d/` from the repository
@@ -121,7 +121,7 @@ the untagged one holds the files.
121
121
  Antidote takes a `path:` into the repository, and `branch:` takes a tag:
122
122
 
123
123
  ```
124
- MihaiBojin/worktrees branch:v0.11.1 path:zsh/plugins/worktrees # in zsh_plugins.txt
124
+ MihaiBojin/worktrees branch:v0.12.0 path:zsh/plugins/worktrees # in zsh_plugins.txt
125
125
  ```
126
126
 
127
127
  The plugin puts its own `functions/` and `completions/` on `fpath` and
@@ -196,8 +196,8 @@ its stdout stays the version alone for a script to read.
196
196
  An excerpt of `gw --help`'s release lines with matching CLI and shell releases:
197
197
 
198
198
  ```console
199
- worktrees 0.11.1: git worktree commands that refuse to lose work
200
- The shell plugin here is 0.11.1, the same release as these commands.
199
+ worktrees 0.12.0: git worktree commands that refuse to lose work
200
+ The shell plugin here is 0.12.0, the same release as these commands.
201
201
  ```
202
202
 
203
203
  A shell without the variable has no plugin loaded, or one older than the
@@ -272,12 +272,40 @@ Deleting a branch deletes its reflog, and removing a worktree deletes the
272
272
  worktree's own. A commit nothing else reaches goes with them, so a row whose
273
273
  deleted reflogs hold a commit whose patch the head lacks is held back, and
274
274
  the protection names `git show SHA` for each one. `eligible` also checks
275
- protections and the deletion permissions you supplied. The WHY column gives
276
- the evidence, then each protection that stands. A protection that `--delete`
277
- values lift ends with every value its row needs, such as
278
- `pass --delete empty --delete stashes`, and only where those values make
279
- the row eligible. For a target it keeps, `gw remove` prints every reason, and
280
- names a command with `--keep-branch` when only that removes the worktree.
275
+ protections and the deletion permissions you supplied.
276
+
277
+ The table is a box with one record for each worktree: a line of short
278
+ answers, then the reasons across the full width, wrapped to the terminal.
279
+
280
+ ```
281
+ ┌───────────────┬─────────┬────────┬──────────────────────┐
282
+ │ BRANCH │ VERDICT │ REASON │ ELIGIBLE │
283
+ ├───────────────┼─────────┼────────┼──────────────────────┤
284
+ │ release-0.8.0 │ keep │ closed │ no │
285
+ ├───────────────┴─────────┴────────┴──────────────────────┤
286
+ │ pull request #182 was closed without merging this tip │
287
+ │ its request is closed │
288
+ │ its reflog alone holds 2 commits the head branch lacks; │
289
+ │ see each with: │
290
+ │ git show 54a199e1f797 │
291
+ │ git show ea8faa8208f5 │
292
+ │ needs: --delete closed --delete reflog │
293
+ └─────────────────────────────────────────────────────────┘
294
+ ```
295
+
296
+ The reasons are the evidence, then each protection that stands, a command
297
+ on a line of its own so it is never cut. `needs:` ends a record with every
298
+ `--delete` value it needs, and only where those values make it eligible.
299
+ The path is in `--json`, not in the table. Off a terminal and under
300
+ `--table` the box is drawn with `+`, `-` and `|` and nothing wraps. In
301
+ `--json`, a protection those values lift ends with them, such as
302
+ `pass --delete empty --delete stashes`. For a target it keeps, `gw remove` prints every reason and
303
+ each command that removes it: `gw remove PATH --delete VALUE`, carrying the
304
+ values you passed, as `gw prune` names them; `--keep-branch` when only that
305
+ waives the proof; and, for uncommitted changes or untracked paths,
306
+ `git worktree remove --force PATH`, which deletes the checkout with them and
307
+ keeps the branch. That line counts the ignored paths and reflog-only commits
308
+ that go too. gw never runs it.
281
309
 
282
310
  The CLI never deletes `main`, `master` or the head branch. It never removes
283
311
  the main checkout, locked or dirty worktrees, worktrees with untracked files,
@@ -303,9 +331,20 @@ Repeat `--delete` to combine categories:
303
331
 
304
332
  `gw branch status` rejects `--delete`. An unknown or unsupported value is a
305
333
  usage error before mutation. A `--delete` value changes eligibility, not the
306
- verdict. When only missing values hold worktrees back, `gw prune` names
307
- the command that grants them, keeping the values you passed:
308
- `gw prune --delete empty makes fix-parser eligible`. Without a terminal,
334
+ verdict. When only missing values hold worktrees back, `gw prune` says so
335
+ and prints the command that grants them on a line of its own, keeping the
336
+ values you passed, then the worktrees it frees. The command takes no names;
337
+ `gw remove NAME` targets one worktree.
338
+
339
+ ```
340
+ → 2 worktrees are held back only by a permission. To make them eligible, run:
341
+
342
+ gw prune --delete closed --delete reflog
343
+
344
+ frees: gw-design, release-0.8.0
345
+ ```
346
+
347
+ Without a terminal,
309
348
  the line that names `--yes` carries the `--delete` values and
310
349
  `--keep-branch` you passed, so running it removes what was counted.
311
350
 
@@ -493,7 +532,11 @@ moves to a new branch from the head ref or `--from`, named
493
532
  `YYYY-MM-DDThh-mm-ssZ/NAME` unless you name it. A branch whose own pull
494
533
  request squash-merged its first commits moves the same way, carrying only
495
534
  the commits made after the merge; a stacked branch whose parent merged keeps
496
- its name and drops the merged commits in place. `--autostash` carries uncommitted changes across. A branch
535
+ its name and drops the merged commits in place. When that branch's open
536
+ request still targets the merged parent, which a forge leaves there unless
537
+ the parent's branch is deleted, the run moves its base to the head branch
538
+ and pushes the branch under a lease; commits the parent gained after its
539
+ merge get a branch and a request of their own first. `--autostash` carries uncommitted changes across. A branch
497
540
  already level exits 0 and changes nothing. [Fast-forward](docs/commands/fast-forward.md) gives the
498
541
  order of the checks, the JSON and the conflict loop.
499
542
 
@@ -502,7 +545,8 @@ order of the checks, the JSON and the conflict loop.
502
545
  [`gw merge`](docs/commands/merge.md) squashes one GitHub PR at its checked
503
546
  head SHA, including native stacked PRs. It waits up to ten minutes for lower
504
547
  stack members and the head rewrite, and respects the merge queue. A rewritten
505
- head returns `head-moved` at exit 4 without submitting. Submitted operations
548
+ head returns `head-moved` at exit 4 without submitting. A base left on a
549
+ branch whose own PR merged is refused, and `gw fast-forward` moves it. Submitted operations
506
550
  report `merged`, `enqueued`, `pending` or `failed`. The ship-it skill in
507
551
  Codex and Claude uses this command; both the CLI and plugin must be updated
508
552
  to provide it.
@@ -594,6 +638,25 @@ gw prune --json | jq '.verdicts[] | select(.eligible)'
594
638
  gw list --json | jq -r '.worktrees[].path'
595
639
  ```
596
640
 
641
+ ## Audit log
642
+
643
+ Each command appends what it did, one JSON object per line, to
644
+ `~/.local/state/worktrees/audit-YYYY-MM.jsonl`: the command as typed, every
645
+ `git`, `gh` and `glab` process with its exit code and duration, and each
646
+ removal with the full SHA and what restores it, as fields and as commands
647
+ to paste. Lines are only ever appended, and no file is ever deleted.
648
+
649
+ ```console
650
+ $ jq -c 'select(.event == "removal.outcome") | {ts, host, branch, result, restore}' \
651
+ ~/.local/state/worktrees/audit-*.jsonl
652
+ $ jq -c 'select(.event == "exec" and .mutates) | {ts, ms, code, argv}' \
653
+ ~/.local/state/worktrees/audit-*.jsonl
654
+ ```
655
+
656
+ `WORKTREES_AUDIT=reads=off` leaves out read-only git commands,
657
+ `WORKTREES_AUDIT=off` turns the log off, and `WORKTREES_AUDIT_DIR` moves it.
658
+ [The reference](docs/REFERENCE.md#audit-log) lists every event and field.
659
+
597
660
  ## Migration
598
661
 
599
662
  | Removed interface | Current interface |
@@ -77,7 +77,7 @@ the plugin's tag to the same release, as each manager below describes.
77
77
  ### fish
78
78
 
79
79
  ```console
80
- fisher install MihaiBojin/worktrees@v0.11.1
80
+ fisher install MihaiBojin/worktrees@v0.12.0
81
81
  ```
82
82
 
83
83
  Fisher copies `functions/`, `completions/` and `conf.d/` from the repository
@@ -94,7 +94,7 @@ the untagged one holds the files.
94
94
  Antidote takes a `path:` into the repository, and `branch:` takes a tag:
95
95
 
96
96
  ```
97
- MihaiBojin/worktrees branch:v0.11.1 path:zsh/plugins/worktrees # in zsh_plugins.txt
97
+ MihaiBojin/worktrees branch:v0.12.0 path:zsh/plugins/worktrees # in zsh_plugins.txt
98
98
  ```
99
99
 
100
100
  The plugin puts its own `functions/` and `completions/` on `fpath` and
@@ -169,8 +169,8 @@ its stdout stays the version alone for a script to read.
169
169
  An excerpt of `gw --help`'s release lines with matching CLI and shell releases:
170
170
 
171
171
  ```console
172
- worktrees 0.11.1: git worktree commands that refuse to lose work
173
- The shell plugin here is 0.11.1, the same release as these commands.
172
+ worktrees 0.12.0: git worktree commands that refuse to lose work
173
+ The shell plugin here is 0.12.0, the same release as these commands.
174
174
  ```
175
175
 
176
176
  A shell without the variable has no plugin loaded, or one older than the
@@ -245,12 +245,40 @@ Deleting a branch deletes its reflog, and removing a worktree deletes the
245
245
  worktree's own. A commit nothing else reaches goes with them, so a row whose
246
246
  deleted reflogs hold a commit whose patch the head lacks is held back, and
247
247
  the protection names `git show SHA` for each one. `eligible` also checks
248
- protections and the deletion permissions you supplied. The WHY column gives
249
- the evidence, then each protection that stands. A protection that `--delete`
250
- values lift ends with every value its row needs, such as
251
- `pass --delete empty --delete stashes`, and only where those values make
252
- the row eligible. For a target it keeps, `gw remove` prints every reason, and
253
- names a command with `--keep-branch` when only that removes the worktree.
248
+ protections and the deletion permissions you supplied.
249
+
250
+ The table is a box with one record for each worktree: a line of short
251
+ answers, then the reasons across the full width, wrapped to the terminal.
252
+
253
+ ```
254
+ ┌───────────────┬─────────┬────────┬──────────────────────┐
255
+ │ BRANCH │ VERDICT │ REASON │ ELIGIBLE │
256
+ ├───────────────┼─────────┼────────┼──────────────────────┤
257
+ │ release-0.8.0 │ keep │ closed │ no │
258
+ ├───────────────┴─────────┴────────┴──────────────────────┤
259
+ │ pull request #182 was closed without merging this tip │
260
+ │ its request is closed │
261
+ │ its reflog alone holds 2 commits the head branch lacks; │
262
+ │ see each with: │
263
+ │ git show 54a199e1f797 │
264
+ │ git show ea8faa8208f5 │
265
+ │ needs: --delete closed --delete reflog │
266
+ └─────────────────────────────────────────────────────────┘
267
+ ```
268
+
269
+ The reasons are the evidence, then each protection that stands, a command
270
+ on a line of its own so it is never cut. `needs:` ends a record with every
271
+ `--delete` value it needs, and only where those values make it eligible.
272
+ The path is in `--json`, not in the table. Off a terminal and under
273
+ `--table` the box is drawn with `+`, `-` and `|` and nothing wraps. In
274
+ `--json`, a protection those values lift ends with them, such as
275
+ `pass --delete empty --delete stashes`. For a target it keeps, `gw remove` prints every reason and
276
+ each command that removes it: `gw remove PATH --delete VALUE`, carrying the
277
+ values you passed, as `gw prune` names them; `--keep-branch` when only that
278
+ waives the proof; and, for uncommitted changes or untracked paths,
279
+ `git worktree remove --force PATH`, which deletes the checkout with them and
280
+ keeps the branch. That line counts the ignored paths and reflog-only commits
281
+ that go too. gw never runs it.
254
282
 
255
283
  The CLI never deletes `main`, `master` or the head branch. It never removes
256
284
  the main checkout, locked or dirty worktrees, worktrees with untracked files,
@@ -276,9 +304,20 @@ Repeat `--delete` to combine categories:
276
304
 
277
305
  `gw branch status` rejects `--delete`. An unknown or unsupported value is a
278
306
  usage error before mutation. A `--delete` value changes eligibility, not the
279
- verdict. When only missing values hold worktrees back, `gw prune` names
280
- the command that grants them, keeping the values you passed:
281
- `gw prune --delete empty makes fix-parser eligible`. Without a terminal,
307
+ verdict. When only missing values hold worktrees back, `gw prune` says so
308
+ and prints the command that grants them on a line of its own, keeping the
309
+ values you passed, then the worktrees it frees. The command takes no names;
310
+ `gw remove NAME` targets one worktree.
311
+
312
+ ```
313
+ → 2 worktrees are held back only by a permission. To make them eligible, run:
314
+
315
+ gw prune --delete closed --delete reflog
316
+
317
+ frees: gw-design, release-0.8.0
318
+ ```
319
+
320
+ Without a terminal,
282
321
  the line that names `--yes` carries the `--delete` values and
283
322
  `--keep-branch` you passed, so running it removes what was counted.
284
323
 
@@ -466,7 +505,11 @@ moves to a new branch from the head ref or `--from`, named
466
505
  `YYYY-MM-DDThh-mm-ssZ/NAME` unless you name it. A branch whose own pull
467
506
  request squash-merged its first commits moves the same way, carrying only
468
507
  the commits made after the merge; a stacked branch whose parent merged keeps
469
- its name and drops the merged commits in place. `--autostash` carries uncommitted changes across. A branch
508
+ its name and drops the merged commits in place. When that branch's open
509
+ request still targets the merged parent, which a forge leaves there unless
510
+ the parent's branch is deleted, the run moves its base to the head branch
511
+ and pushes the branch under a lease; commits the parent gained after its
512
+ merge get a branch and a request of their own first. `--autostash` carries uncommitted changes across. A branch
470
513
  already level exits 0 and changes nothing. [Fast-forward](docs/commands/fast-forward.md) gives the
471
514
  order of the checks, the JSON and the conflict loop.
472
515
 
@@ -475,7 +518,8 @@ order of the checks, the JSON and the conflict loop.
475
518
  [`gw merge`](docs/commands/merge.md) squashes one GitHub PR at its checked
476
519
  head SHA, including native stacked PRs. It waits up to ten minutes for lower
477
520
  stack members and the head rewrite, and respects the merge queue. A rewritten
478
- head returns `head-moved` at exit 4 without submitting. Submitted operations
521
+ head returns `head-moved` at exit 4 without submitting. A base left on a
522
+ branch whose own PR merged is refused, and `gw fast-forward` moves it. Submitted operations
479
523
  report `merged`, `enqueued`, `pending` or `failed`. The ship-it skill in
480
524
  Codex and Claude uses this command; both the CLI and plugin must be updated
481
525
  to provide it.
@@ -567,6 +611,25 @@ gw prune --json | jq '.verdicts[] | select(.eligible)'
567
611
  gw list --json | jq -r '.worktrees[].path'
568
612
  ```
569
613
 
614
+ ## Audit log
615
+
616
+ Each command appends what it did, one JSON object per line, to
617
+ `~/.local/state/worktrees/audit-YYYY-MM.jsonl`: the command as typed, every
618
+ `git`, `gh` and `glab` process with its exit code and duration, and each
619
+ removal with the full SHA and what restores it, as fields and as commands
620
+ to paste. Lines are only ever appended, and no file is ever deleted.
621
+
622
+ ```console
623
+ $ jq -c 'select(.event == "removal.outcome") | {ts, host, branch, result, restore}' \
624
+ ~/.local/state/worktrees/audit-*.jsonl
625
+ $ jq -c 'select(.event == "exec" and .mutates) | {ts, ms, code, argv}' \
626
+ ~/.local/state/worktrees/audit-*.jsonl
627
+ ```
628
+
629
+ `WORKTREES_AUDIT=reads=off` leaves out read-only git commands,
630
+ `WORKTREES_AUDIT=off` turns the log off, and `WORKTREES_AUDIT_DIR` moves it.
631
+ [The reference](docs/REFERENCE.md#audit-log) lists every event and field.
632
+
570
633
  ## Migration
571
634
 
572
635
  | Removed interface | Current interface |
@@ -4,4 +4,4 @@
4
4
  # The release this plugin came from, which `gw --help` and `gw version` compare
5
5
  # with their own. Exported, because the environment is all a binary can see
6
6
  # of the shell that started it.
7
- set -gx WORKTREES_PLUGIN_VERSION 0.11.1
7
+ set -gx WORKTREES_PLUGIN_VERSION 0.12.0