add --worktree flag to trail checkout · Entire

add --worktree flag to trail checkout

f63ff98→main·

With --worktree, trail checkout creates a worktree under .entire/worktrees instead of switching the current checkout, and prints a shell-safe cd hint.

Sessions

01KX4PMF0VC3GNMW6YE1TB6PTYView transcript

Changes

3

119 unmodified lines

// checkoutTrailWorktree checks branch out into a managed worktree under
// <main-root>/.entire/worktrees instead of switching the current checkout.
// The final output line is a shell-safe `cd '<path>'` hint.
func checkoutTrailWorktree(ctx context.Context, w, errW io.Writer, branch string, force bool, trailNumber int) error {
    if err := ValidateBranchName(ctx, branch); err != nil {
        return err
    }
}
func newTrailCheckoutCmd() *cobra.Command {
    var trailSelector string
    var force bool
    var worktree bool

cmd := &cobra.Command{
        Use:   "checkout [<trail>]",
        Args: cobra.MaximumNArgs(1),

// details about the command
    }

cmd.Flags().StringVar(&trailSelector, "trail", "", "Trail to check out (number, id, or branch; defaults to the current branch's trail)")
    cmd.Flags().BoolVarP(&force, "force", "f", false, "Skip the prompt before fetching a remote-only branch")
    cmd.Flags().BoolVar(&worktree, "worktree", false, "Check out the trail branch in a worktree under .entire/worktrees instead of switching this checkout")

return cmd
}