shithub: front

Download patch

ref: 1ab775887383bd20730254ef67b8d6c9dd9968a8
parent: 20780e694e13d767f637e1e27961b00d5cbe2607
author: Ori Bernstein <ori@eigenstate.org>
date: Wed Jul 16 21:47:56 EDT 2025

git: allow unicode in branch names

while the git spec does not talk about unicode in branch
names at all, it seems to allow any byte above 0x80; we
are going to be a bit stricter.

--- a/sys/src/cmd/git/util.c
+++ b/sys/src/cmd/git/util.c
@@ -524,14 +524,16 @@
 int
 okref(char *ref)
 {
-	int slashed;
+	int n, slashed;
 	char *p;
+	Rune r;
 
 	slashed = 0;
 	if(*ref == '/' || *ref == '.')
 		return 0;
-	for(p = ref; *p != 0; p++) {
-		switch(*p){
+	for(p = ref; *p != 0; p += n) {
+		n = chartorune(&r, p);
+		switch(r){
 		case '.':
 			if(p[1]== 0 || p[1] == '.')
 				return 0;
@@ -555,10 +557,11 @@
 		case '*':
 		case '[':
 		case '\\':
+		case Runeerror:
 		case 0x7f: /* DEL */
 			return 0;
 		default:
-			if(*p < 0x20)
+			if(r < 0x20 || isspacerune(r))
 				return 0;
 		}
 	}
--