path: root/commit.c
diff options
authorEric Wong <>2009-07-03 04:34:54 (GMT)
committerJunio C Hamano <>2009-07-06 16:36:16 (GMT)
commitf290974390c9be76e9166df6f0ab5ad790b812ac (patch)
tree4e6856e53e2eefd3e1fa1736377db59d48c66cdd /commit.c
parentc8400d9ef57dc68925d93d0cb9f1777396b380e2 (diff)
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 <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'commit.c')
1 files changed, 1 insertions, 5 deletions
diff --git a/commit.c b/commit.c
index aa3b35b..a47fb4d 100644
--- a/commit.c
+++ b/commit.c
@@ -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)
@@ -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;