All of lore.kernel.org
 help / color / mirror / Atom feed
From: Phillip Wood <phillip.wood123@gmail.com>
To: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: Re: [PATCH] CodingGuidelines: !! is not all that exotic
Date: Thu, 19 Nov 2026 10:44:12 +0000	[thread overview]
Message-ID: <ebcf98af-a633-4e51-97f0-099084beeef5@gmail.com> (raw)
In-Reply-To: <xmqq33sy6lgb.fsf@gitster.g>

Hi Junio

On 18/11/2026 18:31, Junio C Hamano wrote:
> Remove the clause against "clever tricks" that cites !!value that is
> a standard technique to normalize a value to 0/1 boolean.  We could
> resurrect it if we can come up with a truly exotic example that we
> would want to avoid, but this is not a good enough justification for
> this rule.
> 
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
>   * I think we saw a good example that !! was used in a recent review
>     thread, and the idea to remove this rule was floated back then,
>     but without following through.

Yes, its come up a couple of times recently, thanks for putting a patch 
together.

Phillip

>   Documentation/CodingGuidelines | 4 ----
>   1 file changed, 4 deletions(-)
> 
> diff --git c/Documentation/CodingGuidelines w/Documentation/CodingGuidelines
> index 3c8d6c7dd3..4bfa615bac 100644
> --- c/Documentation/CodingGuidelines
> +++ w/Documentation/CodingGuidelines
> @@ -522,10 +522,6 @@ For C programs:
>   	    that_is_used_in + a_very_long_expression) {
>   		...
>   
> - - Some clever tricks, like using the !! operator with arithmetic
> -   constructs, can be extremely confusing to others.  Avoid them,
> -   unless there is a compelling reason to use them.
> -
>    - Use the API.  No, really.  We have a strbuf (variable length
>      string), several arrays with the ALLOC_GROW() macro, a
>      string_list for sorted string lists, a hash map (mapping struct


  reply	other threads:[~2026-11-19 10:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18 18:31 [PATCH] CodingGuidelines: !! is not all that exotic Junio C Hamano
2026-11-19 10:44 ` Phillip Wood [this message]
2026-11-19 15:15 ` Kristoffer Haugsbakk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ebcf98af-a633-4e51-97f0-099084beeef5@gmail.com \
    --to=phillip.wood123@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=phillip.wood@dunelm.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.