code: plan9front

Download patch

ref: 6b6b9a236d773c704daaf7f7b5b090111e28ac87
parent: f70cf0b70eb2b9b6cdf7208bf775189c724eb446
author: Noam Preil <noam@pixelhero.dev>
date: Tue Nov 21 06:30:52 EST 2023

git: utilize time zone info when present and ignore it when it's not

This fixes a bug which prevents us from modifying some
real-world repositories (test case: KnightOS), and utilizes
time zone information when it's present to improve our timestamps.

--- a/sys/src/cmd/git/pack.c
+++ b/sys/src/cmd/git/pack.c
@@ -825,6 +825,7 @@
 {
 	char buf[128];
 	Resub m[4];
+	vlong tz;
 	char *p;
 	int n, nm;
 
@@ -845,10 +846,16 @@
 	memcpy(*name, m[1].sp, nm);
 	buf[nm] = 0;
 	
+	nm = m[3].ep - m[3].sp;
+	memcpy(buf, m[3].sp, nm);
+	buf[nm] = 0;
+	tz = atoll(buf);
+
 	nm = m[2].ep - m[2].sp;
 	memcpy(buf, m[2].sp, nm);
 	buf[nm] = 0;
-	*time = atoll(buf);
+	*time = atoll(buf) + 3600*(tz/100) + 60*(tz%100);
+
 	return 0;
 }
 
--- a/sys/src/cmd/git/util.c
+++ b/sys/src/cmd/git/util.c
@@ -207,7 +207,7 @@
 	fmtinstall('Q', Qfmt);
 	inflateinit();
 	deflateinit();
-	authorpat = regcomp("[\t ]*(.*)[\t ]+([0-9]+)[\t ]+([\\-+]?[0-9]+)");
+	authorpat = regcomp("[\t ]*(.*)[\t ]+([0-9]+)[\t ]*([\\-+]?[0-9]+)?");
 	osinit(&objcache);
 }