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

[PATCH 3/4] Use tree_from_tree_or_commit() in diff-tree.

From
Junio C Hamano <junkio@cox.net>
Date
Apr 20, 2005, 06:10 UTC
Message-ID
<7v8y3ekmgd.fsf@assigned-by-dhcp.cox.net>
This patch makes diff-tree accept either tree or commit.
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
 diff-tree.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)
--- a/diff-tree.c
+++ b/diff-tree.c
@@ -160,18 +160,20 @@ static int diff_tree(void *tree1, unsign
 	return 0;
 }
 
-static int diff_tree_sha1(const unsigned char *old, const unsigned char *new, const char *base)
+static int diff_tree_sha1(const unsigned char *old,
+			  const unsigned char *new,
+			  const char *base)
 {
 	void *tree1, *tree2;
 	unsigned long size1, size2;
 	char type[20];
 	int retval;
 
-	tree1 = read_sha1_file(old, type, &size1);
-	if (!tree1 || strcmp(type, "tree"))
+	tree1 = tree_from_tree_or_commit(old, type, &size1);
+	if (!tree1)
 		die("unable to read source tree (%s)", sha1_to_hex(old));
-	tree2 = read_sha1_file(new, type, &size2);
-	if (!tree2 || strcmp(type, "tree"))
+	tree2 = tree_from_tree_or_commit(new, type, &size2);
+	if (!tree2)
 		die("unable to read destination tree (%s)", sha1_to_hex(new));
 	retval = diff_tree(tree1, size1, tree2, size2, base);
 	free(tree1);
Message 1 of 1 in “Use tree_from_tree_or_commit() in diff-tree.”
  1. 3/4 Use tree_from_tree_or_commit() in diff-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.