summaryrefslogtreecommitdiff
path: root/cat-file.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-07 15:13:13 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-07 15:13:13 -0700
commite83c5163316f89bfbde7d9ab23ca2e25604af290 (patch)
tree2b5bfdf7798569e0b59b16eb9602d5fa572d6038 /cat-file.c
downloadgit-e83c5163316f89bfbde7d9ab23ca2e25604af290.tar.gz
Initial revision of "git", the information manager from hellinitial
Diffstat (limited to 'cat-file.c')
-rw-r--r--cat-file.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/cat-file.c b/cat-file.c
new file mode 100644
index 0000000000..74a0a234dd
--- /dev/null
+++ b/cat-file.c
@@ -0,0 +1,23 @@
+#include "cache.h"
+
+int main(int argc, char **argv)
+{
+ unsigned char sha1[20];
+ char type[20];
+ void *buf;
+ unsigned long size;
+ char template[] = "temp_git_file_XXXXXX";
+ int fd;
+
+ if (argc != 2 || get_sha1_hex(argv[1], sha1))
+ usage("cat-file: cat-file <sha1>");
+ buf = read_sha1_file(sha1, type, &size);
+ if (!buf)
+ exit(1);
+ fd = mkstemp(template);
+ if (fd < 0)
+ usage("unable to create tempfile");
+ if (write(fd, buf, size) != size)
+ strcpy(type, "bad");
+ printf("%s: %s\n", template, type);
+}