@@ -57,10 +57,10 @@ static int check_ref_format_branch(const char *arg)
int cmd_check_ref_format(int argc, const char **argv, const char *prefix)
{
enum {
+ CHECK_REFNAME_FORMAT = 0,
CHECK_REF_FORMAT_BRANCH,
- };
+ } mode = CHECK_REFNAME_FORMAT;
- int i = 0;
int verbose = 0;
int normalize = 0;
int flags = 0;
@@ -69,17 +69,19 @@ int cmd_check_ref_format(int argc, const char **argv, const char *prefix)
struct option options[] = {
OPT__VERBOSE(&verbose, N_("be verbose")),
OPT_GROUP(""),
- OPT_CMDMODE( 0 , "branch", &check_ref_format_branch, N_("branch"), CHECK_REF_FORMAT_BRANCH),
- OPT_BOOL( 0 , "normalize", &normalize, N_("normalize tracked files")),
- OPT_BIT( 0 , "allow-onelevel", &flags, N_("allow one level"), REFNAME_ALLOW_ONELEVEL),
- OPT_NEGBIT( 0, "no-allow-onelevel", &flags, N_("no allow one level"), REFNAME_ALLOW_ONELEVEL),
- OPT_BIT( 0 , "refspec-pattern", &flags, N_("refspec pattern"), REFNAME_REFSPEC_PATTERN),
+ OPT_CMDMODE(0 , "branch", &mode, N_("branch"), CHECK_REF_FORMAT_BRANCH),
+ OPT_BOOL(0 , "normalize", &normalize, N_("normalize tracked files")),
+ OPT_BIT(0 , "allow-onelevel", &flags, N_("allow one level"), REFNAME_ALLOW_ONELEVEL),
+ OPT_NEGBIT(0, "no-allow-onelevel", &flags, N_("no allow one level"), REFNAME_ALLOW_ONELEVEL),
+ OPT_BIT(0 , "refspec-pattern", &flags, N_("refspec pattern"), REFNAME_REFSPEC_PATTERN),
OPT_END(),
};
argc = parse_options(argc, argv, prefix, options, builtin_check_ref_format_usage, 0);
- refname = argv[i];
+ refname = argv[0];
+ if (mode)
+ return check_ref_format_branch(argv[2]);
if (normalize)
refname = collapse_slashes(refname);
if (check_refname_format(refname, flags))