summaryrefslogtreecommitdiff
path: root/fsck.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2019-10-18 05:00:04 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-10-28 05:05:18 (GMT)
commit7854399366fa36854de8e6962a441b02009c10e4 (patch)
tree931a717880c9677331001208ada8ae7b6c8ee161 /fsck.c
parentb8b00f1693c149ba03e34d56d8804256e74f6eab (diff)
downloadgit-7854399366fa36854de8e6962a441b02009c10e4.zip
git-7854399366fa36854de8e6962a441b02009c10e4.tar.gz
git-7854399366fa36854de8e6962a441b02009c10e4.tar.bz2
fsck: don't require an object struct for fsck_ident()
The only thing we do with the struct is pass its oid and type to report(). We can just take those explicitly, which gives our callers more flexibility. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'fsck.c')
-rw-r--r--fsck.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/fsck.c b/fsck.c
index 4ff0ceb..e1d06fb 100644
--- a/fsck.c
+++ b/fsck.c
@@ -717,7 +717,9 @@ static int verify_headers(const void *data, unsigned long size,
FSCK_MSG_UNTERMINATED_HEADER, "unterminated header");
}
-static int fsck_ident(const char **ident, struct object *obj, struct fsck_options *options)
+static int fsck_ident(const char **ident,
+ const struct object_id *oid, enum object_type type,
+ struct fsck_options *options)
{
const char *p = *ident;
char *end;
@@ -727,28 +729,28 @@ static int fsck_ident(const char **ident, struct object *obj, struct fsck_option
(*ident)++;
if (*p == '<')
- return report(options, &obj->oid, obj->type, FSCK_MSG_MISSING_NAME_BEFORE_EMAIL, "invalid author/committer line - missing space before email");
+ return report(options, oid, type, FSCK_MSG_MISSING_NAME_BEFORE_EMAIL, "invalid author/committer line - missing space before email");
p += strcspn(p, "<>\n");
if (*p == '>')
- return report(options, &obj->oid, obj->type, FSCK_MSG_BAD_NAME, "invalid author/committer line - bad name");
+ return report(options, oid, type, FSCK_MSG_BAD_NAME, "invalid author/committer line - bad name");
if (*p != '<')
- return report(options, &obj->oid, obj->type, FSCK_MSG_MISSING_EMAIL, "invalid author/committer line - missing email");
+ return report(options, oid, type, FSCK_MSG_MISSING_EMAIL, "invalid author/committer line - missing email");
if (p[-1] != ' ')
- return report(options, &obj->oid, obj->type, FSCK_MSG_MISSING_SPACE_BEFORE_EMAIL, "invalid author/committer line - missing space before email");
+ return report(options, oid, type, FSCK_MSG_MISSING_SPACE_BEFORE_EMAIL, "invalid author/committer line - missing space before email");
p++;
p += strcspn(p, "<>\n");
if (*p != '>')
- return report(options, &obj->oid, obj->type, FSCK_MSG_BAD_EMAIL, "invalid author/committer line - bad email");
+ return report(options, oid, type, FSCK_MSG_BAD_EMAIL, "invalid author/committer line - bad email");
p++;
if (*p != ' ')
- return report(options, &obj->oid, obj->type, FSCK_MSG_MISSING_SPACE_BEFORE_DATE, "invalid author/committer line - missing space before date");
+ return report(options, oid, type, FSCK_MSG_MISSING_SPACE_BEFORE_DATE, "invalid author/committer line - missing space before date");
p++;
if (*p == '0' && p[1] != ' ')
- return report(options, &obj->oid, obj->type, FSCK_MSG_ZERO_PADDED_DATE, "invalid author/committer line - zero-padded date");
+ return report(options, oid, type, FSCK_MSG_ZERO_PADDED_DATE, "invalid author/committer line - zero-padded date");
if (date_overflows(parse_timestamp(p, &end, 10)))
- return report(options, &obj->oid, obj->type, FSCK_MSG_BAD_DATE_OVERFLOW, "invalid author/committer line - date causes integer overflow");
+ return report(options, oid, type, FSCK_MSG_BAD_DATE_OVERFLOW, "invalid author/committer line - date causes integer overflow");
if ((end == p || *end != ' '))
- return report(options, &obj->oid, obj->type, FSCK_MSG_BAD_DATE, "invalid author/committer line - bad date");
+ return report(options, oid, type, FSCK_MSG_BAD_DATE, "invalid author/committer line - bad date");
p = end + 1;
if ((*p != '+' && *p != '-') ||
!isdigit(p[1]) ||
@@ -756,7 +758,7 @@ static int fsck_ident(const char **ident, struct object *obj, struct fsck_option
!isdigit(p[3]) ||
!isdigit(p[4]) ||
(p[5] != '\n'))
- return report(options, &obj->oid, obj->type, FSCK_MSG_BAD_TIMEZONE, "invalid author/committer line - bad time zone");
+ return report(options, oid, type, FSCK_MSG_BAD_TIMEZONE, "invalid author/committer line - bad time zone");
p += 6;
return 0;
}
@@ -792,7 +794,7 @@ static int fsck_commit(struct commit *commit, const char *buffer,
author_count = 0;
while (skip_prefix(buffer, "author ", &buffer)) {
author_count++;
- err = fsck_ident(&buffer, &commit->object, options);
+ err = fsck_ident(&buffer, &commit->object.oid, commit->object.type, options);
if (err)
return err;
}
@@ -804,7 +806,7 @@ static int fsck_commit(struct commit *commit, const char *buffer,
return err;
if (!skip_prefix(buffer, "committer ", &buffer))
return report(options, &commit->object.oid, commit->object.type, FSCK_MSG_MISSING_COMMITTER, "invalid format - expected 'committer' line");
- err = fsck_ident(&buffer, &commit->object, options);
+ err = fsck_ident(&buffer, &commit->object.oid, commit->object.type, options);
if (err)
return err;
if (memchr(buffer_begin, '\0', size)) {
@@ -882,7 +884,7 @@ static int fsck_tag(struct tag *tag, const char *buffer,
goto done;
}
else
- ret = fsck_ident(&buffer, &tag->object, options);
+ ret = fsck_ident(&buffer, &tag->object.oid, tag->object.type, options);
done:
strbuf_release(&sb);