Skip to content

Fix checkout errors blaming the working directory (issue #629) - #630

Merged
hannesa2 merged 1 commit into
gitx:masterfrom
goneng:fix-checkout-error-message
Sep 13, 2026
Merged

hannesa2 merged 1 commit into
gitx:masterfrom
goneng:fix-checkout-error-message

Conversation

@goneng

@goneng goneng commented Sep 13, 2026 •

Copy link
Copy Markdown
Collaborator

git says why it refused, and GitX said something else.

First slice of #629. Checking out a branch that is checked out in another
worktree fails with

fatal: 'feature' is already used by worktree at '/path/to/wt'

and the sheet answered "Perhaps your working directory is not clean?", which
sends you looking for uncommitted changes that are not there. git's own text
did reach the sheet, but further down under "Output:", below a headline that
contradicted it.

The same canned guess stood in for every failure of checkoutRefish:,
checkoutFiles:fromRefish: and cherryPickRefish:, so all three now lead with
what git said. Worktrees are only the case that made it obvious.

  • Report the failed task's own output as the failure reason, keeping the guess
    for a failure that produced no output (a signal or a timeout)
  • Cover the worktree refusal, and both fallbacks, with tests that need no git
    on the machine

Nothing here teaches GitX about worktrees. Marking those branches and offering
to open them is the rest of #629.

Test plan

  • make unit-test: 105 tests, 0 failures, 4 of them new (in
    PBGitRepositoryCheckoutErrorTests)
  • Confirmed red first: with the helper returning the fallback, as the code did
    before, testGitsOwnRefusalIsReportedInsteadOfTheGuess and
    testGitsOutputIsTrimmed fail
  • The tests build the task error directly rather than launching git, so they
    do not depend on [PBGitBinary path] resolving on the runner, which Keep the unit tests from depending on the machine they run on #620
    had to clean up elsewhere
  • Not checked by hand in a running app

One known wart

The sheet now prints git's message twice: once as the headline, and again in
the "Output:" block that PBGitXMessageSheet appends for any task error.
Suppressing the second copy means touching the sheet for every error it shows,
which I kept out of this PR. Happy to follow up if you would rather have it.

@goneng
goneng marked this pull request as ready for review September 13, 2026 10:29
@hannesa2

Copy link
Copy Markdown
Contributor

Unfortunately, it comes with a conflict

@goneng
goneng force-pushed the fix-checkout-error-message branch from 64715eb to 911a6dd Compare September 13, 2026 10:40
@goneng
goneng marked this pull request as draft September 13, 2026 11:20
@goneng
goneng force-pushed the fix-checkout-error-message branch from 911a6dd to 8fcc04e Compare September 13, 2026 11:37
git says why it refused, and GitX said something else.

Checking out a branch that is checked out in another worktree fails with
"fatal: 'x' is already used by worktree at ...", and the sheet answered
"Perhaps your working directory is not clean?", which sends the reader
looking for changes that are not there. The same guess stood in for
every failure of the two checkouts and of cherry pick.

* Report the failed task's own output as the failure reason, keeping the
  guess for a failure that produced none
* Cover the worktree refusal, and both fallbacks, with tests that need
  no git on the machine
@goneng
goneng force-pushed the fix-checkout-error-message branch from 8fcc04e to 110ad54 Compare September 13, 2026 19:43
@goneng
goneng marked this pull request as ready for review September 13, 2026 19:55
@goneng

goneng commented Sep 13, 2026

Copy link
Copy Markdown
Collaborator Author

Unfortunately, it comes with a conflict

(rebased - thanks)

@hannesa2
hannesa2 merged commit 9607ce9 into gitx:master Sep 13, 2026
3 checks passed
@goneng
goneng deleted the fix-checkout-error-message branch September 13, 2026 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants