break;
default:
- die("git-cat-file: unknown option: %s\n", exp_type);
+ die("git cat-file: unknown option: %s", exp_type);
}
if (!buf)
- die("git-cat-file %s: bad file", obj_name);
+ die("git cat-file %s: bad file", obj_name);
write_or_die(1, buf, size);
return 0;
static int batch_one_object(const char *obj_name, int print_contents)
{
unsigned char sha1[20];
- enum object_type type;
+ enum object_type type = 0;
unsigned long size;
void *contents = contents;
if (get_sha1(obj_name, sha1)) {
printf("%s missing\n", obj_name);
+ fflush(stdout);
return 0;
}
else
type = sha1_object_info(sha1, &size);
- if (type <= 0)
- return 1;
+ if (type <= 0) {
+ printf("%s missing\n", obj_name);
+ fflush(stdout);
+ return 0;
+ }
printf("%s %s %lu\n", sha1_to_hex(sha1), typename(type), size);
fflush(stdout);
write_or_die(1, contents, size);
printf("\n");
fflush(stdout);
+ free(contents);
}
return 0;
static int batch_objects(int print_contents)
{
- struct strbuf buf;
+ struct strbuf buf = STRBUF_INIT;
- strbuf_init(&buf, 0);
while (strbuf_getline(&buf, stdin, '\n') != EOF) {
int error = batch_one_object(buf.buf, print_contents);
if (error)
}
static const char * const cat_file_usage[] = {
- "git-cat-file [-t|-s|-e|-p|<type>] <sha1>",
- "git-cat-file [--batch|--batch-check] < <list_of_sha1s>",
+ "git cat-file [-t|-s|-e|-p|<type>] <sha1>",
+ "git cat-file [--batch|--batch-check] < <list_of_sha1s>",
NULL
};
OPT_END()
};
- git_config(git_default_config);
+ git_config(git_default_config, NULL);
if (argc != 3 && argc != 2)
usage_with_options(cat_file_usage, options);