environment: reorder header to split out `the_repository`-free section
Reorder the "environment.h" header such that declarations which are free from `the_repository` come before those which aren't. The new structure is now: - Defines for environment variable names. - Things which do not rely on a repository. - Things which do, including those that implicitly rely on a parsed repository. This includes for example variables which get populated when reading repository config. This will allow us to guard the last category of declarations with `USE_THE_REPOSITORY_VARIABLE`. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Patrick Steinhardt committed
Sep 12, 2024 at 13:29 UTC
f2d70847bd21f00045700aebca023f9c07ba87ac
1 file changed
+40
-41
environment.h
+40
-41
@@ -1,22 +1,6 @@
1
#ifndef ENVIRONMENT_H
2
#define ENVIRONMENT_H
3
4
-struct strvec;
5
-
6
-/*
7
- * The character that begins a commented line in user-editable file
8
- * that is subject to stripspace.
9
- */
10
-extern const char *comment_line_str;
11
-extern char *comment_line_str_to_free;
12
-extern int auto_comment_line_char;
13
-
14
-/*
15
- * Wrapper of getenv() that returns a strdup value. This value is kept
16
- * in argv to be freed later.
17
- */
18
-const char *getenv_safe(struct strvec *argv, const char *name);
19
-
4
/* Double-check local_repo_env below if you add to this list. */
5
#define GIT_DIR_ENVIRONMENT "GIT_DIR"
6
#define GIT_COMMON_DIR_ENVIRONMENT "GIT_COMMON_DIR"
@@ -86,6 +70,8 @@ const char *getenv_safe(struct strvec *argv, const char *name);
70
*/
71
#define GIT_IMPLICIT_WORK_TREE_ENVIRONMENT "GIT_IMPLICIT_WORK_TREE"
72
73
+#define ALTERNATE_DB_ENVIRONMENT "GIT_ALTERNATE_OBJECT_DIRECTORIES"
74
+
75
/*
76
* Repository-local GIT_* environment variables; these will be cleared
77
* when git spawns a sub-process that runs inside another repository.
@@ -94,6 +80,28 @@ const char *getenv_safe(struct strvec *argv, const char *name);
80
*/
81
extern const char * const local_repo_env[];
82
83
+struct strvec;
84
+
85
+/*
86
+ * Wrapper of getenv() that returns a strdup value. This value is kept
87
+ * in argv to be freed later.
88
+ */
89
+const char *getenv_safe(struct strvec *argv, const char *name);
90
+
91
+/*
92
+ * Should we print an ellipsis after an abbreviated SHA-1 value
93
+ * when doing diff-raw output or indicating a detached HEAD?
94
+ */
95
+int print_sha1_ellipsis(void);
96
+
97
+/*
98
+ * Returns the boolean value of $GIT_OPTIONAL_LOCKS (or the default value).
99
+ */
100
+int use_optional_locks(void);
101
+
102
+const char *get_git_namespace(void);
103
+const char *strip_namespace(const char *namespaced_ref);
104
+
105
void setup_git_env(const char *git_dir);
106
107
/*
@@ -102,13 +110,19 @@ void setup_git_env(const char *git_dir);
110
*/
111
int have_git_dir(void);
112
113
+/*
114
+ * Accessors for the core.sharedrepository config which lazy-load the value
115
+ * from the config (if not already set). The "reset" function can be
116
+ * used to unset "set" or cached value, meaning that the value will be loaded
117
+ * fresh from the config file on the next call to get_shared_repository().
118
+ */
119
+void set_shared_repository(int value);
120
+int get_shared_repository(void);
121
+void reset_shared_repository(void);
122
+
123
extern int is_bare_repository_cfg;
124
int is_bare_repository(void);
125
extern char *git_work_tree_cfg;
108
-const char *get_git_namespace(void);
109
-const char *strip_namespace(const char *namespaced_ref);
110
-
111
-#define ALTERNATE_DB_ENVIRONMENT "GIT_ALTERNATE_OBJECT_DIRECTORIES"
126
127
/* Environment bits from configuration mechanism */
128
extern int trust_executable_bit;
@@ -134,16 +148,6 @@ extern unsigned long big_file_threshold;
148
extern unsigned long pack_size_limit_cfg;
149
extern int max_allowed_tree_depth;
150
137
-/*
138
- * Accessors for the core.sharedrepository config which lazy-load the value
139
- * from the config (if not already set). The "reset" function can be
140
- * used to unset "set" or cached value, meaning that the value will be loaded
141
- * fresh from the config file on the next call to get_shared_repository().
142
- */
143
-void set_shared_repository(int value);
144
-int get_shared_repository(void);
145
-void reset_shared_repository(void);
146
-
151
extern int core_preload_index;
152
extern int precomposed_unicode;
153
extern int protect_hfs;
@@ -153,11 +157,6 @@ extern int core_apply_sparse_checkout;
157
extern int core_sparse_checkout_cone;
158
extern int sparse_expect_files_outside_of_patterns;
159
156
-/*
157
- * Returns the boolean value of $GIT_OPTIONAL_LOCKS (or the default value).
158
- */
159
-int use_optional_locks(void);
160
-
160
enum log_refs_config {
161
LOG_REFS_UNSET = -1,
162
LOG_REFS_NONE = 0,
@@ -172,6 +171,7 @@ enum rebase_setup_type {
171
AUTOREBASE_REMOTE,
172
AUTOREBASE_ALWAYS
173
};
174
+extern enum rebase_setup_type autorebase;
175
176
enum push_default_type {
177
PUSH_DEFAULT_NOTHING = 0,
@@ -181,15 +181,12 @@ enum push_default_type {
181
PUSH_DEFAULT_CURRENT,
182
PUSH_DEFAULT_UNSPECIFIED
183
};
184
-
185
-extern enum rebase_setup_type autorebase;
184
extern enum push_default_type push_default;
185
186
enum object_creation_mode {
187
OBJECT_CREATION_USES_HARDLINKS = 0,
188
OBJECT_CREATION_USES_RENAMES = 1
189
};
192
-
190
extern enum object_creation_mode object_creation_mode;
191
192
extern char *notes_ref_name;
@@ -209,9 +206,11 @@ extern char *askpass_program;
206
extern char *excludes_file;
207
208
/*
212
- * Should we print an ellipsis after an abbreviated SHA-1 value
213
- * when doing diff-raw output or indicating a detached HEAD?
209
+ * The character that begins a commented line in user-editable file
210
+ * that is subject to stripspace.
211
*/
215
-int print_sha1_ellipsis(void);
212
+extern const char *comment_line_str;
213
+extern char *comment_line_str_to_free;
214
+extern int auto_comment_line_char;
215
216
#endif