diff options
author | Junio C Hamano <gitster@pobox.com> | 2010-12-28 11:26:55 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2010-12-28 11:26:55 -0800 |
commit | f3bb8b4b8452f1b7add220e787ef56c737ceff6a (patch) | |
tree | 9560624c57a06e0a1c24b7e44a9e8ebb9daaab91 /environment.c | |
parent | 73e7b2ef6c62b3ec345b557acb71a8da4798c70d (diff) | |
parent | 0ed748134748579a13cf27e1e8b3e55371bcd9dc (diff) | |
download | git-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 'environment.c')
-rw-r--r-- | environment.c | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/environment.c b/environment.c index c79f2a9b56..9564475f42 100644 --- a/environment.c +++ b/environment.c @@ -139,30 +139,20 @@ static int git_work_tree_initialized; */ void set_git_work_tree(const char *new_work_tree) { - if (is_bare_repository_cfg >= 0) - die("cannot set work tree after initialization"); + if (git_work_tree_initialized) { + new_work_tree = make_absolute_path(new_work_tree); + if (strcmp(new_work_tree, work_tree)) + die("internal error: work tree has already been set\n" + "Current worktree: %s\nNew worktree: %s", + work_tree, new_work_tree); + return; + } 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) { - 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) { - 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("%s", work_tree))); - } else if (work_tree) - work_tree = xstrdup(make_absolute_path(work_tree)); - git_work_tree_initialized = 1; - if (work_tree) - is_bare_repository_cfg = 0; - } return work_tree; } |