ls-tree: remove path filtering logic in show_tree
[gitweb.git] / builtin / ls-tree.c
index 1ab03812453970ecdaafccb2b4c24a06bb12651a..053edb23a0a3906a0ee64dd49eb2e2f071a465ba 100644 (file)
@@ -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;
 }