"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Stefan Sperling <stsp@stsp.name>
Subject:
Re: Incompatible git repository
To:
Christian Weisgerber <naddy@mips.inka.de>
Cc:
gameoftrees@openbsd.org
Date:
Tue, 2 Feb 2021 23:21:30 +0100

Download raw body.

Thread
On Tue, Feb 02, 2021 at 10:37:18PM +0100, Christian Weisgerber wrote:
> Got does not like this repository:
>     git://github.com/steveicarus/iverilog.git
> 
> I can clone it, but got/tog log complains "bad object data".

There are tag objects in there which lack a time stamp in tagger info:

$ git cat-file tag eca7aeee 
object 5d00f174481f2a5e3b6779eed586f128cdcabeee
type commit
tag s19990431
tagger steve <steve>
$ 

I've never seen this before. Usually, tags look like this:

$ git cat-file tag 0.1
object 661640238bb42e60d862211cd0c0ac4576558656
type commit
tag 0.1
tagger Stefan Sperling <stsp@stsp.name> 1565341427 +0200

got-0.1
$ 

I assume these weird tags were created with very old versions of Git.
This patch allows parsing of such tags. They will show up in 'got tag -l'
with a timestamp of 1 Jan 1970. I don't want to second-guess the date.

ok?

diff df3ed485f4148d31d1b555abb99fcba42c1a49b7 /home/stsp/src/got
blob - 241ea3c3ccac1133d50d95329813ab14c3d00f3d
file + lib/object_parse.c
--- lib/object_parse.c
+++ lib/object_parse.c
@@ -338,8 +338,14 @@ parse_commit_time(time_t *time, time_t *gmtoff, char *
 		return got_error_from_errno("strdup");
 	err = parse_gmtoff(gmtoff, tzstr);
 	free(tzstr);
-	if (err)
-		return err;
+	if (err) { 
+		if (err->code != GOT_ERR_BAD_OBJ_DATA)
+			return err;
+		/* Old versions of Git omitted the timestamp. */
+		*time = 0;
+		*gmtoff = 0;
+		return NULL;
+	}
 	*space = '\0';
 
 	/* Timestamp is separated from committer name + email by space. */