Skip to content

Commit

Permalink
git-fsck: report missing author/commit line in a commit as an error
Browse files Browse the repository at this point in the history
A zero commit date could be caused by:
* a missing author line
* a missing commiter line
* a malformed email address in the commiter line
* a malformed commit date

Simply reporting it as zero commit date is missleading.

Additionally, it upgrades the message to an error (instead of an printf).

Signed-off-by: Martin Koegler <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
Martin Koegler authored and gitster committed Feb 4, 2008
1 parent 3023448 commit d4fe07f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions builtin-fsck.c
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,9 @@ static int fsck_commit(struct commit *commit)
fprintf(stderr, "Checking commit %s\n",
sha1_to_hex(commit->object.sha1));

if (!commit->date)
return objerror(&commit->object, "invalid author/committer line");

if (memcmp(buffer, "tree ", 5))
return objerror(&commit->object, "invalid format - expected 'tree' line");
if (get_sha1_hex(buffer+5, tree_sha1) || buffer[45] != '\n')
Expand All @@ -378,9 +381,6 @@ static int fsck_commit(struct commit *commit)
return objerror(&commit->object, "could not load commit's tree %s", tree_sha1);
if (!commit->parents && show_root)
printf("root %s\n", sha1_to_hex(commit->object.sha1));
if (!commit->date)
printf("bad commit date in %s\n",
sha1_to_hex(commit->object.sha1));
return 0;
}

Expand Down

0 comments on commit d4fe07f

Please sign in to comment.