Subject: Re: [PATCH v3 09/20] global: introduce `USE_THE_REPOSITORY_VARIABLE` macro

From: Junio C Hamano <[email-masked]>
Date: Tue, 18 Jun 2024 08:58:01 -0700

Karthik Nayak <[email-masked]> writes:

>>> s/# define/#define/
>>
>> This is in fact intentional. We aren't strictly following this in our
>> codebase, but when nesting preprocessor macros into ifdefs then we often
>> indent the inner macros with spaces.
>>
>> Patrick
>
> That's something I didn't know. Thanks.

Unlike borrowed sources in compat/, in our codebase, such
indentation is minority.  IOW "often indent" -> "sometimes indent".

A quick look at an early part of git-compat-util.h would show that
even within a single file we are not consistent at all.

#if __STDC_VERSION__ - 0 < 199901L
#error "Required C99 support is in a test phase.  Please see git-compat-util.h for more details."
#endif

#ifdef USE_MSVC_CRTDBG
#include <stdlib.h>
#include <crtdbg.h>
#endif

#define _FILE_OFFSET_BITS 64

#if defined(__GNUC__) && defined(__GNUC_MINOR__)
# define GIT_GNUC_PREREQ(maj, min) \
	((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
#else
 #define GIT_GNUC_PREREQ(maj, min) 0
#endif

#ifndef FLEX_ARRAY
#if defined(__SUNPRO_C) && (__SUNPRO_C <= 0x580)
#elif defined(__GNUC__)
# if (__GNUC__ >= 3)
#  define FLEX_ARRAY /* empty */
# else
#  define FLEX_ARRAY 0 /* older GNU extension */
# endif
#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
# define FLEX_ARRAY /* empty */
#endif
...

We may want to eventually fix this, but we need to decide what the
desirable layout is.  I am not sure if the indented version is
easier to read and maintain, but one thing that is sure is that a
mixed mess is harder than either.  In the above excerpt, you cannot
tell if I quoted everything related to FLEX_ARRAY (in other words,
if "#ifndef FLEX_ARRAY" is already closed in the excerpt) without
carefully looking.