blame: default to HEAD in a bare repo when no start commit is given
[gitweb.git] / builtin / check-ref-format.c
index 6c40ff110bee7387d4eb4e9c7c04a21e8b12ca44..bc67d3f0a83d35b2fc6d81f28c6908075564644a 100644 (file)
@@ -39,12 +39,14 @@ static char *collapse_slashes(const char *refname)
 static int check_ref_format_branch(const char *arg)
 {
        struct strbuf sb = STRBUF_INIT;
+       const char *name;
        int nongit;
 
        setup_git_directory_gently(&nongit);
-       if (strbuf_check_branch_ref(&sb, arg))
+       if (strbuf_check_branch_ref(&sb, arg) ||
+           !skip_prefix(sb.buf, "refs/heads/", &name))
                die("'%s' is not a valid branch name", arg);
-       printf("%s\n", sb.buf + 11);
+       printf("%s\n", name);
        strbuf_release(&sb);
        return 0;
 }