Merge branch 'db/clone-in-c'
* db/clone-in-c: Add test for cloning with "--reference" repo being a subset of source repo Add a test for another combination of --reference Test that --reference actually suppresses fetching referenced objects clone: fall back to copying if hardlinking fails builtin-clone.c: Need to closedir() in copy_or_link_directory() builtin-clone: fix initial checkout Build in clone Provide API access to init_db() Add a function to set a non-default work tree Allow for having for_each_ref() list extra refs Have a constant extern refspec for "--tags" Add a library function to add an alternate to the alternates file Add a lockfile function to append to a file Mark the list of refs to fetch as const Conflicts: cache.h t/t5700-clone-reference.sh
This commit is contained in:
@ -44,7 +44,7 @@ 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;
|
||||
@ -86,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) {
|
||||
@ -99,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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user