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

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Junio C Hamano <gitster@...>
Cc: <git@...>, Martin Koegler <mkoegler@...>
Date: Sunday, January 20, 2008 - 2:59 pm

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

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] git-fsck: report missing author/commit line in a com..., Martin Koegler, (Sun Jan 20, 2:59 pm)
Re: [PATCH] git-fsck: report missing author/commit line in a..., Johannes Schindelin, (Sun Jan 20, 3:20 pm)