1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-25 08:56:25 +02:00

Merge branch 'nd/git-dir-pointing-at-gitfile'

We made sure that we notice the user-supplied GIT_DIR is actually a
gitfile, but did not do the same when the default ".git" is a gitfile.

* nd/git-dir-pointing-at-gitfile:
  Make setup_git_env() resolve .git file when $GIT_DIR is not specified
This commit is contained in:
Junio C Hamano 2013-09-18 11:42:36 -07:00
commit 01e0fa2b37
2 changed files with 8 additions and 5 deletions

View File

@ -123,14 +123,13 @@ static char *expand_namespace(const char *raw_namespace)
static void setup_git_env(void)
{
const char *gitfile;
git_dir = getenv(GIT_DIR_ENVIRONMENT);
git_dir = git_dir ? xstrdup(git_dir) : NULL;
if (!git_dir) {
git_dir = read_gitfile(DEFAULT_GIT_DIR_ENVIRONMENT);
git_dir = git_dir ? xstrdup(git_dir) : NULL;
}
if (!git_dir)
git_dir = DEFAULT_GIT_DIR_ENVIRONMENT;
gitfile = read_gitfile(git_dir);
git_dir = xstrdup(gitfile ? gitfile : git_dir);
git_object_dir = getenv(DB_ENVIRONMENT);
if (!git_object_dir) {
git_object_dir = xmalloc(strlen(git_dir) + 9);

View File

@ -379,6 +379,10 @@ test_expect_success 'init with separate gitdir' '
test -d realgitdir/refs
'
test_expect_success 're-init on .git file' '
( cd newdir && git init )
'
test_expect_success 're-init to update git link' '
(
cd newdir &&