- void *buffer;
- unsigned long size;
- char type[20];
-
- buffer = read_sha1_file(sha1, type, &size);
- if (!buffer)
- die("unable to read sha1 file");
- list_recursive(buffer, type, size, NULL);
- return 0;
+ int retval = 0;
+ const char *type = "blob";
+
+ if (S_ISDIR(mode)) {
+ if (show_recursive(base, baselen, pathname)) {
+ retval = READ_TREE_RECURSIVE;
+ if (!(ls_options & LS_SHOW_TREES))
+ return retval;
+ }
+ type = "tree";
+ }
+ else if (ls_options & LS_TREE_ONLY)
+ return 0;
+
+ if (!(ls_options & LS_NAME_ONLY))
+ printf("%06o %s %s\t", mode, type, sha1_to_hex(sha1));
+ write_name_quoted(base, baselen, pathname, line_termination, stdout);
+ putchar(line_termination);
+ return retval;