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)
| 320 | // existing linked worktree, FETCH_HEAD must be written inside it (it is |
| 321 | // per-worktree), so the fetch runs with -C <path>. |
| 322 | func detachCmds(fetchCmd []string, worktree string, reuseWorktree bool) [][]string { |
| 323 | if worktree == "" { |
| 324 | return [][]string{ |
| 325 | fetchCmd, |
| 326 | {"checkout", "--detach", "FETCH_HEAD"}, |
| 327 | } |
| 328 | } |
| 329 | |
| 330 | if reuseWorktree { |
| 331 | return [][]string{ |
| 332 | append([]string{"-C", worktree}, fetchCmd...), |
| 333 | {"-C", worktree, "checkout", "--detach", "FETCH_HEAD"}, |
| 334 | } |
| 335 | } |
| 336 | return [][]string{ |
| 337 | fetchCmd, |
| 338 | {"worktree", "add", "--detach", "--", worktree, "FETCH_HEAD"}, |
| 339 | } |
| 340 | } |
| 341 | |
| 342 | // syncBranchCmds syncs a branch to ref: a hard reset when force is set, |
| 343 | // otherwise a fast-forward-only merge. A non-empty path runs the commands there. |
no outgoing calls
no test coverage detected