builtin-check-ref-format.con commit merge: do not setup worktree twice (d629c40)
   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
  10static const char builtin_check_ref_format_usage[] =
  11"git check-ref-format [--print] <refname>\n"
  12"   or: git check-ref-format --branch <branchname-shorthand>";
  13
  14int 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;
  18
  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}