Skip to content

Commit bcbe5a5

Browse files
torvaldsgitster
authored andcommitted
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>
1 parent 0190457 commit bcbe5a5

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

tree-walk.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,16 @@ int tree_entry(struct tree_desc *desc, struct name_entry *entry)
107107
void setup_traverse_info(struct traverse_info *info, const char *base)
108108
{
109109
int pathlen = strlen(base);
110+
static struct traverse_info dummy;
110111

111112
memset(info, 0, sizeof(*info));
112113
if (pathlen && base[pathlen-1] == '/')
113114
pathlen--;
114115
info->pathlen = pathlen ? pathlen + 1 : 0;
115116
info->name.path = base;
116117
info->name.sha1 = (void *)(base + pathlen + 1);
118+
if (pathlen)
119+
info->prev = &dummy;
117120
}
118121

119122
char *make_traverse_path(char *path, const struct traverse_info *info, const struct name_entry *n)

0 commit comments

Comments
 (0)