@matheusbsbs / matheus-bagliano / commits / d93b7d1c30
Fork 0

get_tree_entry: map blank requested entry to tree root

This means that git show HEAD: will now return HEAD^{tree}, which is logically consistent with git show HEAD:Documentation Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <junkio@cox.net>

Jeff King committed Jan 9, 2007 at 11:11 UTC d93b7d1c30c9716953392ec6590686301de0cc25
1 file changed +8 -1
tree-walk.c
+8 -1
@@ -199,10 +199,17 @@ int get_tree_entry(const unsigned char *tree_sha1, const char *name, unsigned ch
199 int retval;
200 void *tree;
201 struct tree_desc t;
202 + unsigned char root[20];
203
203 - tree = read_object_with_reference(tree_sha1, tree_type, &t.size, NULL);
204 + tree = read_object_with_reference(tree_sha1, tree_type, &t.size, root);
205 if (!tree)
206 return -1;
207 +
208 + if (name[0] == '\0') {
209 + hashcpy(sha1, root);
210 + return 0;
211 + }
212 +
213 t.buf = tree;
214 retval = find_tree_entry(&t, name, sha1, mode);
215 free(tree);