shithub: git9

Download patch

ref: 06d105857f26e65e3fec8ad35665e4c741573f99
parent: fba7aac18f3c040e6e5a4c025230eb4d32b6c243
author: Ori Bernstein <ori@eigenstate.org>
date: Tue Oct 22 01:51:15 EDT 2019

Force permissions on files/dirs in git/fs.

Sometimes we get blank permission bits in git, and we don't want that.
Upstream git only respects the executable bit, and otherwise forces the
permissions to 644 for files or 755 for directories.

We should do the same.


--- a/fs.c
+++ b/fs.c
@@ -251,6 +251,7 @@
 	d->qid.type = o->type == GTree ? QTDIR : 0;
 	d->qid.path = qpath(c, i, o->id, aux->qdir);
 	d->mode = e->tree->ent[i].mode;
+	d->mode |= (o->type == GTree) ? 0755 : 0644;
 	d->atime = c->mtime;
 	d->mtime = c->mtime;
 	d->uid = estrdup9p(username);
@@ -280,7 +281,7 @@
 
 	switch(i){
 	case 0:
-		d->mode = 0555 | DMDIR;
+		d->mode = 0755 | DMDIR;
 		d->name = estrdup9p("tree");
 		d->qid.type = QTDIR;
 		d->qid.path = qpath(c, i, o->id, Qcommittree);
@@ -432,6 +433,7 @@
 			q->type = (w->type == GTree) ? QTDIR : 0;
 			q->path = qpath(c, i, w->id, qdir);
 			c->mode = o->tree->ent[i].mode;
+			c->mode |= (q->type == QTDIR) ? 0755 : 0644;
 			c->obj = w;
 		}
 		if(!w)
@@ -454,7 +456,7 @@
 			q->path = qpath(p, 4, o->id, Qcommittree);
 			unref(c->obj);
 			c->obj = readobject(o->commit->tree);
-			c->mode = DMDIR | 0555;
+			c->mode = DMDIR | 0755;
 		}
 		else
 			e = Eexist;
@@ -579,7 +581,7 @@
 				return "invalid object name";
 			if((c->obj = readobject(h)) == nil)
 				return "could not read object";
-			c->mode = (c->obj->type == GBlob) ? 0444 : QTDIR | 0555;
+			c->mode = (c->obj->type == GBlob) ? 0644 : QTDIR | 0755;
 			q->path = qpath(o, Qobject, c->obj->id, Qobject);
 			q->type = (c->obj->type == GBlob) ? 0 : QTDIR;
 			q->vers = 0;