2 * GIT - The information manager from hell
4 * Copyright (C) Linus Torvalds, 2005
8 int main(int argc
, char **argv
)
10 unsigned char sha1
[20];
15 setup_git_directory();
16 if (argc
!= 3 || get_sha1(argv
[2], sha1
))
17 usage("git-cat-file [-t | -s | <type>] <sha1>");
19 if (!strcmp("-t", argv
[1]) || !strcmp("-s", argv
[1])) {
20 if (!sha1_object_info(sha1
, type
,
21 argv
[1][1] == 's' ? &size
: NULL
)) {
27 printf("%lu\n", size
);
34 buf
= read_object_with_reference(sha1
, argv
[1], &size
, NULL
);
38 die("git-cat-file %s: bad file", argv
[2]);
41 long ret
= write(1, buf
, size
);
48 die("git-cat-file: %s", strerror(errno
));
50 die("git-cat-file: disk full?");