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

[PATCH 1/4] Fix tree-walking compare_entry() in the presense of --prefix

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Mar 6, 2008, 23:44 UTC
Message-ID
<76edcf443909a95e2c391e23390a963f9a417dee.1204856187.git.torvalds@linux-foundation.org>
In-Reply-To
<cover.1204856187.git.torvalds@linux-foundation.org>

When we make the "root" tree-walk info entry have a pathname in it, we need to have a ->prev pointer so that compare_entry will actually notice and traverse into the root.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
---
 tree-walk.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/tree-walk.c b/tree-walk.c
index 842cb6a..02e2aed 100644
--- a/tree-walk.c
+++ b/tree-walk.c
@@ -107,6 +107,7 @@ int tree_entry(struct tree_desc *desc, struct name_entry *entry)
 void setup_traverse_info(struct traverse_info *info, const char *base)
 {
 	int pathlen = strlen(base);
+	static struct traverse_info dummy;
 
 	memset(info, 0, sizeof(*info));
 	if (pathlen && base[pathlen-1] == '/')
@@ -114,6 +115,8 @@ void setup_traverse_info(struct traverse_info *info, const char *base)
 	info->pathlen = pathlen ? pathlen + 1 : 0;
 	info->name.path = base;
 	info->name.sha1 = (void *)(base + pathlen + 1);
+	if (pathlen)
+		info->prev = &dummy;
 }
 
 char *make_traverse_path(char *path, const struct traverse_info *info, const struct name_entry *n)
-- 
1.5.4.3.452.g67136
Previous: Linus TorvaldsNext: Linus Torvalds
Message 4 of 11 in “Make unpack_trees() do separate source and destination indexes”
  1. 0/4 Make unpack_trees() do separate source and destination indexesLinus Torvalds, Mar 7, 2008
  2. 3/4 Make 'unpack_trees()' take the index to work on as an argumentLinus Torvalds, Mar 6, 2008
  3. 2/4 Add 'const' where appropriate to index handling functionsLinus Torvalds, Mar 6, 2008
  4. 1/4 Fix tree-walking compare_entry() in the presense of --prefixLinus Torvalds, Mar 6, 2008
  5. 4/4 Make 'unpack_trees()' have a separate source and destination indexLinus Torvalds, Mar 7, 2008
  6. Johannes SchindelinMar 7, 2008
  7. Linus TorvaldsMar 7, 2008
  8. Daniel BarkalowMar 7, 2008
  9. Linus TorvaldsMar 7, 2008
  10. Junio C HamanoMar 7, 2008
  11. Linus TorvaldsMar 7, 2008

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.