- printf("%06o %s %s\t", mode, type, sha1_to_hex(sha1));
- write_name_quoted(base, baselen, pathname, line_termination, stdout);
+ if (chomp_prefix &&
+ (baselen < chomp_prefix || memcmp(prefix, base, chomp_prefix)))
+ return 0;
+
+ if (!(ls_options & LS_NAME_ONLY))
+ printf("%06o %s %s\t", mode, type, sha1_to_hex(sha1));
+ write_name_quoted(base + chomp_prefix, baselen - chomp_prefix,
+ pathname,
+ line_termination, stdout);