checkout: teach check_linked_checkout() about symbolic link HEAD
[gitweb.git] / builtin / checkout.c
index 6f4e49232adc5d89850d6211b7cdf3c926821e7a..f04dcaaf1f714504a37181658d70351b1110c002 100644 (file)
@@ -889,7 +889,11 @@ static void check_linked_checkout(const char *branch, const char *id)
        else
                strbuf_addf(&path, "%s/HEAD", get_git_common_dir());
 
-       if (strbuf_read_file(&sb, path.buf, 0) >= 0 &&
+       if (!strbuf_readlink(&sb, path.buf, 0)) {
+               if (!starts_with(sb.buf, "refs/") ||
+                   check_refname_format(sb.buf, 0))
+                       goto done;
+       } else if (strbuf_read_file(&sb, path.buf, 0) >= 0 &&
            starts_with(sb.buf, "ref:")) {
                strbuf_remove(&sb, 0, strlen("ref:"));
                strbuf_trim(&sb);