X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=environment.c;h=73feb2d03a917d1fbdc8d9397b42fd90e5916bca;hb=efb98b44536300f5daed25da3650033a1ce7fdef;hp=6739a3f41745fe1c01dc767e09af8746d6f2815f;hpb=b75aaa546e0593440d85c77d380c9b53e126ea02;p=git.git diff --git a/environment.c b/environment.c index 6739a3f41..73feb2d03 100644 --- a/environment.c +++ b/environment.c @@ -11,9 +11,11 @@ char git_default_email[MAX_GITNAME]; char git_default_name[MAX_GITNAME]; +int user_ident_explicitly_given; int trust_executable_bit = 1; int quote_path_fully = 1; int has_symlinks = 1; +int ignore_case; int assume_unchanged; int prefer_symlink_refs; int is_bare_repository_cfg = -1; /* unspecified */ @@ -38,10 +40,11 @@ int auto_crlf = 0; /* 1: both ways, -1: only when adding git objects */ enum safe_crlf safe_crlf = SAFE_CRLF_WARN; unsigned whitespace_rule_cfg = WS_DEFAULT_RULE; enum branch_track git_branch_track = BRANCH_TRACK_REMOTE; +enum rebase_setup_type autorebase = AUTOREBASE_NEVER; /* This is set by setup_git_dir_gently() and/or git_default_config() */ char *git_work_tree_cfg; -static const char *work_tree; +static char *work_tree; static const char *git_dir; static char *git_object_dir, *git_index_file, *git_refs_dir, *git_graft_file; @@ -49,6 +52,8 @@ static char *git_object_dir, *git_index_file, *git_refs_dir, *git_graft_file; static void setup_git_env(void) { git_dir = getenv(GIT_DIR_ENVIRONMENT); + if (!git_dir) + git_dir = read_gitfile_gently(DEFAULT_GIT_DIR_ENVIRONMENT); if (!git_dir) git_dir = DEFAULT_GIT_DIR_ENVIRONMENT; git_object_dir = getenv(DB_ENVIRONMENT); @@ -81,10 +86,26 @@ const char *get_git_dir(void) return git_dir; } +static int git_work_tree_initialized; + +/* + * Note. This works only before you used a work tree. This was added + * primarily to support git-clone to work in a new repository it just + * created, and is not meant to flip between different work trees. + */ +void set_git_work_tree(const char *new_work_tree) +{ + if (is_bare_repository_cfg >= 0) + die("cannot set work tree after initialization"); + git_work_tree_initialized = 1; + free(work_tree); + work_tree = xstrdup(make_absolute_path(new_work_tree)); + is_bare_repository_cfg = 0; +} + const char *get_git_work_tree(void) { - static int initialized = 0; - if (!initialized) { + if (!git_work_tree_initialized) { work_tree = getenv(GIT_WORK_TREE_ENVIRONMENT); /* core.bare = true overrides implicit and config work tree */ if (!work_tree && is_bare_repository_cfg < 1) { @@ -94,7 +115,7 @@ const char *get_git_work_tree(void) work_tree = xstrdup(make_absolute_path(git_path(work_tree))); } else if (work_tree) work_tree = xstrdup(make_absolute_path(work_tree)); - initialized = 1; + git_work_tree_initialized = 1; if (work_tree) is_bare_repository_cfg = 0; }