{"thread":{"id":"6308","subject":"[PATCH] get_tree_entry: map blank requested entry to tree root","startedAt":"2007-01-09T16:11:47Z","lastAt":"2007-01-10T01:04:19Z","messageCount":7,"participants":["Jeff King","Johannes Schindelin","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"31254","messageId":"20070109161147.GA9313@coredump.intra.peff.net","threadId":"6308","inReplyTo":null,"subject":"[PATCH] get_tree_entry: map blank requested entry to tree root","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2007-01-09T16:11:47Z","receivedAt":"2007-01-09T16:11:47Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"This means that\n  git show HEAD:\nwill now return HEAD^{tree}, which is logically consistent with\n  git show HEAD:Documentation\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n tree-walk.c |    9 ++++++++-\n 1 files changed, 8 insertions(+), 1 deletions(-)\n\ndiff --git a/tree-walk.c b/tree-walk.c\nindex 22f4550..70f8999 100644\n--- a/tree-walk.c\n+++ b/tree-walk.c\n@@ -199,10 +199,17 @@ int get_tree_entry(const unsigned char *tree_sha1, const char *name, unsigned ch\n \tint retval;\n \tvoid *tree;\n \tstruct tree_desc t;\n+\tunsigned char root[20];\n \n-\ttree = read_object_with_reference(tree_sha1, tree_type, &t.size, NULL);\n+\ttree = read_object_with_reference(tree_sha1, tree_type, &t.size, root);\n \tif (!tree)\n \t\treturn -1;\n+\n+\tif (name[0] == '\\0') {\n+\t\thashcpy(sha1, root);\n+\t\treturn 0;\n+\t}\n+\n \tt.buf = tree;\n \tretval = find_tree_entry(&t, name, sha1, mode);\n \tfree(tree);\n-- \n1.4.4.4.g9612-dirty\n"},{"id":"31255","messageId":"Pine.LNX.4.63.0701091715040.22628@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"6308","inReplyTo":"20070109161147.GA9313@coredump.intra.peff.net","subject":"Re: [PATCH] get_tree_entry: map blank requested entry to tree root","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-01-09T16:15:15Z","receivedAt":"2007-01-09T16:15:15Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 9 Jan 2007, Jeff King wrote:\n\n> This means that\n>   git show HEAD:\n> will now return HEAD^{tree}, which is logically consistent with\n>   git show HEAD:Documentation\n\nGood idea!\n\nCiao,\nDscho\n"},{"id":"31312","messageId":"7vk5zviwxa.fsf@assigned-by-dhcp.cox.net","threadId":"6308","inReplyTo":"20070109161147.GA9313@coredump.intra.peff.net","subject":"Re: [PATCH] get_tree_entry: map blank requested entry to tree root","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-01-09T23:48:33Z","receivedAt":"2007-01-09T23:48:33Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Makes sense, although I somewhat worry about changing the\nbehaviour and potentially breaking the expectation of callers\nof get_tree_entry() other than \"git show\".\n"},{"id":"31328","messageId":"20070110004633.GA14345@coredump.intra.peff.net","threadId":"6308","inReplyTo":"7vk5zviwxa.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] get_tree_entry: map blank requested entry to tree root","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2007-01-10T00:46:33Z","receivedAt":"2007-01-10T00:46:33Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Jan 09, 2007 at 03:48:33PM -0800, Junio C Hamano wrote:\n\n> Makes sense, although I somewhat worry about changing the\n> behaviour and potentially breaking the expectation of callers\n> of get_tree_entry() other than \"git show\".\n\nPreviously, trying to get an empty name would always return -1. Most of\nthe users besides sha1_name are getting the paths by enumerating the\nindex or an existing tree, so they will never be blank. The exceptions\nare:\n - git-blame ''; this fails in both the root and a subdir (though with\n   different errors); behavior is unchanged with my patch\n - git-archive feeds the 'prefix' variable to get_tree_entry; it works\n   fine in the root with or without the patch. I seem to be getting an\n   error, with or without my patch, when doing a git-archive from a\n   subdirectory:\n     $ git-archive --format=tar origin >/dev/null\n     $ cd Documentation\n     $ git-archive --format=tar origin >/dev/null\n     fatal: cannot read c87c61af00c6d2cd7212240e260809000000aaab\n   but I haven't been able to track it down further. It's clearly\n   unrelated to my patch, though.\n\nThe main difference is that looking up a ref through sha1_name used to\nfail to match 'HEAD:'; now it does. So if you were trying to match a\nfile 'HEAD:' without using '--', you're out of luck.\n\n-Peff\n"},{"id":"31333","messageId":"7vac0rhf6g.fsf@assigned-by-dhcp.cox.net","threadId":"6308","inReplyTo":"20070110004633.GA14345@coredump.intra.peff.net","subject":"Re: [PATCH] get_tree_entry: map blank requested entry to tree root","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-01-10T00:57:11Z","receivedAt":"2007-01-10T00:57:11Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n>  - git-archive feeds the 'prefix' variable to get_tree_entry; it works\n>    fine in the root with or without the patch. I seem to be getting an\n>    error, with or without my patch, when doing a git-archive from a\n>    subdirectory:\n>      $ git-archive --format=tar origin >/dev/null\n>      $ cd Documentation\n>      $ git-archive --format=tar origin >/dev/null\n>      fatal: cannot read c87c61af00c6d2cd7212240e260809000000aaab\n>    but I haven't been able to track it down further. It's clearly\n>    unrelated to my patch, though.\n\nI've noticed this while looking at your patch and fixed it in my\ntree already.\n"},{"id":"31334","messageId":"20070110005750.GA18242@coredump.intra.peff.net","threadId":"6308","inReplyTo":"7vac0rhf6g.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] get_tree_entry: map blank requested entry to tree root","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2007-01-10T00:57:50Z","receivedAt":"2007-01-10T00:57:50Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Jan 09, 2007 at 04:57:11PM -0800, Junio C Hamano wrote:\n\n> I've noticed this while looking at your patch and fixed it in my\n> tree already.\n\nThanks, I will stop looking, then. :)\n\n-Peff\n"},{"id":"31337","messageId":"7v64bfheuk.fsf@assigned-by-dhcp.cox.net","threadId":"6308","inReplyTo":"20070110005750.GA18242@coredump.intra.peff.net","subject":"Re: [PATCH] get_tree_entry: map blank requested entry to tree root","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-01-10T01:04:19Z","receivedAt":"2007-01-10T01:04:19Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> On Tue, Jan 09, 2007 at 04:57:11PM -0800, Junio C Hamano wrote:\n>\n>> I've noticed this while looking at your patch and fixed it in my\n>> tree already.\n>\n> Thanks, I will stop looking, then. :)\n\n-- >8 --\n[PATCH] builtin-archive: do not free a tree held by the object layer.\n\nFound by running \"git archive --format=tar HEAD\" in Documentation/\ndirectory.\n\nIt's surprising that nobody has noticed this from the beginning...\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n builtin-archive.c |    1 -\n 1 files changed, 0 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin-archive.c b/builtin-archive.c\nindex 391cf43..32737d3 100644\n--- a/builtin-archive.c\n+++ b/builtin-archive.c\n@@ -137,7 +137,6 @@ void parse_treeish_arg(const char **argv, struct archiver_args *ar_args,\n \t\tif (err || !S_ISDIR(mode))\n \t\t\tdie(\"current working directory is untracked\");\n \n-\t\tfree(tree);\n \t\ttree = parse_tree_indirect(tree_sha1);\n \t}\n \tar_args->tree = tree;\n"}]}