Thread (4 messages) flat view 4 messages, 2 authors, 2016-06-15

Re: [PATCH] check-ref-format --print: Normalize refnames that start with slashes

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:51:55

Michael Haggerty [off-list ref] writes:
And add tests that such refnames are accepted and normalized
correctly.
Thanks. I think this is a bit simpler, though...

 builtin/check-ref-format.c  |    4 +---
 t/t1402-check-ref-format.sh |    1 -
 2 files changed, 1 insertions(+), 4 deletions(-)
diff --git b/builtin/check-ref-format.c a/builtin/check-ref-format.c
index 7118021..0723cf2 100644
--- b/builtin/check-ref-format.c
+++ a/builtin/check-ref-format.c
@@ -21,10 +21,8 @@ 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 (*src == '/')
-		src++;
 	while ((ch = *src++) != '\0') {
 		if (prev == '/' && ch == prev)
 			continue;
diff --git b/t/t1402-check-ref-format.sh a/t/t1402-check-ref-format.sh
index e6fafb2..7563043 100755
--- b/t/t1402-check-ref-format.sh
+++ a/t/t1402-check-ref-format.sh
@@ -31,7 +31,6 @@ valid_ref 'heads/foo@bar'
 invalid_ref 'heads/v@{ation'
 invalid_ref 'heads/foo\bar'
 
-
 test_expect_success "check-ref-format --branch @{-1}" '
 	T=$(git write-tree) &&
 	sha1=$(echo A | git commit-tree $T) &&
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help