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

[PATCH] parse_commit: don't ignore NULL from loopup_commit

From
MKMartin Koegler <mkoegler@auto.tuwien.ac.at>
Date
Feb 14, 2008, 22:02 UTC
Message-ID
<12030265212108-git-send-email-mkoegler@auto.tuwien.ac.at>

This behaviour causes a different parent list depending on the already loaded objects, if the parent points contains a non commit sha1.

Signed-off-by: Martin Koegler <mkoegler@auto.tuwien.ac.at>
---
This will hide such an error from fsck (as the parent is not
returned) and make it only print a message to stderr.
 commit.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/commit.c b/commit.c
index 8b8fb04..116afb7 100644
--- a/commit.c
+++ b/commit.c
@@ -275,7 +275,8 @@ int parse_commit_buffer(struct commit *item, void *buffer, unsigned long size)
 		if (new_parent) {
 			pptr = &commit_list_insert(new_parent, pptr)->next;
 			n_refs++;
-		}
+		} else
+			return error("bad parents in commit %s", sha1_to_hex(item->object.sha1));
 	}
 	if (graft) {
 		int i;
@@ -283,7 +284,7 @@ int parse_commit_buffer(struct commit *item, void *buffer, unsigned long size)
 		for (i = 0; i < graft->nr_parent; i++) {
 			new_parent = lookup_commit(graft->parent[i]);
 			if (!new_parent)
-				continue;
+				return error("bad graft in commit %s", sha1_to_hex(item->object.sha1));
 			pptr = &commit_list_insert(new_parent, pptr)->next;
 			n_refs++;
 		}
-- 
1.5.4.1.g3a858
Message 1 of 1 in “parse_commit: don't ignore NULL from loopup_commit”
  1. parse_commit: don't ignore NULL from loopup_commitMartin Koegler, Feb 14, 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.