Skip to content

Commit bde6a72

Browse files
committed
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
2 parents c185936 + 84d18c0 commit bde6a72

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

fsck.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,8 @@ static int fsck_tree(struct tree *item, int strict, fsck_error error_func)
241241
return retval;
242242
}
243243

244-
static int require_end_of_header(const void *data, unsigned long size,
245-
struct object *obj, fsck_error error_func)
244+
static int verify_headers(const void *data, unsigned long size,
245+
struct object *obj, fsck_error error_func)
246246
{
247247
const char *buffer = (const char *)data;
248248
unsigned long i;
@@ -258,6 +258,15 @@ static int require_end_of_header(const void *data, unsigned long size,
258258
}
259259
}
260260

261+
/*
262+
* We did not find double-LF that separates the header
263+
* and the body. Not having a body is not a crime but
264+
* we do want to see the terminating LF for the last header
265+
* line.
266+
*/
267+
if (size && buffer[size - 1] == '\n')
268+
return 0;
269+
261270
return error_func(obj, FSCK_ERROR, "unterminated header");
262271
}
263272

@@ -308,7 +317,7 @@ static int fsck_commit_buffer(struct commit *commit, const char *buffer,
308317
unsigned parent_count, parent_line_count = 0;
309318
int err;
310319

311-
if (require_end_of_header(buffer, size, &commit->object, error_func))
320+
if (verify_headers(buffer, size, &commit->object, error_func))
312321
return -1;
313322

314323
if (!skip_prefix(buffer, "tree ", &buffer))
@@ -387,7 +396,7 @@ static int fsck_tag_buffer(struct tag *tag, const char *data,
387396
}
388397
}
389398

390-
if (require_end_of_header(buffer, size, &tag->object, error_func))
399+
if (verify_headers(buffer, size, &tag->object, error_func))
391400
goto done;
392401

393402
if (!skip_prefix(buffer, "object ", &buffer)) {

0 commit comments

Comments
 (0)