Skip to content

Commit

Permalink
Make clang-format sort includes
Browse files Browse the repository at this point in the history
To reduce amount of noise due to include sorting have clang-format
enforce consistent sorting across all includes.
  • Loading branch information
svenklemm committed May 25, 2024
1 parent 4aa5800 commit 4a3670e
Show file tree
Hide file tree
Showing 18 changed files with 228 additions and 53 deletions.
16 changes: 11 additions & 5 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,18 @@ ForEachMacros:
- forthree
IncludeBlocks: Preserve # separate include blocks will not be merged
IncludeCategories: # we want to ensure c.h and postgres.h appear first
- Regex: '.*'
Priority: 1
- Regex: '^<c\.h>'
Priority: -1
- Regex: '^<(string|unistd)\.h>'
Priority: -2
- Regex: '^<postgres\.h>'
Priority: -1
- Regex: '^(<|")compat/compat\.h'
Priority: -2
- Regex: '^"compat/compat-msvc-enter\.h'
Priority: -1
- Regex: '^"compat/compat-msvc-exit\.h'
Priority: 2000000000
- Regex: '.*'
Priority: 1
IncludeIsMainRegex: '' # filename_<suffix> will be seen as the primary include
IndentCaseLabels: true
IndentPPDirectives: None # do not indent preprocessor directives after the '#'
Expand All @@ -97,7 +103,7 @@ PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Right # as in char *foo;
ReflowComments: true # break up long comments into multiple lines
SortIncludes: false # keep includes in the same order as we write them
SortIncludes: CaseInsensitive # sort includes
SortUsingDeclarations: false # N/A c++
SpaceAfterCStyleCast: true
SpaceAfterTemplateKeyword: false # N/A c++
Expand Down
6 changes: 3 additions & 3 deletions test/src/bgw/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
#include <postgres.h>
#include <access/xact.h>
#include <catalog/namespace.h>
#include <utils/builtins.h>
#include <utils/lsyscache.h>
#include <postmaster/bgworker.h>
#include <storage/proc.h>
#include <utils/builtins.h>
#include <utils/lsyscache.h>

#include "log.h"
#include "scanner.h"
#include "params.h"
#include "scanner.h"
#include "ts_catalog/catalog.h"
#include "utils.h"

Expand Down
6 changes: 3 additions & 3 deletions test/src/bgw/params.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
#include <utils/lsyscache.h>
#include <utils/rel.h>

#include "params.h"
#include "timer_mock.h"
#include "test_utils.h"
#include "log.h"
#include "params.h"
#include "scanner.h"
#include "test_utils.h"
#include "timer_mock.h"
#include "ts_catalog/catalog.h"
#include "utils.h"

Expand Down
24 changes: 12 additions & 12 deletions test/src/bgw/scheduler_mock.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,34 @@
*/
#include <postgres.h>

#include <access/xact.h>
#include <miscadmin.h>
#include <pgstat.h>
#include <postmaster/bgworker.h>
#include <signal.h>
#include <storage/ipc.h>
#include <storage/latch.h>
#include <storage/lwlock.h>
#include <storage/lmgr.h>
#include <storage/lwlock.h>
#include <storage/proc.h>
#include <storage/shmem.h>
#include <utils/builtins.h>
#include <utils/guc.h>
#include <utils/jsonb.h>
#include <utils/timestamp.h>
#include <utils/snapmgr.h>
#include <utils/memutils.h>
#include <utils/builtins.h>
#include <access/xact.h>
#include <pgstat.h>
#include <signal.h>
#include <utils/snapmgr.h>
#include <utils/timestamp.h>

#include "extension.h"
#include "log.h"
#include "bgw/scheduler.h"
#include "bgw/job.h"
#include "bgw/job_stat.h"
#include "timer_mock.h"
#include "bgw/scheduler.h"
#include "cross_module_fn.h"
#include "extension.h"
#include "log.h"
#include "params.h"
#include "test_utils.h"
#include "cross_module_fn.h"
#include "time_bucket.h"
#include "timer_mock.h"

TS_FUNCTION_INFO_V1(ts_bgw_db_scheduler_test_run_and_wait_for_scheduler_finish);
TS_FUNCTION_INFO_V1(ts_bgw_db_scheduler_test_run);
Expand Down
8 changes: 4 additions & 4 deletions test/src/bgw/test_job_refresh.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
* LICENSE-APACHE for a copy of the license.
*/

#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <postgres.h>
#include <access/htup_details.h>
#include <fmgr.h>
#include <funcapi.h>
#include <access/htup_details.h>
#include <stdlib.h>
#include <time.h>
#include <utils/memutils.h>

#include "compat/compat.h"
#include "export.h"
#include "bgw/scheduler.h"
#include "export.h"

TS_FUNCTION_INFO_V1(ts_test_job_refresh);

Expand Down
6 changes: 3 additions & 3 deletions test/src/bgw/timer_mock.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
#include <utils/rel.h>

#include "annotations.h"
#include "timer_mock.h"
#include "bgw/launcher_interface.h"
#include "log.h"
#include "params.h"
#include "scanner.h"
#include "timer_mock.h"
#include "ts_catalog/catalog.h"
#include "params.h"
#include "bgw/launcher_interface.h"

static List *bgw_handles = NIL;

Expand Down
8 changes: 4 additions & 4 deletions test/src/loader/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
#ifndef WIN32
#include <access/parallel.h>
#endif
#include "compat/compat.h"
#include "export.h"
#include "extension.h"
#include <commands/extension.h>
#include <miscadmin.h>
#include <parser/analyze.h>
#include <utils/guc.h>
#include <utils/inval.h>
#include <parser/analyze.h>
#include "compat/compat.h"
#include "export.h"
#include "extension.h"

#define STR_EXPAND(x) #x
#define STR(x) STR_EXPAND(x)
Expand Down
4 changes: 2 additions & 2 deletions test/src/net/conn_mock.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
* Please see the included NOTICE for copyright information and
* LICENSE-APACHE for a copy of the license.
*/
#include <unistd.h>
#include <postgres.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
#include <postgres.h>

#include "conn_internal.h"
#include "conn_mock.h"
Expand Down
4 changes: 2 additions & 2 deletions test/src/net/test_http.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
* Please see the included NOTICE for copyright information and
* LICENSE-APACHE for a copy of the license.
*/
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <postgres.h>
#include <fmgr.h>
#include <stdlib.h>
#include <time.h>

#include "export.h"
#include "net/http.h"
Expand Down
2 changes: 1 addition & 1 deletion test/src/symbol_conflict.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* LICENSE-APACHE for a copy of the license.
*/
#include <postgres.h>
#include <utils/builtins.h>
#include <fmgr.h>
#include <utils/builtins.h>

#include "export.h"

Expand Down
10 changes: 5 additions & 5 deletions test/src/telemetry/test_telemetry.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
*/
#include <postgres.h>
#include <access/htup_details.h>
#include <fmgr.h>
#include <funcapi.h>
#include <utils/builtins.h>
#include <utils/jsonb.h>
#include <funcapi.h>
#include <fmgr.h>

#include "telemetry/telemetry.h"
#include "net/http.h"
#include "compat/compat.h"
#include "config.h"
#include "export.h"
#include "compat/compat.h"
#include "net/http.h"
#include "telemetry/telemetry.h"

#ifdef TS_DEBUG
#include "net/conn_mock.h"
Expand Down
4 changes: 2 additions & 2 deletions test/src/test_scanner.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
*/
#include <postgres.h>

#include "scanner.h"
#include "scan_iterator.h"
#include "chunk.h"
#include "scan_iterator.h"
#include "scanner.h"
#include "test_utils.h"

TS_TEST_FN(ts_test_scanner)
Expand Down
2 changes: 1 addition & 1 deletion test/src/test_time_to_internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
*/

#include <postgres.h>
#include <fmgr.h>
#include <catalog/pg_type.h>
#include <fmgr.h>
#include <utils/date.h>

#include "export.h"
Expand Down
2 changes: 1 addition & 1 deletion test/src/test_time_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
*/
#include <postgres.h>
#include <catalog/pg_type.h>
#include <utils/date.h>
#include <fmgr.h>
#include <funcapi.h>
#include <utils/date.h>

#include <time_utils.h>
#include <utils.h>
Expand Down
2 changes: 1 addition & 1 deletion test/src/test_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

#include <postgres.h>

#include <commands/dbcommands.h>
#include <compat/compat.h>
#include <commands/dbcommands.h>
#include <fmgr.h>
#include <miscadmin.h>
#include <storage/latch.h>
Expand Down
8 changes: 4 additions & 4 deletions test/src/test_with_clause_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@
*/

#include <postgres.h>
#include <fmgr.h>
#include <funcapi.h>
#include <access/htup_details.h>
#include <commands/defrem.h>
#include <catalog/pg_type.h>
#include <commands/defrem.h>
#include <fmgr.h>
#include <funcapi.h>
#include <utils/array.h>
#include <utils/builtins.h>
#include <utils/lsyscache.h>
#include <utils/memutils.h>

#include "annotations.h"
#include "export.h"
#include "test_utils.h"
#include "with_clause_parser.h"
#include "annotations.h"

static DefElem *
def_elem_from_texts(Datum *texts, int nelems)
Expand Down
Loading

0 comments on commit 4a3670e

Please sign in to comment.