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>
This commit is contained in:
Patrick Steinhardt
2024-09-12 13:29:59 +02:00
committed by Junio C Hamano
parent a52beae3a3
commit f2d70847bd

View File

@@ -1,22 +1,6 @@
#ifndef ENVIRONMENT_H #ifndef ENVIRONMENT_H
#define ENVIRONMENT_H #define ENVIRONMENT_H
struct strvec;
/*
* The character that begins a commented line in user-editable file
* that is subject to stripspace.
*/
extern const char *comment_line_str;
extern char *comment_line_str_to_free;
extern int auto_comment_line_char;
/*
* Wrapper of getenv() that returns a strdup value. This value is kept
* in argv to be freed later.
*/
const char *getenv_safe(struct strvec *argv, const char *name);
/* Double-check local_repo_env below if you add to this list. */ /* Double-check local_repo_env below if you add to this list. */
#define GIT_DIR_ENVIRONMENT "GIT_DIR" #define GIT_DIR_ENVIRONMENT "GIT_DIR"
#define GIT_COMMON_DIR_ENVIRONMENT "GIT_COMMON_DIR" #define GIT_COMMON_DIR_ENVIRONMENT "GIT_COMMON_DIR"
@@ -86,6 +70,8 @@ const char *getenv_safe(struct strvec *argv, const char *name);
*/ */
#define GIT_IMPLICIT_WORK_TREE_ENVIRONMENT "GIT_IMPLICIT_WORK_TREE" #define GIT_IMPLICIT_WORK_TREE_ENVIRONMENT "GIT_IMPLICIT_WORK_TREE"
#define ALTERNATE_DB_ENVIRONMENT "GIT_ALTERNATE_OBJECT_DIRECTORIES"
/* /*
* Repository-local GIT_* environment variables; these will be cleared * Repository-local GIT_* environment variables; these will be cleared
* when git spawns a sub-process that runs inside another repository. * 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);
*/ */
extern const char * const local_repo_env[]; extern const char * const local_repo_env[];
struct strvec;
/*
* Wrapper of getenv() that returns a strdup value. This value is kept
* in argv to be freed later.
*/
const char *getenv_safe(struct strvec *argv, const char *name);
/*
* Should we print an ellipsis after an abbreviated SHA-1 value
* when doing diff-raw output or indicating a detached HEAD?
*/
int print_sha1_ellipsis(void);
/*
* Returns the boolean value of $GIT_OPTIONAL_LOCKS (or the default value).
*/
int use_optional_locks(void);
const char *get_git_namespace(void);
const char *strip_namespace(const char *namespaced_ref);
void setup_git_env(const char *git_dir); void setup_git_env(const char *git_dir);
/* /*
@@ -102,13 +110,19 @@ void setup_git_env(const char *git_dir);
*/ */
int have_git_dir(void); int have_git_dir(void);
/*
* Accessors for the core.sharedrepository config which lazy-load the value
* from the config (if not already set). The "reset" function can be
* used to unset "set" or cached value, meaning that the value will be loaded
* fresh from the config file on the next call to get_shared_repository().
*/
void set_shared_repository(int value);
int get_shared_repository(void);
void reset_shared_repository(void);
extern int is_bare_repository_cfg; extern int is_bare_repository_cfg;
int is_bare_repository(void); int is_bare_repository(void);
extern char *git_work_tree_cfg; extern char *git_work_tree_cfg;
const char *get_git_namespace(void);
const char *strip_namespace(const char *namespaced_ref);
#define ALTERNATE_DB_ENVIRONMENT "GIT_ALTERNATE_OBJECT_DIRECTORIES"
/* Environment bits from configuration mechanism */ /* Environment bits from configuration mechanism */
extern int trust_executable_bit; extern int trust_executable_bit;
@@ -134,16 +148,6 @@ extern unsigned long big_file_threshold;
extern unsigned long pack_size_limit_cfg; extern unsigned long pack_size_limit_cfg;
extern int max_allowed_tree_depth; extern int max_allowed_tree_depth;
/*
* Accessors for the core.sharedrepository config which lazy-load the value
* from the config (if not already set). The "reset" function can be
* used to unset "set" or cached value, meaning that the value will be loaded
* fresh from the config file on the next call to get_shared_repository().
*/
void set_shared_repository(int value);
int get_shared_repository(void);
void reset_shared_repository(void);
extern int core_preload_index; extern int core_preload_index;
extern int precomposed_unicode; extern int precomposed_unicode;
extern int protect_hfs; extern int protect_hfs;
@@ -153,11 +157,6 @@ extern int core_apply_sparse_checkout;
extern int core_sparse_checkout_cone; extern int core_sparse_checkout_cone;
extern int sparse_expect_files_outside_of_patterns; extern int sparse_expect_files_outside_of_patterns;
/*
* Returns the boolean value of $GIT_OPTIONAL_LOCKS (or the default value).
*/
int use_optional_locks(void);
enum log_refs_config { enum log_refs_config {
LOG_REFS_UNSET = -1, LOG_REFS_UNSET = -1,
LOG_REFS_NONE = 0, LOG_REFS_NONE = 0,
@@ -172,6 +171,7 @@ enum rebase_setup_type {
AUTOREBASE_REMOTE, AUTOREBASE_REMOTE,
AUTOREBASE_ALWAYS AUTOREBASE_ALWAYS
}; };
extern enum rebase_setup_type autorebase;
enum push_default_type { enum push_default_type {
PUSH_DEFAULT_NOTHING = 0, PUSH_DEFAULT_NOTHING = 0,
@@ -181,15 +181,12 @@ enum push_default_type {
PUSH_DEFAULT_CURRENT, PUSH_DEFAULT_CURRENT,
PUSH_DEFAULT_UNSPECIFIED PUSH_DEFAULT_UNSPECIFIED
}; };
extern enum rebase_setup_type autorebase;
extern enum push_default_type push_default; extern enum push_default_type push_default;
enum object_creation_mode { enum object_creation_mode {
OBJECT_CREATION_USES_HARDLINKS = 0, OBJECT_CREATION_USES_HARDLINKS = 0,
OBJECT_CREATION_USES_RENAMES = 1 OBJECT_CREATION_USES_RENAMES = 1
}; };
extern enum object_creation_mode object_creation_mode; extern enum object_creation_mode object_creation_mode;
extern char *notes_ref_name; extern char *notes_ref_name;
@@ -209,9 +206,11 @@ extern char *askpass_program;
extern char *excludes_file; extern char *excludes_file;
/* /*
* Should we print an ellipsis after an abbreviated SHA-1 value * The character that begins a commented line in user-editable file
* when doing diff-raw output or indicating a detached HEAD? * that is subject to stripspace.
*/ */
int print_sha1_ellipsis(void); extern const char *comment_line_str;
extern char *comment_line_str_to_free;
extern int auto_comment_line_char;
#endif #endif