Merge branch 'rs/fgrep'
[gitweb.git] / builtin-fsck.c
index aa4b239e42e8ade25cb481c4cdb55866eb37d948..5c4c77adaaba36693e304c27d1f171f8e7e9f151 100644 (file)
@@ -222,12 +222,16 @@ static void check_unreachable_object(struct object *obj)
                                char *buf = read_sha1_file(obj->sha1,
                                                &type, &size);
                                if (buf) {
-                                       fwrite(buf, size, 1, f);
+                                       if (fwrite(buf, size, 1, f) != 1)
+                                               die("Could not write %s: %s",
+                                                   filename, strerror(errno));
                                        free(buf);
                                }
                        } else
                                fprintf(f, "%s\n", sha1_to_hex(obj->sha1));
-                       fclose(f);
+                       if (fclose(f))
+                               die("Could not finish %s: %s",
+                                   filename, strerror(errno));
                }
                return;
        }