From: Junio C Hamano Date: Mon, 27 Jul 2015 19:21:45 +0000 (-0700) Subject: Merge branch 'jc/fsck-retire-require-eoh' into maint X-Git-Tag: v2.4.7~5 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/bde6a72af5b5dc9f1e489c8103ea900e266ab766?ds=inline;hp=-c Merge branch 'jc/fsck-retire-require-eoh' into maint 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 --- bde6a72af5b5dc9f1e489c8103ea900e266ab766 diff --combined fsck.c index 10bcb65151,3f264e7a41..24b2a5f36c --- a/fsck.c +++ b/fsck.c @@@ -7,7 -7,6 +7,7 @@@ #include "tag.h" #include "fsck.h" #include "refs.h" +#include "utf8.h" static int fsck_walk_tree(struct tree *tree, fsck_walk_func walk, void *data) { @@@ -172,9 -171,7 +172,9 @@@ static int fsck_tree(struct tree *item has_empty_name |= !*name; has_dot |= !strcmp(name, "."); has_dotdot |= !strcmp(name, ".."); - has_dotgit |= !strcmp(name, ".git"); + has_dotgit |= (!strcmp(name, ".git") || + is_hfs_dotgit(name) || + is_ntfs_dotgit(name)); has_zero_pad |= *(char *)desc.buffer == '0'; update_tree_entry(&desc); @@@ -241,8 -238,8 +241,8 @@@ 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 -255,15 +258,15 @@@ } } + /* + * 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 -314,7 +317,7 @@@ static int fsck_commit_buffer(struct co 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 -393,7 +396,7 @@@ static int fsck_tag_buffer(struct tag * } } - 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)) {