fsck: use streaming API for writing lost-found blobs

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Nguyễn Thái Ngọc Duy committed Mar 7, 2012 at 17:54 UTC 6f7f3beb2d19ab772729fc599d4a92ebf9140c5f
1 file changed +2 -6
builtin/fsck.c
+2 -6
@@ -12,6 +12,7 @@
12 #include "parse-options.h"
13 #include "dir.h"
14 #include "progress.h"
15 +#include "streaming.h"
16
17 #define REACHABLE 0x0001
18 #define SEEN 0x0002
@@ -238,13 +239,8 @@ static void check_unreachable_object(struct object *obj)
239 if (!(f = fopen(filename, "w")))
240 die_errno("Could not open '%s'", filename);
241 if (obj->type == OBJ_BLOB) {
241 - enum object_type type;
242 - unsigned long size;
243 - char *buf = read_sha1_file(obj->sha1,
244 - &type, &size);
245 - if (buf && fwrite(buf, 1, size, f) != size)
242 + if (stream_blob_to_fd(fileno(f), obj->sha1, NULL, 1))
243 die_errno("Could not write '%s'", filename);
247 - free(buf);
244 } else
245 fprintf(f, "%s\n", sha1_to_hex(obj->sha1));
246 if (fclose(f))