diff options
author | Junio C Hamano <gitster@pobox.com> | 2011-05-02 15:58:30 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2011-05-02 15:58:30 -0700 |
commit | c67e367c50304c5a0701ae2bb8ecb7291f481ffd (patch) | |
tree | 6c4015ddf403faec0ed182c39341cb42e670f878 /setup.c | |
parent | 2db8926236406a4e4cb17d1b9c4b791706fb0512 (diff) | |
parent | b892913d51795ee66d825bedd23e5c4ffe85ebb2 (diff) | |
download | git-c67e367c50304c5a0701ae2bb8ecb7291f481ffd.tar.gz |
Merge branch 'nd/maint-setup'
* nd/maint-setup:
Kill off get_relative_cwd()
setup: return correct prefix if worktree is '/'
Conflicts:
dir.c
setup.c
Diffstat (limited to 'setup.c')
-rw-r--r-- | setup.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -325,6 +325,7 @@ static const char *setup_explicit_git_dir(const char *gitdirenv, const char *work_tree_env = getenv(GIT_WORK_TREE_ENVIRONMENT); const char *worktree; char *gitfile; + int offset; if (PATH_MAX - 40 < strlen(gitdirenv)) die("'$%s' too big", GIT_DIR_ENVIRONMENT); @@ -390,15 +391,15 @@ static const char *setup_explicit_git_dir(const char *gitdirenv, return NULL; } - if (!prefixcmp(cwd, worktree) && - cwd[strlen(worktree)] == '/') { /* cwd inside worktree */ + offset = dir_inside_of(cwd, worktree); + if (offset >= 0) { /* cwd inside worktree? */ set_git_dir(real_path(gitdirenv)); if (chdir(worktree)) die_errno("Could not chdir to '%s'", worktree); cwd[len++] = '/'; cwd[len] = '\0'; free(gitfile); - return cwd + strlen(worktree) + 1; + return cwd + offset; } /* cwd outside worktree */ |