Skip to content

Commit f2d7084

Browse files
pks-tgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a52beae commit f2d7084

File tree

1 file changed

+40
-41
lines changed

1 file changed

+40
-41
lines changed

environment.h

Lines changed: 40 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,6 @@
11
#ifndef ENVIRONMENT_H
22
#define ENVIRONMENT_H
33

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-
204
/* Double-check local_repo_env below if you add to this list. */
215
#define GIT_DIR_ENVIRONMENT "GIT_DIR"
226
#define GIT_COMMON_DIR_ENVIRONMENT "GIT_COMMON_DIR"
@@ -86,6 +70,8 @@ const char *getenv_safe(struct strvec *argv, const char *name);
8670
*/
8771
#define GIT_IMPLICIT_WORK_TREE_ENVIRONMENT "GIT_IMPLICIT_WORK_TREE"
8872

73+
#define ALTERNATE_DB_ENVIRONMENT "GIT_ALTERNATE_OBJECT_DIRECTORIES"
74+
8975
/*
9076
* Repository-local GIT_* environment variables; these will be cleared
9177
* 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);
9480
*/
9581
extern const char * const local_repo_env[];
9682

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+
97105
void setup_git_env(const char *git_dir);
98106

99107
/*
@@ -102,13 +110,19 @@ void setup_git_env(const char *git_dir);
102110
*/
103111
int have_git_dir(void);
104112

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+
105123
extern int is_bare_repository_cfg;
106124
int is_bare_repository(void);
107125
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"
112126

113127
/* Environment bits from configuration mechanism */
114128
extern int trust_executable_bit;
@@ -134,16 +148,6 @@ extern unsigned long big_file_threshold;
134148
extern unsigned long pack_size_limit_cfg;
135149
extern int max_allowed_tree_depth;
136150

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-
147151
extern int core_preload_index;
148152
extern int precomposed_unicode;
149153
extern int protect_hfs;
@@ -153,11 +157,6 @@ extern int core_apply_sparse_checkout;
153157
extern int core_sparse_checkout_cone;
154158
extern int sparse_expect_files_outside_of_patterns;
155159

156-
/*
157-
* Returns the boolean value of $GIT_OPTIONAL_LOCKS (or the default value).
158-
*/
159-
int use_optional_locks(void);
160-
161160
enum log_refs_config {
162161
LOG_REFS_UNSET = -1,
163162
LOG_REFS_NONE = 0,
@@ -172,6 +171,7 @@ enum rebase_setup_type {
172171
AUTOREBASE_REMOTE,
173172
AUTOREBASE_ALWAYS
174173
};
174+
extern enum rebase_setup_type autorebase;
175175

176176
enum push_default_type {
177177
PUSH_DEFAULT_NOTHING = 0,
@@ -181,15 +181,12 @@ enum push_default_type {
181181
PUSH_DEFAULT_CURRENT,
182182
PUSH_DEFAULT_UNSPECIFIED
183183
};
184-
185-
extern enum rebase_setup_type autorebase;
186184
extern enum push_default_type push_default;
187185

188186
enum object_creation_mode {
189187
OBJECT_CREATION_USES_HARDLINKS = 0,
190188
OBJECT_CREATION_USES_RENAMES = 1
191189
};
192-
193190
extern enum object_creation_mode object_creation_mode;
194191

195192
extern char *notes_ref_name;
@@ -209,9 +206,11 @@ extern char *askpass_program;
209206
extern char *excludes_file;
210207

211208
/*
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.
214211
*/
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;
216215

217216
#endif

0 commit comments

Comments
 (0)