diff options
author | Jeff King <peff@peff.net> | 2007-01-09 11:11:47 -0500 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2007-01-09 14:08:41 -0800 |
commit | d93b7d1c30c9716953392ec6590686301de0cc25 (patch) | |
tree | ef4c4fc39ad91d0a50d5fa86c8ba31ec4b694434 /tree-walk.c | |
parent | 2740b2b8539a322bc73f46c45c569503900c5dc1 (diff) | |
download | git-d93b7d1c30c9716953392ec6590686301de0cc25.tar.gz git-d93b7d1c30c9716953392ec6590686301de0cc25.tar.xz |
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>
Diffstat (limited to 'tree-walk.c')
-rw-r--r-- | tree-walk.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/tree-walk.c b/tree-walk.c index 22f4550b6..70f899957 100644 --- a/tree-walk.c +++ b/tree-walk.c @@ -199,10 +199,17 @@ int get_tree_entry(const unsigned char *tree_sha1, const char *name, unsigned ch int retval; void *tree; struct tree_desc t; + unsigned char root[20]; - tree = read_object_with_reference(tree_sha1, tree_type, &t.size, NULL); + tree = read_object_with_reference(tree_sha1, tree_type, &t.size, root); if (!tree) return -1; + + if (name[0] == '\0') { + hashcpy(sha1, root); + return 0; + } + t.buf = tree; retval = find_tree_entry(&t, name, sha1, mode); free(tree); |