git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] git-fsck: report missing author/commit line in a commit as an error
@ 2008-01-20 18:59 Martin Koegler
  2008-01-20 19:20 ` Johannes Schindelin
  0 siblings, 1 reply; 3+ messages in thread
From: Martin Koegler @ 2008-01-20 18:59 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Martin Koegler

Report a commit date (returned by parse_commit), if it is zero
as an error (instead by a printf).

A zero date means missing author/commiter line or a totally
corrupted commiter line.

Signed-off-by: Martin Koegler <mkoegler@auto.tuwien.ac.at>
---
 builtin-fsck.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/builtin-fsck.c b/builtin-fsck.c
index e4874f6..c4e91bf 100644
--- a/builtin-fsck.c
+++ b/builtin-fsck.c
@@ -360,6 +360,10 @@ 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/commiter line in %s",
+				sha1_to_hex(commit->object.sha1));
+
 	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')
@@ -378,9 +382,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;
 }
 
-- 
gitgui.0.9.1.gdeb16

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-01-21  7:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-20 18:59 [PATCH] git-fsck: report missing author/commit line in a commit as an error Martin Koegler
2008-01-20 19:20 ` Johannes Schindelin
2008-01-21  7:00   ` Martin Koegler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).