summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b296e8f)
raw | patch | inline | side by side (parent: b296e8f)
author | Jeff King <peff@peff.net> | |
Thu, 29 Jan 2009 08:30:16 +0000 (03:30 -0500) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Thu, 29 Jan 2009 09:00:43 +0000 (01:00 -0800) |
When we are trying to determine whether a directory contains
a git repository, one of the tests we do is to check whether
HEAD is either a symlink or a symref into the "refs/"
hierarchy, or a detached HEAD.
We can tighten this a little more, though: a non-detached
HEAD should always point to a branch (since checking out
anything else should result in detachment), so it is safe to
check for "refs/heads/".
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
a git repository, one of the tests we do is to check whether
HEAD is either a symlink or a symref into the "refs/"
hierarchy, or a detached HEAD.
We can tighten this a little more, though: a non-detached
HEAD should always point to a branch (since checking out
anything else should result in detachment), so it is safe to
check for "refs/heads/".
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
path.c | patch | blob | history |
index a074aea64921eb1fb90f079ede9087e6b8109f6a..108d9e9599d059a06fd0621188f45a716346ca07 100644 (file)
--- a/path.c
+++ b/path.c
/* Make sure it is a "refs/.." symlink */
if (S_ISLNK(st.st_mode)) {
len = readlink(path, buffer, sizeof(buffer)-1);
- if (len >= 5 && !memcmp("refs/", buffer, 5))
+ if (len >= 11 && !memcmp("refs/heads/", buffer, 11))
return 0;
return -1;
}
len -= 4;
while (len && isspace(*buf))
buf++, len--;
- if (len >= 5 && !memcmp("refs/", buf, 5))
+ if (len >= 11 && !memcmp("refs/heads/", buf, 11))
return 0;
}