]> git.ipfire.org Git - thirdparty/git.git/blame - builtin-check-ref-format.c
Merge branch 'mm/maint-hint-failed-merge' into maint
[thirdparty/git.git] / builtin-check-ref-format.c
CommitLineData
9370bae2
LS
1/*
2 * GIT - The information manager from hell
3 */
4
5#include "cache.h"
6#include "refs.h"
7#include "builtin.h"
a31dca03 8#include "strbuf.h"
9370bae2 9
6586b1f3 10static const char builtin_check_ref_format_usage[] =
9deec58a 11"git check-ref-format <refname>\n"
6586b1f3
JN
12" or: git check-ref-format --branch <branchname-shorthand>";
13
a633fca0 14int cmd_check_ref_format(int argc, const char **argv, const char *prefix)
9370bae2 15{
a31dca03
JH
16 if (argc == 3 && !strcmp(argv[1], "--branch")) {
17 struct strbuf sb = STRBUF_INIT;
a2fab531
JH
18
19 if (strbuf_check_branch_ref(&sb, argv[2]))
a31dca03
JH
20 die("'%s' is not a valid branch name", argv[2]);
21 printf("%s\n", sb.buf + 11);
22 exit(0);
23 }
9370bae2 24 if (argc != 2)
6586b1f3 25 usage(builtin_check_ref_format_usage);
9370bae2
LS
26 return !!check_ref_format(argv[1]);
27}