X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=update-ref.c;fp=update-ref.c;h=6919cead4beb2a8aae42c9fbac01e1093477b26d;hb=9b143c6e155a8eead165b2a813b533e0f3e0018a;hp=1863b823240790c450e29c1c82041972713d716b;hpb=ed1aadf1b0cb4afc7cb0aaf4cec4f5ad84e3307d;p=git.git diff --git a/update-ref.c b/update-ref.c index 1863b823..6919cead 100644 --- a/update-ref.c +++ b/update-ref.c @@ -13,6 +13,7 @@ static const char *resolve_ref(const char *path, unsigned char *sha1) for (;;) { struct stat st; + char *buf; int fd; if (--depth < 0) @@ -44,7 +45,19 @@ static const char *resolve_ref(const char *path, unsigned char *sha1) return NULL; len = read(fd, buffer, sizeof(buffer)-1); close(fd); - break; + + /* + * Is it a symbolic ref? + */ + if (len < 4 || memcmp("ref:", buffer, 4)) + break; + buf = buffer + 4; + len -= 4; + while (len && isspace(*buf)) + buf++, len--; + while (len && isspace(buf[len-1])) + buf[--len] = 0; + path = git_path("%.*s", len, buf); } if (len < 40 || get_sha1_hex(buffer, sha1)) return NULL;