{"thread":{"id":"182","subject":"(rework) [PATCH 2/5] Accept commit in some places when tree is needed.","startedAt":"2005-04-21T00:21:42Z","lastAt":"2005-04-21T00:21:42Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":5},"messages":[{"id":"1067","messageId":"7v64yhhtd5.fsf@assigned-by-dhcp.cox.net","threadId":"182","inReplyTo":null,"subject":"(rework) [PATCH 2/5] Accept commit in some places when tree is needed.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-04-21T00:21:42Z","receivedAt":"2005-04-21T00:21:42Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Updates diff-cache.c to use read_tree_with_tree_or_commit_sha1()\nfunction.  The end-user visible result is the same --- the command\ntakes either tree or commit ID.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n\n diff-cache.c |   17 +----------------\n 1 files changed, 1 insertion(+), 16 deletions(-)\n\ndiff-cache.c: fcbc4900d32f4ca24f67bb8f0fe344c6c5642ac9\n--- a/diff-cache.c\n+++ b/diff-cache.c\n@@ -220,7 +220,6 @@ int main(int argc, char **argv)\n \tunsigned char tree_sha1[20];\n \tvoid *tree;\n \tunsigned long size;\n-\tchar type[20];\n \n \tread_cache();\n \twhile (argc > 2) {\n@@ -245,23 +244,9 @@ int main(int argc, char **argv)\n \tif (argc != 2 || get_sha1_hex(argv[1], tree_sha1))\n \t\tusage(\"diff-cache [-r] [-z] <tree sha1>\");\n \n-\ttree = read_sha1_file(tree_sha1, type, &size);\n+\ttree = read_tree_with_tree_or_commit_sha1(tree_sha1, &size, 0);\n \tif (!tree)\n \t\tdie(\"bad tree object %s\", argv[1]);\n \n-\t/* We allow people to feed us a commit object, just because we're nice */\n-\tif (!strcmp(type, \"commit\")) {\n-\t\t/* tree sha1 is always at offset 5 (\"tree \") */\n-\t\tif (get_sha1_hex(tree + 5, tree_sha1))\n-\t\t\tdie(\"bad commit object %s\", argv[1]);\n-\t\tfree(tree);\n-\t\ttree = read_sha1_file(tree_sha1, type, &size);       \n-\t\tif (!tree)\n-\t\t\tdie(\"unable to read tree object %s\", sha1_to_hex(tree_sha1));\n-\t}\n-\n-\tif (strcmp(type, \"tree\"))\n-\t\tdie(\"bad tree object %s (%s)\", sha1_to_hex(tree_sha1), type);\n-\n \treturn diff_cache(tree, size, active_cache, active_nr, \"\");\n }\n\n\n"}]}