Merge branch 'jk/reflog-date' into next
[git] / builtin-check-ref-format.c
1 /*
2  * GIT - The information manager from hell
3  */
4
5 #include "cache.h"
6 #include "refs.h"
7 #include "builtin.h"
8 #include "strbuf.h"
9
10 int cmd_check_ref_format(int argc, const char **argv, const char *prefix)
11 {
12         if (argc == 3 && !strcmp(argv[1], "--branch")) {
13                 struct strbuf sb = STRBUF_INIT;
14
15                 if (strbuf_check_branch_ref(&sb, argv[2]))
16                         die("'%s' is not a valid branch name", argv[2]);
17                 printf("%s\n", sb.buf + 11);
18                 exit(0);
19         }
20         if (argc != 2)
21                 usage("git check-ref-format refname");
22         return !!check_ref_format(argv[1]);
23 }