summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2010-12-28 11:26:55 -0800
committerJunio C Hamano <gitster@pobox.com>2010-12-28 11:26:55 -0800
commitf3bb8b4b8452f1b7add220e787ef56c737ceff6a (patch)
tree9560624c57a06e0a1c24b7e44a9e8ebb9daaab91 /builtin
parent73e7b2ef6c62b3ec345b557acb71a8da4798c70d (diff)
parent0ed748134748579a13cf27e1e8b3e55371bcd9dc (diff)
downloadgit-f3bb8b4b8452f1b7add220e787ef56c737ceff6a.tar.gz
Merge branch 'nd/setup'
* nd/setup: (47 commits) setup_work_tree: adjust relative $GIT_WORK_TREE after moving cwd git.txt: correct where --work-tree path is relative to Revert "Documentation: always respect core.worktree if set" t0001: test git init when run via an alias Remove all logic from get_git_work_tree() setup: rework setup_explicit_git_dir() setup: clean up setup_discovered_git_dir() t1020-subdirectory: test alias expansion in a subdirectory setup: clean up setup_bare_git_dir() setup: limit get_git_work_tree()'s to explicit setup case only Use git_config_early() instead of git_config() during repo setup Add git_config_early() git-rev-parse.txt: clarify --git-dir t1510: setup case #31 t1510: setup case #30 t1510: setup case #29 t1510: setup case #28 t1510: setup case #27 t1510: setup case #26 t1510: setup case #25 ...
Diffstat (limited to 'builtin')
-rw-r--r--builtin/init-db.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/builtin/init-db.c b/builtin/init-db.c
index 9d4886c716..e3af9eaa87 100644
--- a/builtin/init-db.c
+++ b/builtin/init-db.c
@@ -414,6 +414,7 @@ static const char *const init_db_usage[] = {
int cmd_init_db(int argc, const char **argv, const char *prefix)
{
const char *git_dir;
+ const char *work_tree;
const char *template_dir = NULL;
unsigned int flags = 0;
const struct option init_db_options[] = {
@@ -480,8 +481,8 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
* without --bare. Catch the error early.
*/
git_dir = getenv(GIT_DIR_ENVIRONMENT);
- if ((!git_dir || is_bare_repository_cfg == 1)
- && getenv(GIT_WORK_TREE_ENVIRONMENT))
+ work_tree = getenv(GIT_WORK_TREE_ENVIRONMENT);
+ if ((!git_dir || is_bare_repository_cfg == 1) && work_tree)
die("%s (or --work-tree=<directory>) not allowed without "
"specifying %s (or --git-dir=<directory>)",
GIT_WORK_TREE_ENVIRONMENT,
@@ -510,10 +511,18 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
if (!getcwd(git_work_tree_cfg, PATH_MAX))
die_errno ("Cannot access current working directory");
}
+ if (work_tree)
+ set_git_work_tree(make_absolute_path(work_tree));
+ else
+ set_git_work_tree(git_work_tree_cfg);
if (access(get_git_work_tree(), X_OK))
die_errno ("Cannot access work tree '%s'",
get_git_work_tree());
}
+ else {
+ if (work_tree)
+ set_git_work_tree(make_absolute_path(work_tree));
+ }
set_git_dir(make_absolute_path(git_dir));