Commit ed1e178
authored
fix(worktree): clean error when restoring/promoting onto an occupied branch
createWorktreeForExistingBranch only checked that the branch existed and
that the worktree name/path was free -- never whether the branch was
already checked out in another worktree. When it was, git failed with a
raw "git worktree add exited with code 128" error that escaped through
the restore and promote paths into error tracking.
The workspace creation path already caught the "is already used by
worktree" message and surfaced a friendly error, but the restore
(suspension/archive) and promote paths did not.
Detect the occupied branch up front in createWorktreeForExistingBranch
and throw a clean, actionable message instead. The wording mirrors git's
own so existing consumers that key on the "is already used by worktree"
substring keep recognising the case. Fixing it at this shared chokepoint
covers all three callers (create, restore, promote).
Generated-By: PostHog Code
Task-Id: c5eefa8e-bed0-4490-bb76-948ba72609981 parent d9f9204 commit ed1e178
2 files changed
Lines changed: 61 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
229 | 229 | | |
230 | 230 | | |
231 | 231 | | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
232 | 256 | | |
233 | 257 | | |
234 | 258 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
250 | 250 | | |
251 | 251 | | |
252 | 252 | | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
253 | 266 | | |
254 | 267 | | |
255 | 268 | | |
| |||
345 | 358 | | |
346 | 359 | | |
347 | 360 | | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
348 | 385 | | |
349 | 386 | | |
350 | 387 | | |
| |||
0 commit comments