char git_default_email[MAX_GITNAME];
char git_default_name[MAX_GITNAME];
-int use_legacy_headers = 1;
int trust_executable_bit = 1;
+int quote_path_fully = 1;
int has_symlinks = 1;
int assume_unchanged;
int prefer_symlink_refs;
const char *git_log_output_encoding;
int shared_repository = PERM_UMASK;
const char *apply_default_whitespace;
-int zlib_compression_level = Z_DEFAULT_COMPRESSION;
+int zlib_compression_level = Z_BEST_SPEED;
+int core_compression_level;
+int core_compression_seen;
size_t packed_git_window_size = DEFAULT_PACKED_GIT_WINDOW_SIZE;
size_t packed_git_limit = DEFAULT_PACKED_GIT_LIMIT;
size_t delta_base_cache_limit = 16 * 1024 * 1024;
+char *pager_program;
int pager_in_use;
int pager_use_color = 1;
+char *editor_program;
+char *excludes_file;
int auto_crlf = 0; /* 1: both ways, -1: only when adding git objects */
+/* This is set by setup_git_dir_gently() and/or git_default_config() */
+char *git_work_tree_cfg;
+static const char *work_tree;
+
static const char *git_dir;
static char *git_object_dir, *git_index_file, *git_refs_dir, *git_graft_file;
int is_bare_repository(void)
{
- const char *dir, *s;
- if (0 <= is_bare_repository_cfg)
- return is_bare_repository_cfg;
-
- dir = get_git_dir();
- if (!strcmp(dir, DEFAULT_GIT_DIR_ENVIRONMENT))
- return 0;
- s = strrchr(dir, '/');
- return !s || strcmp(s + 1, DEFAULT_GIT_DIR_ENVIRONMENT);
+ /* if core.bare is not 'false', let's see if there is a work tree */
+ return is_bare_repository_cfg && !get_git_work_tree();
}
const char *get_git_dir(void)
return git_dir;
}
+const char *get_git_work_tree(void)
+{
+ static int initialized = 0;
+ if (!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) {
+ work_tree = git_work_tree_cfg;
+ /* make_absolute_path also normalizes the path */
+ if (work_tree && !is_absolute_path(work_tree))
+ work_tree = xstrdup(make_absolute_path(git_path(work_tree)));
+ } else if (work_tree)
+ work_tree = xstrdup(make_absolute_path(work_tree));
+ initialized = 1;
+ if (work_tree)
+ is_bare_repository_cfg = 0;
+ }
+ return work_tree;
+}
+
char *get_object_directory(void)
{
if (!git_object_dir)
return git_graft_file;
}
-
+int set_git_dir(const char *path)
+{
+ if (setenv(GIT_DIR_ENVIRONMENT, path, 1))
+ return error("Could not set GIT_DIR to '%s'", path);
+ setup_git_env();
+ return 0;
+}