@ -222,12 +222,47 @@ static int fsck_tree(struct tree *item, int strict, fsck_error error_func)
@@ -222,12 +222,47 @@ static int fsck_tree(struct tree *item, int strict, fsck_error error_func)
return retval;
}
static int fsck_ident(char **ident, struct object *obj, fsck_error error_func)
{
if (**ident == '<' || **ident == '\n')
return error_func(obj, FSCK_ERROR, "invalid author/committer line - missing space before email");
*ident += strcspn(*ident, "<\n");
if ((*ident)[-1] != ' ')
return error_func(obj, FSCK_ERROR, "invalid author/committer line - missing space before email");
if (**ident != '<')
return error_func(obj, FSCK_ERROR, "invalid author/committer line - missing email");
(*ident)++;
*ident += strcspn(*ident, "<>\n");
if (**ident != '>')
return error_func(obj, FSCK_ERROR, "invalid author/committer line - bad email");
(*ident)++;
if (**ident != ' ')
return error_func(obj, FSCK_ERROR, "invalid author/committer line - missing space before date");
(*ident)++;
if (**ident == '0' && (*ident)[1] != ' ')
return error_func(obj, FSCK_ERROR, "invalid author/committer line - zero-padded date");
*ident += strspn(*ident, "0123456789");
if (**ident != ' ')
return error_func(obj, FSCK_ERROR, "invalid author/committer line - bad date");
(*ident)++;
if ((**ident != '+' && **ident != '-') ||
!isdigit((*ident)[1]) ||
!isdigit((*ident)[2]) ||
!isdigit((*ident)[3]) ||
!isdigit((*ident)[4]) ||
((*ident)[5] != '\n'))
return error_func(obj, FSCK_ERROR, "invalid author/committer line - bad time zone");
(*ident) += 6;
return 0;
}
static int fsck_commit(struct commit *commit, fsck_error error_func)