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

[PATCH 2/4] Use tree_from_tree_or_commit() in read-tree.

From
Junio C Hamano <junkio@cox.net>
Date
Apr 20, 2005, 06:09 UTC
Message-ID
<7vekd6kmi3.fsf@assigned-by-dhcp.cox.net>
This patch makes read-tree accept either tree or commit.
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
 read-tree.c |    4 +---
 1 files changed, 1 insertion(+), 3 deletions(-)
Makefile: needs update
--- a/read-tree.c
+++ b/read-tree.c
@@ -29,11 +29,9 @@ static int read_tree(unsigned char *sha1
 	unsigned long size;
 	char type[20];
 
-	buffer = read_sha1_file(sha1, type, &size);
+	buffer = tree_from_tree_or_commit(sha1, type, &size);
 	if (!buffer)
 		return -1;
-	if (strcmp(type, "tree"))
-		return -1;
 	while (size) {
 		int len = strlen(buffer)+1;
 		unsigned char *sha1 = buffer + len;
Message 1 of 1 in “Use tree_from_tree_or_commit() in read-tree.”
  1. 2/4 Use tree_from_tree_or_commit() in read-tree.Junio C Hamano, Apr 20, 2005

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.