Skip to content

fix(list): let merge-tree probes finish when the picker cancels background work - #4274

Merged
max-sixty merged 3 commits into
mainfrom
fix/issue-4273
Sep 26, 2026
Merged

max-sixty merged 3 commits into
mainfrom
fix/issue-4273

Conversation

@worktrunk-bot

Copy link
Copy Markdown
Collaborator

Leaving the wt switch picker while a git merge-tree probe is inside an external merge driver no longer strands .merge_file_* files in the worktree. Git writes the driver's three inputs as plain temp files in its cwd and removes them only when the driver returns normally, so the SIGTERM that cancel_background_commands() sends on picker exit left them behind. SIGTERM is the right signal for the preview diffs (git cleans index.lock on it), but not for this case.

The change adds Cmd::finish_once_started(). A command marked that way still honors the cancellation latch, so a cancelled probe that hasn't spawned never will. Once running, though, it isn't registered for signalling and runs to completion. compute_merge_tree_outcome opts in. This is the first fix proposed in the issue.

Verification:

  • merge_tree_cache_tests::merge_tree_probe_is_not_signalled_on_cancel runs a conflicting probe through a merge driver that records its parent PID, then checks that the running git merge-tree isn't a cancellation target. It fails without the fix and passes with it.
  • End to end, I drove wt switch from a PTY using the issue's sleep 3; exit 1 driver and pressed Esc after 1.5 s. The unfixed binary left three .merge_file_* files each run, and the fixed binary left none.

Tradeoff: an abandoned probe now outlives wt for as long as the driver takes, and its result isn't cached because the in-process cache exits with wt. A Ctrl-C during wt list still reaches merge-tree via the terminal's process-group broadcast, and that path is unchanged.

Closes #4273 — automated triage

…round work

Git writes an external merge driver's inputs as .merge_file_XXXXXX files in
its cwd and removes them only on a normal return, so the SIGTERM the picker
sends on exit stranded them in the worktree. Cmd::finish_once_started keeps
the cancellation latch (nothing new spawns) but leaves a running command
unsignalled; the merge-tree probe opts in.

Closes #4273
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automated-fix Automated CI fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

wt switch picker exit strands .merge_file_* temp files when a custom merge driver is configured

2 participants