#include "refs.h"
#include "fmt-merge-msg.h"
#include "commit.h"
+#include "argv-array.h"
int trust_executable_bit = 1;
int trust_ctime = 1;
int warn_on_object_refname_ambiguity = 1;
int ref_paranoia = -1;
int repository_format_precious_objects;
+char *repository_format_partial_clone;
+const char *core_partial_clone_filter_default;
const char *git_commit_encoding;
const char *git_log_output_encoding;
const char *apply_default_whitespace;
int check_replace_refs = 1;
char *git_replace_ref_base;
enum eol core_eol = EOL_UNSET;
-enum safe_crlf safe_crlf = SAFE_CRLF_WARN;
+int global_conv_flags_eol = CONV_EOL_RNDTRP_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 char *namespace;
+static char *git_namespace;
static const char *super_prefix;
return strbuf_detach(&buf, NULL);
}
-void setup_git_env(void)
+/*
+ * Wrapper of getenv() that returns a strdup value. This value is kept
+ * in argv to be freed later.
+ */
+static const char *getenv_safe(struct argv_array *argv, const char *name)
+{
+ const char *value = getenv(name);
+
+ if (!value)
+ return NULL;
+
+ argv_array_push(argv, value);
+ return argv->argv[argv->argc - 1];
+}
+
+void setup_git_env(const char *git_dir)
{
const char *shallow_file;
const char *replace_ref_base;
+ struct set_gitdir_args args = { NULL };
+ struct argv_array to_free = ARGV_ARRAY_INIT;
+
+ args.commondir = getenv_safe(&to_free, GIT_COMMON_DIR_ENVIRONMENT);
+ args.object_dir = getenv_safe(&to_free, DB_ENVIRONMENT);
+ args.graft_file = getenv_safe(&to_free, GRAFT_ENVIRONMENT);
+ args.index_file = getenv_safe(&to_free, INDEX_ENVIRONMENT);
+ args.alternate_db = getenv_safe(&to_free, ALTERNATE_DB_ENVIRONMENT);
+ repo_set_gitdir(the_repository, git_dir, &args);
+ argv_array_clear(&to_free);
if (getenv(NO_REPLACE_OBJECTS_ENVIRONMENT))
check_replace_refs = 0;
free(git_replace_ref_base);
git_replace_ref_base = xstrdup(replace_ref_base ? replace_ref_base
: "refs/replace/");
- free(namespace);
- namespace = expand_namespace(getenv(GIT_NAMESPACE_ENVIRONMENT));
+ free(git_namespace);
+ git_namespace = expand_namespace(getenv(GIT_NAMESPACE_ENVIRONMENT));
shallow_file = getenv(GIT_SHALLOW_FILE_ENVIRONMENT);
if (shallow_file)
set_alternate_shallow_file(shallow_file, 0);
const char *get_git_namespace(void)
{
- if (!namespace)
+ if (!git_namespace)
BUG("git environment hasn't been setup");
- return namespace;
+ return git_namespace;
}
const char *strip_namespace(const char *namespaced_ref)
{
if (setenv(GIT_DIR_ENVIRONMENT, path, 1))
return error("Could not set GIT_DIR to '%s'", path);
- repo_set_gitdir(the_repository, path);
- setup_git_env();
+ setup_git_env(path);
return 0;
}