@matheusbsbs / matheus-bagliano / commits / d4fe07f149
Fork 0

git-fsck: report missing author/commit line in a commit as an error

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 <mkoegler@auto.tuwien.ac.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Martin Koegler committed Feb 3, 2008 at 22:22 UTC d4fe07f14975b87fa26776792a95f411473cfb46
1 file changed +3 -3
builtin-fsck.c
+3 -3
@@ -360,6 +360,9 @@ static int fsck_commit(struct commit *commit)
360 fprintf(stderr, "Checking commit %s\n",
361 sha1_to_hex(commit->object.sha1));
362
363 + if (!commit->date)
364 + return objerror(&commit->object, "invalid author/committer line");
365 +
366 if (memcmp(buffer, "tree ", 5))
367 return objerror(&commit->object, "invalid format - expected 'tree' line");
368 if (get_sha1_hex(buffer+5, tree_sha1) || buffer[45] != '\n')
@@ -378,9 +381,6 @@ static int fsck_commit(struct commit *commit)
381 return objerror(&commit->object, "could not load commit's tree %s", tree_sha1);
382 if (!commit->parents && show_root)
383 printf("root %s\n", sha1_to_hex(commit->object.sha1));
381 - if (!commit->date)
382 - printf("bad commit date in %s\n",
383 - sha1_to_hex(commit->object.sha1));
384 return 0;
385 }
386