diff options
author | Junio C Hamano <gitster@pobox.com> | 2010-01-20 14:38:34 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2010-01-20 14:38:34 -0800 |
commit | bd0d1916de221425fc22b69940ff71b0ce6aad9c (patch) | |
tree | de5b8e222e87202fc4c7159cb284a165f101939f /setup.c | |
parent | c757c52f63cfaa9446f9ae93e44acc6ca610650f (diff) | |
parent | 40c813e00c8de5725c7a6bb127fadedcce1f788f (diff) | |
download | git-bd0d1916de221425fc22b69940ff71b0ce6aad9c.tar.gz |
Merge branch 'bk/fix-relative-gitdir-file'
* bk/fix-relative-gitdir-file:
Handle relative paths in submodule .git files
Test update-index for a gitlink to a .git file
Diffstat (limited to 'setup.c')
-rw-r--r-- | setup.c | 22 |
1 files changed, 19 insertions, 3 deletions
@@ -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; } |