Code

Merge branch 'sp/maint-index-pack' into maint
[git.git] / builtin-cat-file.c
index f8b3160668e1eeff3ef9a893459c64992aa53b5b..880e75af5e1951689a417aa47e64f99a20d46ae6 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;
 
@@ -168,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);
@@ -178,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;