mirror of
https://github.com/git/git
synced 2024-10-06 08:39:27 +00:00
fsck: don't require an object struct in verify_headers()
We only need the oid and type to pass on to report(). Let's accept the broken-out parameters to give our callers more flexibility. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
7854399366
commit
cc579000bf
12
fsck.c
12
fsck.c
|
@ -687,7 +687,8 @@ static int fsck_tree(struct tree *item,
|
||||||
}
|
}
|
||||||
|
|
||||||
static int verify_headers(const void *data, unsigned long size,
|
static int verify_headers(const void *data, unsigned long size,
|
||||||
struct object *obj, struct fsck_options *options)
|
const struct object_id *oid, enum object_type type,
|
||||||
|
struct fsck_options *options)
|
||||||
{
|
{
|
||||||
const char *buffer = (const char *)data;
|
const char *buffer = (const char *)data;
|
||||||
unsigned long i;
|
unsigned long i;
|
||||||
|
@ -695,7 +696,7 @@ static int verify_headers(const void *data, unsigned long size,
|
||||||
for (i = 0; i < size; i++) {
|
for (i = 0; i < size; i++) {
|
||||||
switch (buffer[i]) {
|
switch (buffer[i]) {
|
||||||
case '\0':
|
case '\0':
|
||||||
return report(options, &obj->oid, obj->type,
|
return report(options, oid, type,
|
||||||
FSCK_MSG_NUL_IN_HEADER,
|
FSCK_MSG_NUL_IN_HEADER,
|
||||||
"unterminated header: NUL at offset %ld", i);
|
"unterminated header: NUL at offset %ld", i);
|
||||||
case '\n':
|
case '\n':
|
||||||
|
@ -713,7 +714,7 @@ static int verify_headers(const void *data, unsigned long size,
|
||||||
if (size && buffer[size - 1] == '\n')
|
if (size && buffer[size - 1] == '\n')
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return report(options, &obj->oid, obj->type,
|
return report(options, oid, type,
|
||||||
FSCK_MSG_UNTERMINATED_HEADER, "unterminated header");
|
FSCK_MSG_UNTERMINATED_HEADER, "unterminated header");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -772,7 +773,8 @@ static int fsck_commit(struct commit *commit, const char *buffer,
|
||||||
const char *buffer_begin = buffer;
|
const char *buffer_begin = buffer;
|
||||||
const char *p;
|
const char *p;
|
||||||
|
|
||||||
if (verify_headers(buffer, size, &commit->object, options))
|
if (verify_headers(buffer, size, &commit->object.oid,
|
||||||
|
commit->object.type, options))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (!skip_prefix(buffer, "tree ", &buffer))
|
if (!skip_prefix(buffer, "tree ", &buffer))
|
||||||
|
@ -827,7 +829,7 @@ static int fsck_tag(struct tag *tag, const char *buffer,
|
||||||
struct strbuf sb = STRBUF_INIT;
|
struct strbuf sb = STRBUF_INIT;
|
||||||
const char *p;
|
const char *p;
|
||||||
|
|
||||||
ret = verify_headers(buffer, size, &tag->object, options);
|
ret = verify_headers(buffer, size, &tag->object.oid, tag->object.type, options);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue