- * and the file size. -- pasky@ucw.cz */
- type = S_ISDIR(mode) ? "tree" : "blob";
- printf("%03o\t%s\t%s\t%s\n", mode, type, sha1_to_hex(sha1), path);
+ * and the file size. -- pasky@ucw.cz
+ * ... that is, when we are not recursive -- junkio@cox.net
+ */
+ eltbuf = (recursive ? read_sha1_file(sha1, elttype, &eltsize) :
+ NULL);
+ if (! eltbuf) {
+ if (recursive)
+ error("cannot read %s", sha1_to_hex(sha1));
+ type = S_ISDIR(mode) ? "tree" : "blob";
+ }
+ else
+ type = elttype;
+
+ printf("%03o\t%s\t%s\t", mode, type, sha1_to_hex(sha1));
+ print_path_prefix(prefix);
+ fputs(path, stdout);
+ putchar(line_termination);
+
+ if (eltbuf && !strcmp(type, "tree")) {
+ this_prefix.name = path;
+ list_recursive(eltbuf, elttype, eltsize, &this_prefix);
+ }
+ free(eltbuf);