ref: d358e3b2524686dc233ebe7d618398f157b8000b
parent: cb8df31ee09f75a8ec7d6fad01a78249309b757f
author: Ori Bernstein <ori@eigenstate.org>
date: Sat Feb 15 16:27:04 EST 2025
git/serve: accept the same ref formats as git/get
--- a/sys/src/cmd/git/serve.c
+++ b/sys/src/cmd/git/serve.c
@@ -179,10 +179,7 @@
cleanname(s);
if(strncmp(s, "refs/", 5) != 0)
return 0;
- for(; *s != '\0'; s++)
- if(!isalnum(*s) && strchr("/-_.", *s) == nil)
- return 0;
- return 1;
+ return okref(s);
}
int
@@ -328,6 +325,28 @@
}
int
+mkpath(char *path)
+{
+ char *p;
+
+ p = path;
+ /*
+ * we assume that the path has been
+ * checked with validref(), so there
+ * are no double '/' or odd characters.
+ */
+ while(1){
+ p = strchr(p, '/');
+ if(p == nil)
+ return 0;
+ *p = 0;
+ if(mkdir(path) == -1)
+ return -1;
+ *p++ = '/';
+ }
+}
+
+int
updatepack(Conn *c)
{
char buf[Pktmax], packtmp[128], idxtmp[128], ebuf[ERRMAX];
@@ -445,6 +464,10 @@
newidx = i;
}
unref(o);
+ if(mkpath(refpath) == -1){
+ snprint(buf, sizeof(buf), "create path: %r");
+ goto error;
+ }
if((fd = create(refpath, OWRITE|OTRUNC, 0644)) == -1){
snprint(buf, sizeof(buf), "open ref: %r");
goto error;
--
⑨