about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ui-tree.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/ui-tree.c b/ui-tree.c index 5c31e6a..b98a7f0 100644 --- a/ui-tree.c +++ b/ui-tree.c
@@ -324,22 +324,25 @@ static int walk_tree(const unsigned char *sha1, struct strbuf *base,
324 const char *pathname, unsigned mode, int stage, void *cbdata) 324 const char *pathname, unsigned mode, int stage, void *cbdata)
325{ 325{
326 struct walk_tree_context *walk_tree_ctx = cbdata; 326 struct walk_tree_context *walk_tree_ctx = cbdata;
327 static char buffer[PATH_MAX];
328 327
329 if (walk_tree_ctx->state == 0) { 328 if (walk_tree_ctx->state == 0) {
330 memcpy(buffer, base->buf, base->len); 329 struct strbuf buffer = STRBUF_INIT;
331 strcpy(buffer + base->len, pathname); 330
332 if (strcmp(walk_tree_ctx->match_path, buffer)) 331 strbuf_addbuf(&buffer, base);
332 strbuf_addstr(&buffer, pathname);
333 if (strcmp(walk_tree_ctx->match_path, buffer.buf))
333 return READ_TREE_RECURSIVE; 334 return READ_TREE_RECURSIVE;
334 335
335 if (S_ISDIR(mode)) { 336 if (S_ISDIR(mode)) {
336 walk_tree_ctx->state = 1; 337 walk_tree_ctx->state = 1;
337 set_title_from_path(buffer); 338 set_title_from_path(buffer.buf);
339 strbuf_release(&buffer);
338 ls_head(); 340 ls_head();
339 return READ_TREE_RECURSIVE; 341 return READ_TREE_RECURSIVE;
340 } else { 342 } else {
341 walk_tree_ctx->state = 2; 343 walk_tree_ctx->state = 2;
342 print_object(sha1, buffer, pathname, walk_tree_ctx->curr_rev); 344 print_object(sha1, buffer.buf, pathname, walk_tree_ctx->curr_rev);
345 strbuf_release(&buffer);
343 return 0; 346 return 0;
344 } 347 }
345 } 348 }