@matheusbsbs / matheus-bagliano / commits / bcbe5a515e
Fork 0

Fix tree-walking compare_entry() in the presense of --prefix

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> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Linus Torvalds committed Mar 6, 2008 at 15:44 UTC bcbe5a515e837873f24dc9a764fa31e3ade45bb5
1 file changed +3
tree-walk.c
+3
@@ -107,6 +107,7 @@ int tree_entry(struct tree_desc *desc, struct name_entry *entry)
107 void setup_traverse_info(struct traverse_info *info, const char *base)
108 {
109 int pathlen = strlen(base);
110 + static struct traverse_info dummy;
111
112 memset(info, 0, sizeof(*info));
113 if (pathlen && base[pathlen-1] == '/')
@@ -114,6 +115,8 @@ void setup_traverse_info(struct traverse_info *info, const char *base)
115 info->pathlen = pathlen ? pathlen + 1 : 0;
116 info->name.path = base;
117 info->name.sha1 = (void *)(base + pathlen + 1);
118 + if (pathlen)
119 + info->prev = &dummy;
120 }
121
122 char *make_traverse_path(char *path, const struct traverse_info *info, const struct name_entry *n)