Skip to content

Commit

Permalink
Fix tree-walking compare_entry() in the presense of --prefix
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
torvalds authored and gitster committed Mar 9, 2008
1 parent 0190457 commit bcbe5a5
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tree-walk.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,16 @@ 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] == '/')
pathlen--;
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)
Expand Down

0 comments on commit bcbe5a5

Please sign in to comment.