Re: [PATCH] submodule--helper.c: add only-active to foreach
- From
- Guillaume Galeazzi <guillaume.galeazzi@gmail.com>
- Date
- May 15, 2020, 18:53 UTC
- Message-ID
- <CAOEXN9yjd6r54K=5_Mdqr+cGJJ-ngaerfdbfD2m6RVZys-QmVQ@mail.gmail.com>
- In-Reply-To
- <xmqq7dxdm8qi.fsf@gitster.c.googlers.com>
Le ven. 15 mai 2020 à 19:03, Junio C Hamano <gitster@pobox.com> a écrit :
Show 12 quoted lines
>
> Guillaume Galeazzi <guillaume.galeazzi@gmail.com> writes:
>
> > Goal here was to avoid magic number, but after looking to the code it
> > seem accepted that true is 1 and false is 0. To comply with that, in
> > next version it will be replace it with:
> >
> > if (FOREACH_BOOL_FILTER_NOT_SET != info->active_only) {
>
> It still is unusual to have a constant on the left hand side of the
> "!=" or "==" operator, though. Having a constant on the left hand
> side of "<" and "<=" is justifiable, but not for "!=" and "==".It is call Yoda condition. As it compare with a constant, the compiler will throw an error if you write only = instead of != or ==.
But after a quick check, this wasn't needed as compiler warn
builtin/submodule--helper.c:570:2: error: suggest parentheses
around assignment used as truth value [-Werror=parentheses]And I am not a Yoda condition adept at all. So it will be removed.