Code

check-ref-format --print: Normalize refnames that start with slashes
[git.git] / builtin / check-ref-format.c
index ae3f28115a7a4d65d8bb6f284cd1ececa4f9c2ef..0723cf245e52e6c0ab99cbe92c74010f9f7d7167 100644 (file)
@@ -12,8 +12,8 @@ static const char builtin_check_ref_format_usage[] =
 "   or: git check-ref-format --branch <branchname-shorthand>";
 
 /*
- * Replace each run of adjacent slashes in src with a single slash,
- * and write the result to dst.
+ * Remove leading slashes and replace each run of adjacent slashes in
+ * src with a single slash, and write the result to dst.
  *
  * This function is similar to normalize_path_copy(), but stripped down
  * to meet check_ref_format's simpler needs.
@@ -21,7 +21,7 @@ static const char builtin_check_ref_format_usage[] =
 static void collapse_slashes(char *dst, const char *src)
 {
        char ch;
-       char prev = '\0';
+       char prev = '/';
 
        while ((ch = *src++) != '\0') {
                if (prev == '/' && ch == prev)