summaryrefslogtreecommitdiff
path: root/builtin/ls-tree.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2014-11-30 16:05:01 +0700
committerJunio C Hamano <gitster@pobox.com>2014-12-01 11:32:34 -0800
commit1cf9952db243c624cc2763fa74e98adbb38537b1 (patch)
tree3e1f495925b0e6e8869a238ee7a567e32fa2b997 /builtin/ls-tree.c
parent6a0b0b6de996e2ac7eeb951e3d08f577c11c7e54 (diff)
downloadgit-1cf9952db243c624cc2763fa74e98adbb38537b1.tar.gz
ls-tree: remove path filtering logic in show_tree
ls-tree uses read_tree_recursive() which already does path filtering using pathspec. No need to filter one more time based on prefix only. "ls-tree ../somewhere" does not work because of this. write_name_quotedpfx() can now be retired because nobody else uses it. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/ls-tree.c')
-rw-r--r--builtin/ls-tree.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/builtin/ls-tree.c b/builtin/ls-tree.c
index 1ab0381245..053edb23a0 100644
--- a/builtin/ls-tree.c
+++ b/builtin/ls-tree.c
@@ -65,6 +65,7 @@ static int show_tree(const unsigned char *sha1, struct strbuf *base,
const char *pathname, unsigned mode, int stage, void *context)
{
int retval = 0;
+ int baselen;
const char *type = blob_type;
if (S_ISGITLINK(mode)) {
@@ -89,11 +90,6 @@ static int show_tree(const unsigned char *sha1, struct strbuf *base,
else if (ls_options & LS_TREE_ONLY)
return 0;
- if (chomp_prefix &&
- (base->len < chomp_prefix ||
- memcmp(ls_tree_prefix, base->buf, chomp_prefix)))
- return 0;
-
if (!(ls_options & LS_NAME_ONLY)) {
if (ls_options & LS_SHOW_SIZE) {
char size_text[24];
@@ -113,8 +109,12 @@ static int show_tree(const unsigned char *sha1, struct strbuf *base,
printf("%06o %s %s\t", mode, type,
find_unique_abbrev(sha1, abbrev));
}
- write_name_quotedpfx(base->buf + chomp_prefix, base->len - chomp_prefix,
- pathname, stdout, line_termination);
+ baselen = base->len;
+ strbuf_addstr(base, pathname);
+ write_name_quoted_relative(base->buf,
+ chomp_prefix ? ls_tree_prefix : NULL,
+ stdout, line_termination);
+ strbuf_setlen(base, baselen);
return retval;
}