Re: [PATCH v2 1/8] checkout: pass cb_option explicitly to branch name parsers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]




Junio C Hamano <gitster@xxxxxxxxx> 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]

Attachment: signature.asc
Description: PGP signature


[Index of Archives] [Linux Kernel Development] [Gcc Help] [IETF Annouce] [DCCP] [Netdev] [Networking] [Security] [V4L] [Bugtraq] [Yosemite] [MIPS Linux] [ARM Linux] [Linux Security] [Linux RAID] [Linux SCSI] [Fedora Users]

(追記) (追記ここまで)
Powered by Linux

AltStyle によって変換されたページ (->オリジナル) /