Skip to content

Commit

Permalink
Merge branch 'nd/git-dir-pointing-at-gitfile' into maint
Browse files Browse the repository at this point in the history
* nd/git-dir-pointing-at-gitfile:
  Make setup_git_env() resolve .git file when $GIT_DIR is not specified
  • Loading branch information
Junio C Hamano committed Oct 17, 2013
2 parents 7d9dd6d + 487a2b7 commit f8aeacf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 4 additions & 5 deletions environment.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions t/t0001-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down

0 comments on commit f8aeacf

Please sign in to comment.