summaryrefslogtreecommitdiff
path: root/setup.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-05-02 22:58:30 (GMT)
committerJunio C Hamano <gitster@pobox.com>2011-05-02 22:58:30 (GMT)
commitc67e367c50304c5a0701ae2bb8ecb7291f481ffd (patch)
tree6c4015ddf403faec0ed182c39341cb42e670f878 /setup.c
parent2db8926236406a4e4cb17d1b9c4b791706fb0512 (diff)
parentb892913d51795ee66d825bedd23e5c4ffe85ebb2 (diff)
downloadgit-c67e367c50304c5a0701ae2bb8ecb7291f481ffd.zip
git-c67e367c50304c5a0701ae2bb8ecb7291f481ffd.tar.gz
git-c67e367c50304c5a0701ae2bb8ecb7291f481ffd.tar.bz2
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.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/setup.c b/setup.c
index 03cd84f..b6e6b5a 100644
--- a/setup.c
+++ b/setup.c
@@ -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 */