Skip to content

Commit

Permalink
Allow the Unix epoch to be a valid commit date
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Eric Wong authored and Junio C Hamano committed Jul 6, 2009
1 parent c8400d9 commit f290974
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
6 changes: 1 addition & 5 deletions commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ struct commit *lookup_commit(const unsigned char *sha1)

static unsigned long parse_commit_date(const char *buf, const char *tail)
{
unsigned long date;
const char *dateptr;

if (buf + 6 >= tail)
Expand All @@ -73,10 +72,7 @@ static unsigned long parse_commit_date(const char *buf, const char *tail)
if (buf >= tail)
return 0;
/* dateptr < buf && buf[-1] == '\n', so strtoul will stop at buf-1 */
date = strtoul(dateptr, NULL, 10);
if (date == ULONG_MAX)
date = 0;
return date;
return strtoul(dateptr, NULL, 10);
}

static struct commit_graft **commit_graft;
Expand Down
2 changes: 1 addition & 1 deletion fsck.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ static int fsck_commit(struct commit *commit, fsck_error error_func)
struct commit_graft *graft;
int parents = 0;

if (!commit->date)
if (commit->date == ULONG_MAX)
return error_func(&commit->object, FSCK_ERROR, "invalid author/committer line");

if (memcmp(buffer, "tree ", 5))
Expand Down

0 comments on commit f290974

Please sign in to comment.