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];
16 setup_git_directory();
17 if (argc
!= 3 || get_sha1(argv
[2], sha1
))
18 usage("git-cat-file [-t|-s|-e|<type>] <sha1>");
21 if ( argv
[1][0] == '-' ) {
23 if ( !opt
|| argv
[1][2] )
24 opt
= -1; /* Not a single character option */
30 if (!sha1_object_info(sha1
, type
, NULL
)) {
37 if (!sha1_object_info(sha1
, type
, &size
)) {
38 printf("%lu\n", size
);
44 return !has_sha1_file(sha1
);
47 buf
= read_object_with_reference(sha1
, argv
[1], &size
, NULL
);
51 die("git-cat-file: unknown option: %s\n", argv
[1]);
55 die("git-cat-file %s: bad file", argv
[2]);
58 long ret
= xwrite(1, buf
, size
);
63 die("git-cat-file: %s", strerror(errno
));
65 die("git-cat-file: disk full?");