git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] CodingGuidelines: !! is not all that exotic

From
PWPhillip Wood <phillip.wood123@gmail.com>
Date
Nov 19, 2026, 10:44 UTC
Message-ID
<ebcf98af-a633-4e51-97f0-099084beeef5@gmail.com>
In-Reply-To
<xmqq33sy6lgb.fsf@gitster.g>
Hi Junio
On 18/11/2026 18:31, Junio C Hamano wrote:
Show 10 quoted lines
> 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
Show 16 quoted lines
>   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
Previous: Junio C HamanoNext: Kristoffer Haugsbakk
Message 2 of 3 in “CodingGuidelines: !! is not all that exotic”
  1. CodingGuidelines: !! is not all that exoticJunio C Hamano, Nov 18, 2026
  2. Phillip WoodNov 19, 2026
  3. Kristoffer HaugsbakkNov 19, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.