Git development
 help / color / mirror / Atom feed
* [PATCH] get_tree_entry: map blank requested entry to tree root
@ 2007-01-09 16:11 Jeff King
  2007-01-09 16:15 ` Johannes Schindelin
  2007-01-09 23:48 ` Junio C Hamano
  0 siblings, 2 replies; 7+ messages in thread
From: Jeff King @ 2007-01-09 16:11 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

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>
---
 tree-walk.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/tree-walk.c b/tree-walk.c
index 22f4550..70f8999 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);
-- 
1.4.4.4.g9612-dirty

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2007-01-10  1:04 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-01-09 16:11 [PATCH] get_tree_entry: map blank requested entry to tree root Jeff King
2007-01-09 16:15 ` Johannes Schindelin
2007-01-09 23:48 ` Junio C Hamano
2007-01-10  0:46   ` Jeff King
2007-01-10  0:57     ` Junio C Hamano
2007-01-10  0:57       ` Jeff King
2007-01-10  1:04         ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox