2 * GIT - The information manager from hell
11 * Replace each run of adjacent slashes in src with a single slash,
12 * and write the result to dst.
14 * This function is similar to normalize_path_copy(), but stripped down
15 * to meet check_ref_format's simpler needs.
17 static void collapse_slashes(char *dst, const char *src)
22 while ((ch = *src++) != '\0') {
23 if (prev == '/' && ch == prev)
32 int cmd_check_ref_format(int argc, const char **argv, const char *prefix)
34 if (argc == 3 && !strcmp(argv[1], "--branch")) {
35 struct strbuf sb = STRBUF_INIT;
37 if (strbuf_check_branch_ref(&sb, argv[2]))
38 die("'%s' is not a valid branch name", argv[2]);
39 printf("%s\n", sb.buf + 11);
42 if (argc == 3 && !strcmp(argv[1], "--print")) {
43 char *refname = xmalloc(strlen(argv[2]) + 1);
45 if (check_ref_format(argv[2]))
47 collapse_slashes(refname, argv[2]);
48 printf("%s\n", refname);
52 usage("git check-ref-format refname");
53 return !!check_ref_format(argv[1]);