diff options
| author | Junio C Hamano <gitster@pobox.com> | 2011-01-24 10:53:09 -0800 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2011-01-24 10:53:09 -0800 |
| commit | 0efbb7d9f488112d20a8ff257b72a3699aae8ef8 (patch) | |
| tree | 271f1c67fee4e3664c96e667ad009d840739f52d /setup.c | |
| parent | Documentation: do not treat reset --keep as a special case (diff) | |
| parent | t1510: fix typo in the comment of a test (diff) | |
| download | git-0efbb7d9f488112d20a8ff257b72a3699aae8ef8.tar.gz git-0efbb7d9f488112d20a8ff257b72a3699aae8ef8.zip | |
Merge branch 'jn/setup-fixes'
* jn/setup-fixes:
t1510: fix typo in the comment of a test
Documentation updates for 'GIT_WORK_TREE without GIT_DIR' historical usecase
Subject: setup: officially support --work-tree without --git-dir
tests: compress the setup tests
tests: cosmetic improvements to the repo-setup test
t/README: hint about using $(pwd) rather than $PWD in tests
Fix expected values of setup tests on Windows
Diffstat (limited to 'setup.c')
| -rw-r--r-- | setup.c | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -411,6 +411,15 @@ static const char *setup_discovered_git_dir(const char *gitdir, if (check_repository_format_gently(gitdir, nongit_ok)) return NULL; + /* --work-tree is set without --git-dir; use discovered one */ + if (getenv(GIT_WORK_TREE_ENVIRONMENT) || git_work_tree_cfg) { + if (offset != len && !is_absolute_path(gitdir)) + gitdir = xstrdup(make_absolute_path(gitdir)); + if (chdir(cwd)) + die_errno("Could not come back to cwd"); + return setup_explicit_git_dir(gitdir, cwd, len, nongit_ok); + } + /* #16.2, #17.2, #20.2, #21.2, #24, #25, #28, #29 (see t1510) */ if (is_bare_repository_cfg > 0) { set_git_dir(offset == len ? gitdir : make_absolute_path(gitdir)); @@ -443,6 +452,16 @@ static const char *setup_bare_git_dir(char *cwd, int offset, int len, int *nongi if (check_repository_format_gently(".", nongit_ok)) return NULL; + /* --work-tree is set without --git-dir; use discovered one */ + if (getenv(GIT_WORK_TREE_ENVIRONMENT) || git_work_tree_cfg) { + const char *gitdir; + + gitdir = offset == len ? "." : xmemdupz(cwd, offset); + if (chdir(cwd)) + die_errno("Could not come back to cwd"); + return setup_explicit_git_dir(gitdir, cwd, len, nongit_ok); + } + inside_git_dir = 1; inside_work_tree = 0; if (offset != len) { |
