Skip to contentSkip to conversation

Use tree_from_tree_or_commit() in read-tree.

PATCH In review Junio C Hamano 1 participant 1 message Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

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

This patch makes read-tree accept either tree or commit.

---

 read-tree.c |    4 +---
 1 files changed, 1 insertion(+), 3 deletions(-)

Makefile: needs update

read-tree.c +1 -3
@@ -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;