git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] get_tree_entry: map blank requested entry to tree root

From
Jeff King <peff@peff.net>
Date
Jan 9, 2007, 16:11 UTC
Message-ID
<20070109161147.GA9313@coredump.intra.peff.net>
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
Next: Johannes Schindelin
Message 1 of 7 in “get_tree_entry: map blank requested entry to tree root”
  1. get_tree_entry: map blank requested entry to tree rootJeff King, Jan 9, 2007
  2. Johannes SchindelinJan 9, 2007
  3. Junio C HamanoJan 9, 2007
  4. Jeff KingJan 10, 2007
  5. Junio C HamanoJan 10, 2007
  6. Jeff KingJan 10, 2007
  7. Junio C HamanoJan 10, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.