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

(rework) [PATCH 3/4] Accept commit in some places when tree is needed.

From
Junio C Hamano <junkio@cox.net>
Date
Apr 21, 2005, 00:23 UTC
Message-ID
<7vvf6hgeqj.fsf@assigned-by-dhcp.cox.net>

Updates ls-tree.c to use read_tree_with_tree_or_commit_sha1() function. The command can take either tree or commit IDs with this patch.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---
 ls-tree.c |   11 +++++------
 1 files changed, 5 insertions(+), 6 deletions(-)
ls-tree.c: c063640c114634dc7cf950ce44863dd17ddf83c1
--- a/ls-tree.c
+++ b/ls-tree.c
@@ -24,9 +24,9 @@ static void print_path_prefix(struct pat
 }
 
 static void list_recursive(void *buffer,
-			  unsigned char *type,
-			  unsigned long size,
-			  struct path_prefix *prefix)
+			   const unsigned char *type,
+			   unsigned long size,
+			   struct path_prefix *prefix)
 {
 	struct path_prefix this_prefix;
 	this_prefix.prev = prefix;
@@ -72,12 +72,11 @@ static int list(unsigned char *sha1)
 {
 	void *buffer;
 	unsigned long size;
-	char type[20];
 
-	buffer = read_sha1_file(sha1, type, &size);
+	buffer = read_tree_with_tree_or_commit_sha1(sha1, &size, 0);
 	if (!buffer)
 		die("unable to read sha1 file");
-	list_recursive(buffer, type, size, NULL);
+	list_recursive(buffer, "tree", size, NULL);
 	return 0;
 }
Next: Junio C Hamano
Message 1 of 4 in “(rework) [PATCH 3/4] Accept commit in some places when tree is needed.”
  1. Junio C HamanoApr 21, 2005
  2. Junio C HamanoApr 21, 2005
  3. Linus TorvaldsApr 21, 2005
  4. Junio C HamanoApr 21, 2005

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.