1 /*
2 * GIT - The information manager from hell
3 *
4 * Copyright (C) Linus Torvalds, 2005
5 */
6 #include "cache.h"
8 int main(int argc, char **argv)
9 {
10 unsigned char sha1[20];
11 char type[20];
12 void *buf;
13 unsigned long size;
14 char template[] = "temp_git_file_XXXXXX";
15 int fd;
17 if (argc != 2 || get_sha1_hex(argv[1], sha1))
18 usage("cat-file: cat-file <sha1>");
19 buf = read_sha1_file(sha1, type, &size);
20 if (!buf)
21 exit(1);
22 fd = mkstemp(template);
23 if (fd < 0)
24 usage("unable to create tempfile");
25 if (write(fd, buf, size) != size)
26 strcpy(type, "bad");
27 printf("%s: %s\n", template, type);
28 }