{"thread":{"id":"183","subject":"(rework) [PATCH 3/5] Accept commit in some places when tree is needed.","startedAt":"2005-04-21T00:22:30Z","lastAt":"2005-04-21T00:22:30Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":5},"messages":[{"id":"1068","messageId":"7v1x95htbt.fsf@assigned-by-dhcp.cox.net","threadId":"183","inReplyTo":null,"subject":"(rework) [PATCH 3/5] Accept commit in some places when tree is needed.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-04-21T00:22:30Z","receivedAt":"2005-04-21T00:22:30Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Updates diff-tree.c to use read_tree_with_tree_or_commit_sha1()\nfunction.  The command can take either tree or commit IDs with this patch.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n\n diff-tree.c |   25 ++++---------------------\n 1 files changed, 4 insertions(+), 21 deletions(-)\n\ndiff-tree.c: 65bb9d66c5610b2ede11f03a9120da48c59629f8\n--- a/diff-tree.c\n+++ b/diff-tree.c\n@@ -164,14 +164,13 @@ static int diff_tree_sha1(const unsigned\n {\n \tvoid *tree1, *tree2;\n \tunsigned long size1, size2;\n-\tchar type[20];\n \tint retval;\n \n-\ttree1 = read_sha1_file(old, type, &size1);\n-\tif (!tree1 || strcmp(type, \"tree\"))\n+\ttree1 = read_tree_with_tree_or_commit_sha1(old, &size1, 0);\n+\tif (!tree1)\n \t\tdie(\"unable to read source tree (%s)\", sha1_to_hex(old));\n-\ttree2 = read_sha1_file(new, type, &size2);\n-\tif (!tree2 || strcmp(type, \"tree\"))\n+\ttree2 = read_tree_with_tree_or_commit_sha1(new, &size2, 0);\n+\tif (!tree2)\n \t\tdie(\"unable to read destination tree (%s)\", sha1_to_hex(new));\n \tretval = diff_tree(tree1, size1, tree2, size2, base);\n \tfree(tree1);\n@@ -179,20 +178,6 @@ static int diff_tree_sha1(const unsigned\n \treturn retval;\n }\n \n-static void commit_to_tree(unsigned char *sha1)\n-{\n-\tvoid *buf;\n-\tchar type[20];\n-\tunsigned long size;\n-\n-\tbuf = read_sha1_file(sha1, type, &size);\n-\tif (buf) {\n-\t\tif (!strcmp(type, \"commit\"))\n-\t\t\tget_sha1_hex(buf+5, sha1);\n-\t\tfree(buf);\n-\t}\n-}\n-\n int main(int argc, char **argv)\n {\n \tunsigned char old[20], new[20];\n@@ -214,7 +199,5 @@ int main(int argc, char **argv)\n \n \tif (argc != 3 || get_sha1_hex(argv[1], old) || get_sha1_hex(argv[2], new))\n \t\tusage(\"diff-tree <tree sha1> <tree sha1>\");\n-\tcommit_to_tree(old);\n-\tcommit_to_tree(new);\n \treturn diff_tree_sha1(old, new, \"\");\n }\n\n"}]}