Re: [GSoC PATCH v2] object-name: turn INTERPRET_BRANCH_* constants into enum values
- From
Karthik Nayak <karthik.188@gmail.com>
- Date
- Mar 20, 2026, 10:25 UTC
- Message-ID
- <CAOLa=ZTfL+1wqLYLNES-o1bCMJnms7rp1hG=DN+=YStgc38+vA@mail.gmail.com>
- In-Reply-To
- <20260318190942.22595-1-jerrywang183@yahoo.com>
Jialong Wang <jerrywang183@yahoo.com> writes:
Show 10 quoted lines
> Replace the INTERPRET_BRANCH_* preprocessor constants with enum > values and use that type where these flags are stored or passed > around. > > These flags describe which kinds of branches may be considered during > branch-name interpretation, so represent them as an enum describing > branch kinds while keeping the existing bitmask semantics and > INTERPRET_BRANCH_* element names. > > Signed-off-by: Jialong Wang <jerrywang183@yahoo.com>
[snip]
Show 16 quoted lines
> diff --git a/object-name.h b/object-name.h
> index cda4934cd5..167a9154ea 100644
> --- a/object-name.h
> +++ b/object-name.h
> @@ -101,9 +101,12 @@ int set_disambiguate_hint_config(const char *var, const char *value);
> * If the input was ok but there are not N branch switches in the
> * reflog, it returns 0.
> */
> -#define INTERPRET_BRANCH_LOCAL (1<<0)
> -#define INTERPRET_BRANCH_REMOTE (1<<1)
> -#define INTERPRET_BRANCH_HEAD (1<<2)
> +enum interpret_branch_kind {
> + INTERPRET_BRANCH_LOCAL = (1 << 0),
> + INTERPRET_BRANCH_REMOTE = (1 << 1),
> + INTERPRET_BRANCH_HEAD = (1 << 2),
> +};Generally when we use preprocessor constants with bit setting like `1 << 0`, we want to use them as flags which aren't mutually exclusive, allowing us to do 'INTERPRET_BRANCH_LOCAL | INTERPRET_BRANCH_HEAD' and so on.
Is this the case here? If not, maybe we want to mention that explicitly and simply use '1, 2....N'?
[snip]