# [RFC/PATCH] headers: normalize the spelling of some header guards

5 messages from 2018-10-14 to 2018-10-15. Participants: Ramsay Jones, brian m. carlson, Jeff King, Junio C Hamano.
Thread: https://gitlist.dev/t/49562

## Ramsay Jones, 2018-10-14 20:13

Subject: [RFC/PATCH] headers: normalize the spelling of some header guards
Message-ID: <2804aa4e-c078-c981-be93-27e6e58b2042@ramsayjones.plus.com>
URL: https://gitlist.dev/e/2804aa4e-c078-c981-be93-27e6e58b2042%40ramsayjones.plus.com

```

Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
---

Hi Junio,

This patch is marked RFC because I am not aware of any policy with
regard to header guard spelling. Having said that, apart from the
fetch-negotiator.h header, all of these headers are using a reserved
identifier (see C99 Standard 7.1.3).

These headers were found, thus:

  $ git grep -n -E '^#ifn?def ' -- '*.h' | grep 'h\:1\:' | grep -v '^compat' | grep -v -E '[A-Z_]*_H$'
  alias.h:1:#ifndef __ALIAS_H__
  commit-reach.h:1:#ifndef __COMMIT_REACH_H__
  fetch-negotiator.h:1:#ifndef FETCH_NEGOTIATOR
  midx.h:1:#ifndef __MIDX_H__
  t/helper/test-tool.h:1:#ifndef __TEST_TOOL_H__
  vcs-svn/fast_export.h:1:#ifndef FAST_EXPORT_H_
  vcs-svn/line_buffer.h:1:#ifndef LINE_BUFFER_H_
  vcs-svn/sliding_window.h:1:#ifndef SLIDING_WINDOW_H_
  vcs-svn/svndiff.h:1:#ifndef SVNDIFF_H_
  vcs-svn/svndump.h:1:#ifndef SVNDUMP_H_
  $ 

Note that I haven't included the headers in vcs-svn because there is
a patch being discussed which would move that directory to contrib.

ATB,
Ramsay Jones

 alias.h              | 4 ++--
 commit-reach.h       | 4 ++--
 fetch-negotiator.h   | 4 ++--
 midx.h               | 4 ++--
 t/helper/test-tool.h | 4 ++--
 5 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/alias.h b/alias.h
index 79933f2457..aef4843bb7 100644
--- a/alias.h
+++ b/alias.h
@@ -1,5 +1,5 @@
-#ifndef __ALIAS_H__
-#define __ALIAS_H__
+#ifndef ALIAS_H
+#define ALIAS_H
 
 struct string_list;
 
diff --git a/commit-reach.h b/commit-reach.h
index 7d313e2975..122a23a24d 100644
--- a/commit-reach.h
+++ b/commit-reach.h
@@ -1,5 +1,5 @@
-#ifndef __COMMIT_REACH_H__
-#define __COMMIT_REACH_H__
+#ifndef COMMIT_REACH_H
+#define COMMIT_REACH_H
 
 #include "commit-slab.h"
 
diff --git a/fetch-negotiator.h b/fetch-negotiator.h
index ddb44a22dc..9e3967ce66 100644
--- a/fetch-negotiator.h
+++ b/fetch-negotiator.h
@@ -1,5 +1,5 @@
-#ifndef FETCH_NEGOTIATOR
-#define FETCH_NEGOTIATOR
+#ifndef FETCH_NEGOTIATOR_H
+#define FETCH_NEGOTIATOR_H
 
 struct commit;
 
diff --git a/midx.h b/midx.h
index ce80b91c68..ee83702309 100644
--- a/midx.h
+++ b/midx.h
@@ -1,5 +1,5 @@
-#ifndef __MIDX_H__
-#define __MIDX_H__
+#ifndef MIDX_H
+#define MIDX_H
 
 #include "repository.h"
 
diff --git a/t/helper/test-tool.h b/t/helper/test-tool.h
index e4890566da..71f470b871 100644
--- a/t/helper/test-tool.h
+++ b/t/helper/test-tool.h
@@ -1,5 +1,5 @@
-#ifndef __TEST_TOOL_H__
-#define __TEST_TOOL_H__
+#ifndef TEST_TOOL_H
+#define TEST_TOOL_H
 
 #include "git-compat-util.h"
 
-- 
2.19.0

```

## brian m. carlson, 2018-10-14 23:17

Subject: Re: [RFC/PATCH] headers: normalize the spelling of some header guards
Message-ID: <20181014231731.GA432229@genre.crustytoothpaste.net>
URL: https://gitlist.dev/e/20181014231731.GA432229%40genre.crustytoothpaste.net
In-Reply-To: <2804aa4e-c078-c981-be93-27e6e58b2042@ramsayjones.plus.com>

```
On Sun, Oct 14, 2018 at 09:13:09PM +0100, Ramsay Jones wrote:
> 
> Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
> ---
> 
> Hi Junio,
> 
> This patch is marked RFC because I am not aware of any policy with
> regard to header guard spelling. Having said that, apart from the
> fetch-negotiator.h header, all of these headers are using a reserved
> identifier (see C99 Standard 7.1.3).
> 
> These headers were found, thus:
> 
>   $ git grep -n -E '^#ifn?def ' -- '*.h' | grep 'h\:1\:' | grep -v '^compat' | grep -v -E '[A-Z_]*_H$'
>   alias.h:1:#ifndef __ALIAS_H__
>   commit-reach.h:1:#ifndef __COMMIT_REACH_H__
>   fetch-negotiator.h:1:#ifndef FETCH_NEGOTIATOR
>   midx.h:1:#ifndef __MIDX_H__
>   t/helper/test-tool.h:1:#ifndef __TEST_TOOL_H__
>   vcs-svn/fast_export.h:1:#ifndef FAST_EXPORT_H_
>   vcs-svn/line_buffer.h:1:#ifndef LINE_BUFFER_H_
>   vcs-svn/sliding_window.h:1:#ifndef SLIDING_WINDOW_H_
>   vcs-svn/svndiff.h:1:#ifndef SVNDIFF_H_
>   vcs-svn/svndump.h:1:#ifndef SVNDUMP_H_
> 

I think this is a good change.  We should definitely get rid of the
reserved identifiers, but I'm definitely not opposed to tidying things
up.
-- 
brian m. carlson: Houston, Texas, US
OpenPGP: https://keybase.io/bk2204

```

## Jeff King, 2018-10-14 23:59

Subject: Re: [RFC/PATCH] headers: normalize the spelling of some header guards
Message-ID: <20181014235950.GA13510@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20181014235950.GA13510%40sigill.intra.peff.net
In-Reply-To: <2804aa4e-c078-c981-be93-27e6e58b2042@ramsayjones.plus.com>

```
On Sun, Oct 14, 2018 at 09:13:09PM +0100, Ramsay Jones wrote:

> This patch is marked RFC because I am not aware of any policy with
> regard to header guard spelling. Having said that, apart from the
> fetch-negotiator.h header, all of these headers are using a reserved
> identifier (see C99 Standard 7.1.3).
>
> These headers were found, thus:
> 
>   $ git grep -n -E '^#ifn?def ' -- '*.h' | grep 'h\:1\:' | grep -v '^compat' | grep -v -E '[A-Z_]*_H$'
>   alias.h:1:#ifndef __ALIAS_H__
>   commit-reach.h:1:#ifndef __COMMIT_REACH_H__
>   fetch-negotiator.h:1:#ifndef FETCH_NEGOTIATOR
>   midx.h:1:#ifndef __MIDX_H__
>   t/helper/test-tool.h:1:#ifndef __TEST_TOOL_H__
>   vcs-svn/fast_export.h:1:#ifndef FAST_EXPORT_H_
>   vcs-svn/line_buffer.h:1:#ifndef LINE_BUFFER_H_
>   vcs-svn/sliding_window.h:1:#ifndef SLIDING_WINDOW_H_
>   vcs-svn/svndiff.h:1:#ifndef SVNDIFF_H_
>   vcs-svn/svndump.h:1:#ifndef SVNDUMP_H_

I think the ones with a trailing underscore are actually OK according to
the standard (not sure if your "all of these" was including the ones in
vcs-svn ;) ).

I'm in favor of normalizing even the ones that aren't illegal, though
I'm OK either way on the vcs-svn bits if they're going away anyway.

-Peff

```

## Ramsay Jones, 2018-10-15 00:38

Subject: Re: [RFC/PATCH] headers: normalize the spelling of some header guards
Message-ID: <f04c2f71-fe0f-a935-d49d-c71684b7558c@ramsayjones.plus.com>
URL: https://gitlist.dev/e/f04c2f71-fe0f-a935-d49d-c71684b7558c%40ramsayjones.plus.com
In-Reply-To: <20181014235950.GA13510@sigill.intra.peff.net>

```


On 15/10/18 00:59, Jeff King wrote:
> On Sun, Oct 14, 2018 at 09:13:09PM +0100, Ramsay Jones wrote:
> 
>> This patch is marked RFC because I am not aware of any policy with
>> regard to header guard spelling. Having said that, apart from the
>> fetch-negotiator.h header, all of these headers are using a reserved
>> identifier (see C99 Standard 7.1.3).
>>
>> These headers were found, thus:
>>
>>   $ git grep -n -E '^#ifn?def ' -- '*.h' | grep 'h\:1\:' | grep -v '^compat' | grep -v -E '[A-Z_]*_H$'
>>   alias.h:1:#ifndef __ALIAS_H__
>>   commit-reach.h:1:#ifndef __COMMIT_REACH_H__
>>   fetch-negotiator.h:1:#ifndef FETCH_NEGOTIATOR
>>   midx.h:1:#ifndef __MIDX_H__
>>   t/helper/test-tool.h:1:#ifndef __TEST_TOOL_H__
>>   vcs-svn/fast_export.h:1:#ifndef FAST_EXPORT_H_
>>   vcs-svn/line_buffer.h:1:#ifndef LINE_BUFFER_H_
>>   vcs-svn/sliding_window.h:1:#ifndef SLIDING_WINDOW_H_
>>   vcs-svn/svndiff.h:1:#ifndef SVNDIFF_H_
>>   vcs-svn/svndump.h:1:#ifndef SVNDUMP_H_
> 
> I think the ones with a trailing underscore are actually OK according to
> the standard (not sure if your "all of these" was including the ones in
> vcs-svn ;) ).

Yes, trailing underscore is fine - "all of these" meant the
headers in the patch, with the noted exception of fetch-negotiator.h.

> I'm in favor of normalizing even the ones that aren't illegal, though
> I'm OK either way on the vcs-svn bits if they're going away anyway.

I wasn't sure about vcs-svn, but assumed that they might go
away soon (hence the cc: list). I will be happy to add them
to the patch, if that is not the case.

Thanks.

ATB,
Ramsay Jones


```

## Junio C Hamano, 2018-10-15 03:51

Subject: Re: [RFC/PATCH] headers: normalize the spelling of some header guards
Message-ID: <xmqqmurf6f5y.fsf@gitster-ct.c.googlers.com>
URL: https://gitlist.dev/e/xmqqmurf6f5y.fsf%40gitster-ct.c.googlers.com
In-Reply-To: <20181014235950.GA13510@sigill.intra.peff.net>

```
Jeff King <peff@peff.net> writes:

> I'm in favor of normalizing even the ones that aren't illegal, though
> I'm OK either way on the vcs-svn bits if they're going away anyway.

I'm in favour of normalizing even the ones that aren't illegal, too.

```
