3

I have a git repo that was converted from RCS via CVS many years ago. When I tried to push it to GitHub it was rejected because the initial two commits had bad dates:

$ git fsck
Checking object directories: 100% (256/256), done.
error in commit 38f10a1a015625149ea06f2f633e9ba446912b27: badDateOverflow: invalid author/committer line - date causes integer overflow
error in commit 0436a5befd4fee58693c2293e72be53b84705539: badDateOverflow: invalid author/committer line - date causes integer overflow

When I look at these commits, it is clear that the dates are bad (they are negative):

$ git cat-file -p 
tree 75e9d9b58efcc2b706e38967cff75935e656fdf1
parent 0436a5befd4fee58693c2293e72be53b84705539
author John Tang Boyland <boyland@uwm.edu> -59025288066 +0000
committer John Tang Boyland <boyland@uwm.edu> -59025288066 +0000

Updated for CS654 Spring 1999.

This seems like something git-filter-repo should be able to handle. I saw flags for fixing emails and names and commit messages but nothing for dates. I tried a run where I just pruned unreachable commits, and it left the bad dates in place. Then I tried to use git fast-export and edited the negative numbers with the correct unix time stamps. When I used git fast-import into an empty repository, I got plenty of stats but the empty repository stayed empty, probably because the commit structure was disrupted. I'm guessing the only way to fix this is to use the commit callback of git-filter-repo, but I'm not sure how to fix the dates.

I tried

$ git-filter-repo --commit-callback '
        if (commit.committer_date == -59025288066) :
          commit.committer_date = 932873934
'

and it ran fine, but it had no effect on the bad dates. I tried doing the same thing but double-quoted the dates (in case they were read as strings), again to no avail.

I saw an existing question on the same topic, but the answers don't say how to use git-filter-repo to fix dates: How can I fix "bad date" issues in a git repository?

1 Answers1

1

OK, after some experimentation, I found out how to use the hook. It's not sufficient to double quote the datestamp, it has to have the +0000 part too. And even that was not enough. I had to "b" quote the string. The solution was to run git-filter-repo with a hook such as

git-filter-repo --commit-callback '
        if (commit.committer_date == b"-59025288066 +0000") :
          commit.committer_date = b"932873934 +0000"
'

Of course, then I had to do the same thing with author_date and for the other commit too.