Code

prune-packed: only show progress when stderr is a tty
[git.git] / builtin-check-ref-format.c
1 /*
2  * GIT - The information manager from hell
3  */
5 #include "cache.h"
6 #include "refs.h"
7 #include "builtin.h"
8 #include "strbuf.h"
10 static const char builtin_check_ref_format_usage[] =
11 "git check-ref-format <refname>\n"
12 "   or: git check-ref-format --branch <branchname-shorthand>";
14 int cmd_check_ref_format(int argc, const char **argv, const char *prefix)
15 {
16         if (argc == 3 && !strcmp(argv[1], "--branch")) {
17                 struct strbuf sb = STRBUF_INIT;
19                 if (strbuf_check_branch_ref(&sb, argv[2]))
20                         die("'%s' is not a valid branch name", argv[2]);
21                 printf("%s\n", sb.buf + 11);
22                 exit(0);
23         }
24         if (argc != 2)
25                 usage(builtin_check_ref_format_usage);
26         return !!check_ref_format(argv[1]);
27 }