summaryrefslogtreecommitdiff
path: root/tree-walk.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2007-01-09 11:11:47 -0500
committerJunio C Hamano <junkio@cox.net>2007-01-09 14:08:41 -0800
commitd93b7d1c30c9716953392ec6590686301de0cc25 (patch)
treeef4c4fc39ad91d0a50d5fa86c8ba31ec4b694434 /tree-walk.c
parent2740b2b8539a322bc73f46c45c569503900c5dc1 (diff)
downloadgit-d93b7d1c30c9716953392ec6590686301de0cc25.tar.gz
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.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/tree-walk.c b/tree-walk.c
index 22f4550b6c..70f899957e 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);