# [PATCH] Remove duplicate #include

3 messages from 2015-02-13 to 2015-02-13. Participants: Дилян Палаузов, Junio C Hamano, Dilyan Palauzov.
Thread: https://gitlist.dev/t/38563

## Дилян Палаузов, 2015-02-13 14:47

Subject: [PATCH] Remove duplicate #include
Message-ID: <1423838859-15413-1-git-send-email-git-dpa@aegee.org>
URL: https://gitlist.dev/e/1423838859-15413-1-git-send-email-git-dpa%40aegee.org

```
deheader (git://gitorious.org/deheader/deheader.git) found out that
some .c files #include twice one and the same header file.

This patch removes such occurrences and hence speeds up the compilation.

Signed-off-by: Дилян Палаузов <git-dpa@aegee.org>
---
 builtin/fetch.c    | 1 -
 trailer.c          | 1 -
 transport-helper.c | 1 -
 userdiff.c         | 1 -
 4 files changed, 4 deletions(-)

diff --git a/builtin/fetch.c b/builtin/fetch.c
index 7b84d35..75a55e5 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -11,7 +11,6 @@
 #include "run-command.h"
 #include "parse-options.h"
 #include "sigchain.h"
-#include "transport.h"
 #include "submodule.h"
 #include "connected.h"
 #include "argv-array.h"
diff --git a/trailer.c b/trailer.c
index 623adeb..05b3859 100644
--- a/trailer.c
+++ b/trailer.c
@@ -1,7 +1,6 @@
 #include "cache.h"
 #include "string-list.h"
 #include "run-command.h"
-#include "string-list.h"
 #include "commit.h"
 #include "trailer.h"
 /*
diff --git a/transport-helper.c b/transport-helper.c
index 0224687..3652b16 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -5,7 +5,6 @@
 #include "commit.h"
 #include "diff.h"
 #include "revision.h"
-#include "quote.h"
 #include "remote.h"
 #include "string-list.h"
 #include "thread-utils.h"
diff --git a/userdiff.c b/userdiff.c
index fad52d6..2ccbee5 100644
--- a/userdiff.c
+++ b/userdiff.c
@@ -1,6 +1,5 @@
 #include "cache.h"
 #include "userdiff.h"
-#include "cache.h"
 #include "attr.h"
 
 static struct userdiff_driver *drivers;
-- 
2.3.0.1.g24c2b87

```

## Junio C Hamano, 2015-02-13 21:15

Subject: Re: [PATCH] Remove duplicate #include
Message-ID: <xmqqegptms1r.fsf@gitster.dls.corp.google.com>
URL: https://gitlist.dev/e/xmqqegptms1r.fsf%40gitster.dls.corp.google.com
In-Reply-To: <1423838859-15413-1-git-send-email-git-dpa@aegee.org>

```
Дилян Палаузов  <git-dpa@aegee.org> writes:

> deheader (git://gitorious.org/deheader/deheader.git) found out that
> some .c files #include twice one and the same header file.
>
> This patch removes such occurrences and hence speeds up the compilation.

Does it speed up?  By how much?  Any numbers?

I do not see any reason to reject this change.  Removing repeated
inclusions of the same header is a good thing by itself [*1*].

Thanks.

[Footnote]

*1* If things break when repeated inclusions are removed, that would
mean the headers were wrong in the first place.  I do not think
transport.h, string-list.h, quote.h and cache.h have any reason why
they need to be included twice to work correctly, and in fact they
are designed to be no-op when included twice.

> Signed-off-by: Дилян Палаузов <git-dpa@aegee.org>
> ---
>  builtin/fetch.c    | 1 -
>  trailer.c          | 1 -
>  transport-helper.c | 1 -
>  userdiff.c         | 1 -
>  4 files changed, 4 deletions(-)
>
> diff --git a/builtin/fetch.c b/builtin/fetch.c
> index 7b84d35..75a55e5 100644
> --- a/builtin/fetch.c
> +++ b/builtin/fetch.c
> @@ -11,7 +11,6 @@
>  #include "run-command.h"
>  #include "parse-options.h"
>  #include "sigchain.h"
> -#include "transport.h"
>  #include "submodule.h"
>  #include "connected.h"
>  #include "argv-array.h"
> diff --git a/trailer.c b/trailer.c
> index 623adeb..05b3859 100644
> --- a/trailer.c
> +++ b/trailer.c
> @@ -1,7 +1,6 @@
>  #include "cache.h"
>  #include "string-list.h"
>  #include "run-command.h"
> -#include "string-list.h"
>  #include "commit.h"
>  #include "trailer.h"
>  /*
> diff --git a/transport-helper.c b/transport-helper.c
> index 0224687..3652b16 100644
> --- a/transport-helper.c
> +++ b/transport-helper.c
> @@ -5,7 +5,6 @@
>  #include "commit.h"
>  #include "diff.h"
>  #include "revision.h"
> -#include "quote.h"
>  #include "remote.h"
>  #include "string-list.h"
>  #include "thread-utils.h"
> diff --git a/userdiff.c b/userdiff.c
> index fad52d6..2ccbee5 100644
> --- a/userdiff.c
> +++ b/userdiff.c
> @@ -1,6 +1,5 @@
>  #include "cache.h"
>  #include "userdiff.h"
> -#include "cache.h"
>  #include "attr.h"
>  
>  static struct userdiff_driver *drivers;

```

## Dilyan Palauzov, 2015-02-13 21:57

Subject: Re: [PATCH] Remove duplicate #include
Message-ID: <54DE7347.3000107@aegee.org>
URL: https://gitlist.dev/e/54DE7347.3000107%40aegee.org
In-Reply-To: <xmqqegptms1r.fsf@gitster.dls.corp.google.com>

```
Hello Junio,

in theory it speeds up, because the preprocessor has less work to do.
In practice I don't know how much and this seems also irrelevant
criterion for accepting this patch.

Greetings
  Dilyan

On 13.02.2015 22:15, Junio C Hamano wrote:
> Дилян Палаузов  <git-dpa@aegee.org> writes:
> 
>> deheader (git://gitorious.org/deheader/deheader.git) found out that
>> some .c files #include twice one and the same header file.
>>
>> This patch removes such occurrences and hence speeds up the compilation.
> 
> Does it speed up?  By how much?  Any numbers?
> 
> I do not see any reason to reject this change.  Removing repeated
> inclusions of the same header is a good thing by itself [*1*].
> 
> Thanks.
> 
> [Footnote]
> 
> *1* If things break when repeated inclusions are removed, that would
> mean the headers were wrong in the first place.  I do not think
> transport.h, string-list.h, quote.h and cache.h have any reason why
> they need to be included twice to work correctly, and in fact they
> are designed to be no-op when included twice.
> 
>> Signed-off-by: Дилян Палаузов <git-dpa@aegee.org>
>> ---
>>   builtin/fetch.c    | 1 -
>>   trailer.c          | 1 -
>>   transport-helper.c | 1 -
>>   userdiff.c         | 1 -
>>   4 files changed, 4 deletions(-)
>>
>> diff --git a/builtin/fetch.c b/builtin/fetch.c
>> index 7b84d35..75a55e5 100644
>> --- a/builtin/fetch.c
>> +++ b/builtin/fetch.c
>> @@ -11,7 +11,6 @@
>>   #include "run-command.h"
>>   #include "parse-options.h"
>>   #include "sigchain.h"
>> -#include "transport.h"
>>   #include "submodule.h"
>>   #include "connected.h"
>>   #include "argv-array.h"
>> diff --git a/trailer.c b/trailer.c
>> index 623adeb..05b3859 100644
>> --- a/trailer.c
>> +++ b/trailer.c
>> @@ -1,7 +1,6 @@
>>   #include "cache.h"
>>   #include "string-list.h"
>>   #include "run-command.h"
>> -#include "string-list.h"
>>   #include "commit.h"
>>   #include "trailer.h"
>>   /*
>> diff --git a/transport-helper.c b/transport-helper.c
>> index 0224687..3652b16 100644
>> --- a/transport-helper.c
>> +++ b/transport-helper.c
>> @@ -5,7 +5,6 @@
>>   #include "commit.h"
>>   #include "diff.h"
>>   #include "revision.h"
>> -#include "quote.h"
>>   #include "remote.h"
>>   #include "string-list.h"
>>   #include "thread-utils.h"
>> diff --git a/userdiff.c b/userdiff.c
>> index fad52d6..2ccbee5 100644
>> --- a/userdiff.c
>> +++ b/userdiff.c
>> @@ -1,6 +1,5 @@
>>   #include "cache.h"
>>   #include "userdiff.h"
>> -#include "cache.h"
>>   #include "attr.h"
>>   
>>   static struct userdiff_driver *drivers;

```
