From: Karthik Nayak Date: Tue, 01 Sep 2026 11:31:21 GMT Subject: Re: [PATCH v2 1/8] checkout: pass cb_option explicitly to branch name parsers Message-ID: In-Reply-To: <20260830204835.1040408-2-gitster@pobox.com> Junio C Hamano writes: > The file-scope static variable 'cb_option' is used to record whether > a new branch is being created via '-b' (in 'git checkout') or '-c' > (in 'git switch'), primarily for error reporting and advice messages > in parse_remote_branch(). > > Global mutable state makes the code harder to reason about and refactor. > > Pass 'cb_option' explicitly as a parameter to parse_remote_branch() > and parse_branchname_arg(), removing the file-scope static variable. > I was wondering why we couldn't simply get rid of 'cb_option' entirely? The only usecase for it is for printing user facing messages in `checkout_main()`, where we already have access to `enum checkout_command`. Wouldn't it be better to simply only keep the enum and drop this? [snip]