Skip to content

Commit 08b7758

Browse files
pks-tgitster
authored andcommitted
config: move Git config parsing into "environment.c"
In "config.c" we host both the business logic to read and write config files as well as the logic to parse specific Git-related variables. On the one hand this is mixing concerns, but even more importantly it means that we cannot easily remove the dependency on `the_repository` in our config parsing logic. Move the logic into "environment.c". This file is a grab bag of all kinds of global state already, so it is quite a good fit. Furthermore, it also hosts most of the global variables that we're parsing the config values into, making this an even better fit. Note that there is one hidden change: in `parse_fsync_components()` we use an `int` to iterate through `ARRAY_SIZE(fsync_component_names)`. But as -Wsign-compare warnings are enabled in this file this causes a compiler warning. The issue is fixed by using a `size_t` instead. This change allows us to drop the `USE_THE_REPOSITORY_VARIABLE` declaration. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 00271bb commit 08b7758

Some content is hidden

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

55 files changed

+566
-514
lines changed

builtin/add.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "builtin.h"
88
#include "advice.h"
99
#include "config.h"
10+
#include "environment.h"
1011
#include "lockfile.h"
1112
#include "editor.h"
1213
#include "dir.h"

builtin/check-ignore.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "builtin.h"
33
#include "config.h"
44
#include "dir.h"
5+
#include "environment.h"
56
#include "gettext.h"
67
#include "quote.h"
78
#include "pathspec.h"

builtin/check-mailmap.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#define USE_THE_REPOSITORY_VARIABLE
22
#include "builtin.h"
33
#include "config.h"
4+
#include "environment.h"
45
#include "gettext.h"
56
#include "ident.h"
67
#include "mailmap.h"

builtin/checkout--worker.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "builtin.h"
55
#include "config.h"
66
#include "entry.h"
7+
#include "environment.h"
78
#include "gettext.h"
89
#include "parallel-checkout.h"
910
#include "parse-options.h"

builtin/checkout-index.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#include "builtin.h"
1111
#include "config.h"
12+
#include "environment.h"
1213
#include "gettext.h"
1314
#include "lockfile.h"
1415
#include "quote.h"

builtin/clean.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "abspath.h"
1414
#include "config.h"
1515
#include "dir.h"
16+
#include "environment.h"
1617
#include "gettext.h"
1718
#include "parse-options.h"
1819
#include "path.h"

builtin/commit-graph.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "builtin.h"
33
#include "commit.h"
44
#include "config.h"
5+
#include "environment.h"
56
#include "gettext.h"
67
#include "hex.h"
78
#include "parse-options.h"

builtin/commit-tree.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#define USE_THE_REPOSITORY_VARIABLE
77
#include "builtin.h"
88
#include "config.h"
9+
#include "environment.h"
910
#include "gettext.h"
1011
#include "hex.h"
1112
#include "object-name.h"

builtin/count-objects.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "builtin.h"
88
#include "config.h"
99
#include "dir.h"
10+
#include "environment.h"
1011
#include "gettext.h"
1112
#include "path.h"
1213
#include "parse-options.h"

builtin/credential.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "git-compat-util.h"
44
#include "credential.h"
55
#include "builtin.h"
6+
#include "environment.h"
67
#include "config.h"
78

89
static const char usage_msg[] =

0 commit comments

Comments
 (0)