X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=setup.c;h=710e2f3008c79c08cdc507288881c9a58311283a;hb=1ee4b4ef70e26c540d028cc497313000e63cd7dc;hp=3a07aa4df710f5d9584d4ddf412e3debc0e64db4;hpb=5b9c0a699bdf9727d25eceb7b980dbede96bfd8e;p=git.git diff --git a/setup.c b/setup.c index 3a07aa4df..710e2f300 100644 --- a/setup.c +++ b/setup.c @@ -263,6 +263,8 @@ static int check_repository_format_gently(int *nongit_ok) const char *read_gitfile_gently(const char *path) { char *buf; + char *dir; + const char *slash; struct stat st; int fd; size_t len; @@ -287,9 +289,23 @@ const char *read_gitfile_gently(const char *path) if (len < 9) die("No path in gitfile: %s", path); buf[len] = '\0'; - if (!is_git_directory(buf + 8)) - die("Not a git repository: %s", buf + 8); - path = make_absolute_path(buf + 8); + dir = buf + 8; + + if (!is_absolute_path(dir) && (slash = strrchr(path, '/'))) { + size_t pathlen = slash+1 - path; + size_t dirlen = pathlen + len - 8; + dir = xmalloc(dirlen + 1); + strncpy(dir, path, pathlen); + strncpy(dir + pathlen, buf + 8, len - 8); + dir[dirlen] = '\0'; + free(buf); + buf = dir; + } + + if (!is_git_directory(dir)) + die("Not a git repository: %s", dir); + path = make_absolute_path(dir); + free(buf); return path; }