git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
MKMartin Koegler <mkoegler@auto.tuwien.ac.at>
Date
Feb 3, 2008, 21:22 UTC
Message-ID
<12020737593747-git-send-email-mkoegler@auto.tuwien.ac.at>
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>
---
 builtin-fsck.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/builtin-fsck.c b/builtin-fsck.c
index 6fc9525..cc7524b 100644
--- a/builtin-fsck.c
+++ b/builtin-fsck.c
@@ -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')
@@ -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;
 }
 
-- 
1.5.4.g22bc
Next: Martin Koegler
Message 1 of 7 in “git-fsck: report missing author/commit line in a commit as an error”
  1. 1/3 git-fsck: report missing author/commit line in a commit as an errorMartin Koegler, Feb 3, 2008
  2. 2/3 fsck_commit: remove duplicate testsMartin Koegler, Feb 3, 2008
  3. 3/3 parse_object_buffer: don't ignore errors from the object specific parsing functionsMartin Koegler, Feb 3, 2008
  4. Junio C HamanoFeb 3, 2008
  5. Johannes SchindelinFeb 4, 2008
  6. Martin KoeglerFeb 4, 2008
  7. Junio C HamanoFeb 4, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.