summaryrefslogtreecommitdiff
path: root/fsck.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2015-07-13 14:00:23 -0700
committerJunio C Hamano <gitster@pobox.com>2015-07-13 14:00:24 -0700
commitacf718951299fcd6017a096e62e8baf2335ed415 (patch)
treedebe7896846e61b5a8b5901a912431ce97e7db70 /fsck.c
parente59f6c2d348d465e3147b11098126d3965686098 (diff)
parent84d18c0bcfa17927240cc0322023d91d3797d0f3 (diff)
downloadgit-acf718951299fcd6017a096e62e8baf2335ed415.tar.gz
Merge branch 'jc/fsck-retire-require-eoh'
A fix to a minor regression to "git fsck" in v2.2 era that started complaining about a body-less tag object when it lacks a separator empty line after its header to separate it with a non-existent body. * jc/fsck-retire-require-eoh: fsck: it is OK for a tag and a commit to lack the body
Diffstat (limited to 'fsck.c')
-rw-r--r--fsck.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/fsck.c b/fsck.c
index 10bcb65151..24b2a5f36c 100644
--- a/fsck.c
+++ b/fsck.c
@@ -241,8 +241,8 @@ static int fsck_tree(struct tree *item, int strict, fsck_error error_func)
return retval;
}
-static int require_end_of_header(const void *data, unsigned long size,
- struct object *obj, fsck_error error_func)
+static int verify_headers(const void *data, unsigned long size,
+ struct object *obj, fsck_error error_func)
{
const char *buffer = (const char *)data;
unsigned long i;
@@ -258,6 +258,15 @@ static int require_end_of_header(const void *data, unsigned long size,
}
}
+ /*
+ * We did not find double-LF that separates the header
+ * and the body. Not having a body is not a crime but
+ * we do want to see the terminating LF for the last header
+ * line.
+ */
+ if (size && buffer[size - 1] == '\n')
+ return 0;
+
return error_func(obj, FSCK_ERROR, "unterminated header");
}
@@ -308,7 +317,7 @@ static int fsck_commit_buffer(struct commit *commit, const char *buffer,
unsigned parent_count, parent_line_count = 0;
int err;
- if (require_end_of_header(buffer, size, &commit->object, error_func))
+ if (verify_headers(buffer, size, &commit->object, error_func))
return -1;
if (!skip_prefix(buffer, "tree ", &buffer))
@@ -387,7 +396,7 @@ static int fsck_tag_buffer(struct tag *tag, const char *data,
}
}
- if (require_end_of_header(buffer, size, &tag->object, error_func))
+ if (verify_headers(buffer, size, &tag->object, error_func))
goto done;
if (!skip_prefix(buffer, "object ", &buffer)) {