Code

commit, merge: initialize static strbuf
[git.git] / builtin-cat-file.c
index 5ef15a4fa9eac952db105376ec6a10b706b3cbb2..7441a56acdbefdd8044a406f4d756ce8a4f06644 100644 (file)
@@ -150,7 +150,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
 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;
 
@@ -159,6 +159,7 @@ static int batch_one_object(const char *obj_name, int print_contents)
 
        if (get_sha1(obj_name, sha1)) {
                printf("%s missing\n", obj_name);
+               fflush(stdout);
                return 0;
        }
 
@@ -167,8 +168,11 @@ static int batch_one_object(const char *obj_name, int print_contents)
        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);
@@ -177,6 +181,7 @@ static int batch_one_object(const char *obj_name, int print_contents)
                write_or_die(1, contents, size);
                printf("\n");
                fflush(stdout);
+               free(contents);
        }
 
        return 0;
@@ -197,8 +202,8 @@ static int batch_objects(int print_contents)
 }
 
 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
 };
 
@@ -222,7 +227,7 @@ int cmd_cat_file(int argc, const char **argv, const char *prefix)
                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);