@matheusbsbs / matheus-bagliano / commits / f290974390
Fork 0

Allow the Unix epoch to be a valid commit date

It is common practice to use the Unix epoch as a fallback date when a suitable date is not available. This is true of git svn and possibly other importing tools that import non-git history into git. Instead of clobbering established strtoul() error reporting semantics with our own, preserve the strtoul() error value of ULONG_MAX for fsck.c to handle. Signed-off-by: Eric Wong <normalperson@yhbt.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Eric Wong committed Jul 2, 2009 at 21:34 UTC f290974390c9be76e9166df6f0ab5ad790b812ac
2 files changed +2 -6
commit.c
+1 -5
@@ -50,7 +50,6 @@ struct commit *lookup_commit(const unsigned char *sha1)
50
51 static unsigned long parse_commit_date(const char *buf, const char *tail)
52 {
53 - unsigned long date;
53 const char *dateptr;
54
55 if (buf + 6 >= tail)
@@ -73,10 +72,7 @@ static unsigned long parse_commit_date(const char *buf, const char *tail)
72 if (buf >= tail)
73 return 0;
74 /* dateptr < buf && buf[-1] == '\n', so strtoul will stop at buf-1 */
76 - date = strtoul(dateptr, NULL, 10);
77 - if (date == ULONG_MAX)
78 - date = 0;
79 - return date;
75 + return strtoul(dateptr, NULL, 10);
76 }
77
78 static struct commit_graft **commit_graft;
fsck.c
+1 -1
@@ -229,7 +229,7 @@ static int fsck_commit(struct commit *commit, fsck_error error_func)
229 struct commit_graft *graft;
230 int parents = 0;
231
232 - if (!commit->date)
232 + if (commit->date == ULONG_MAX)
233 return error_func(&commit->object, FSCK_ERROR, "invalid author/committer line");
234
235 if (memcmp(buffer, "tree ", 5))