-static void list_recursive(void *buffer,
- const char *type,
- unsigned long size,
- struct path_prefix *prefix)
-{
- struct path_prefix this_prefix;
- this_prefix.prev = prefix;
-
- if (strcmp(type, "tree"))
- die("expected a 'tree' node");
-
- while (size) {
- int namelen = strlen(buffer)+1;
- void *eltbuf;
- char elttype[20];
- unsigned long eltsize;
- unsigned char *sha1 = buffer + namelen;
- char *path = strchr(buffer, ' ') + 1;
- unsigned int mode;
-
- if (size < namelen + 20 || sscanf(buffer, "%o", &mode) != 1)
- die("corrupt 'tree' file");
- buffer = sha1 + 20;
- size -= namelen + 20;
-
- printf("%06o\t%s\t%s\t", mode,
- S_ISDIR(mode) ? "tree" : "blob",
- sha1_to_hex(sha1));
- print_path_prefix(prefix);
- fputs(path, stdout);
- putchar(line_termination);
-
- if (! recursive || ! S_ISDIR(mode))