detachCmds returns the commands for a detached checkout. When reusing an existing linked worktree, FETCH_HEAD must be written inside it (it is per-worktree), so the fetch runs with -C .
(fetchCmd []string, worktree string, reuseWorktree bool)
| 392 | // existing linked worktree, FETCH_HEAD must be written inside it (it is |
| 393 | // per-worktree), so the fetch runs with -C <path>. |
| 394 | func detachCmds(fetchCmd []string, worktree string, reuseWorktree bool) [][]string { |
| 395 | if worktree == "" { |
| 396 | return [][]string{ |
| 397 | fetchCmd, |
| 398 | {"checkout", "--detach", "FETCH_HEAD"}, |
| 399 | } |
| 400 | } |
| 401 | |
| 402 | if reuseWorktree { |
| 403 | return [][]string{ |
| 404 | append([]string{"-C", worktree}, fetchCmd...), |
| 405 | {"-C", worktree, "checkout", "--detach", "FETCH_HEAD"}, |
| 406 | } |
| 407 | } |
| 408 | return [][]string{ |
| 409 | fetchCmd, |
| 410 | {"worktree", "add", "--detach", "--", worktree, "FETCH_HEAD"}, |
| 411 | } |
| 412 | } |
| 413 | |
| 414 | // syncBranchCmds syncs a branch to ref: a hard reset when force is set, |
| 415 | // otherwise a fast-forward-only merge. A non-empty path runs the commands there. |
no outgoing calls
no test coverage detected