Skip to content

Commit 0c7f49d

Browse files
committed
Make sure to always include "common.h" first
Next to including several files, our "common.h" header also declares various macros which are then used throughout the project. As such, we have to make sure to always include this file first in all implementation files. Otherwise, we might encounter problems or even silent behavioural differences due to macros or defines not being defined as they should be. So in fact, our header and implementation files should make sure to always include "common.h" first. This commit does so by establishing a common include pattern. Header files inside of "src" will now always include "common.h" as its first other file, separated by a newline from all the other includes to make it stand out as special. There are two cases for the implementation files. If they do have a matching header file, they will always include this one first, leading to "common.h" being transitively included as first file. If they do not have a matching header file, they instead include "common.h" as first file themselves. This fixes the outlined problems and will become our standard practice for header and source files inside of the "src/" from now on.
1 parent 2480d0e commit 0c7f49d

File tree

235 files changed

+437
-143
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

235 files changed

+437
-143
lines changed

src/annotated_commit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* a Linking Exception. For full terms see the included COPYING file.
66
*/
77

8-
#include "common.h"
98
#include "annotated_commit.h"
9+
1010
#include "refs.h"
1111
#include "cache.h"
1212

src/annotated_commit.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#ifndef INCLUDE_annotated_commit_h__
88
#define INCLUDE_annotated_commit_h__
99

10+
#include "common.h"
11+
1012
#include "oidarray.h"
1113

1214
#include "git2/oid.h"

src/apply.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55
* a Linking Exception. For full terms see the included COPYING file.
66
*/
77

8+
#include "apply.h"
9+
810
#include <assert.h>
911

1012
#include "git2/patch.h"
1113
#include "git2/filter.h"
1214
#include "array.h"
1315
#include "patch.h"
1416
#include "fileops.h"
15-
#include "apply.h"
1617
#include "delta.h"
1718
#include "zstream.h"
1819

src/apply.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#ifndef INCLUDE_apply_h__
88
#define INCLUDE_apply_h__
99

10+
#include "common.h"
11+
1012
#include "git2/patch.h"
1113
#include "buffer.h"
1214

src/attr.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
* a Linking Exception. For full terms see the included COPYING file.
66
*/
77

8-
#include "common.h"
8+
#include "attr.h"
9+
910
#include "repository.h"
1011
#include "sysdir.h"
1112
#include "config.h"

src/attr.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#ifndef INCLUDE_attr_h__
88
#define INCLUDE_attr_h__
99

10+
#include "common.h"
11+
1012
#include "attr_file.h"
1113
#include "attrcache.h"
1214

src/attr_file.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
* a Linking Exception. For full terms see the included COPYING file.
66
*/
77

8-
#include "common.h"
8+
#include "attr_file.h"
9+
910
#include "repository.h"
1011
#include "filebuf.h"
11-
#include "attr_file.h"
1212
#include "attrcache.h"
1313
#include "git2/blob.h"
1414
#include "git2/tree.h"

src/attr_file.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#ifndef INCLUDE_attr_file_h__
88
#define INCLUDE_attr_file_h__
99

10+
#include "common.h"
11+
1012
#include "git2/oid.h"
1113
#include "git2/attr.h"
1214
#include "vector.h"

src/attrcache.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
* a Linking Exception. For full terms see the included COPYING file.
66
*/
77

8-
#include "common.h"
8+
#include "attrcache.h"
9+
910
#include "repository.h"
1011
#include "attr_file.h"
1112
#include "config.h"

src/attrcache.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#ifndef INCLUDE_attrcache_h__
88
#define INCLUDE_attrcache_h__
99

10+
#include "common.h"
11+
1012
#include "attr_file.h"
1113
#include "strmap.h"
1214

0 commit comments

Comments
 (0)