shithub: plan9front

Download patch

ref: 3909b83a90ff0c820ef7c903a03fc12b043ebfea
parent: 5a15acc7f0cbbcddf80e445cf1721cba6de31d4b
author: Ori Bernstein <ori@eigenstate.org>
date: Sat Aug 7 14:01:22 EDT 2021

git/save: leave submodules unmangled

When modifying a submodule, we would garble the
mode, leading to an apparently dangling object.

This fixes the issue.

--- a/sys/src/cmd/git/save.c	Fri Aug  6 06:05:23 2021
+++ b/sys/src/cmd/git/save.c	Sat Aug  7 14:01:22 2021
@@ -15,16 +15,18 @@
 };
 
 int
-gitmode(int m)
+gitmode(Dirent *e)
 {
-	if(m & DMDIR)		/* directory */
+	if(e->islink)
+		return 0120000;
+	else if(e->ismod)
+		return 0160000;
+	else if(e->mode & DMDIR)
 		return 0040000;
-	else if(m & 0111)	/* executable */
+	else if(e->mode & 0111)
 		return 0100755;
-	else if(m != 0)		/* regular */
+	else
 		return 0100644;
-	else			/* symlink */
-		return 0120000;
 }
 
 int
@@ -141,7 +143,7 @@
 	for(d = ent; d != ent + nent; d++){
 		if(strlen(d->name) >= 255)
 			sysfatal("overly long filename: %s", d->name);
-		t = seprint(t, etxt, "%o %s", gitmode(d->mode), d->name) + 1;
+		t = seprint(t, etxt, "%o %s", gitmode(d), d->name) + 1;
 		memcpy(t, d->h.h, sizeof(d->h.h));
 		t += sizeof(d->h.h);
 	}