Skip to content

Commit 6f7f3be

Browse files
pcloudsgitster
authored andcommitted
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>
1 parent 74775a0 commit 6f7f3be

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

builtin/fsck.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "parse-options.h"
1313
#include "dir.h"
1414
#include "progress.h"
15+
#include "streaming.h"
1516

1617
#define REACHABLE 0x0001
1718
#define SEEN 0x0002
@@ -238,13 +239,8 @@ static void check_unreachable_object(struct object *obj)
238239
if (!(f = fopen(filename, "w")))
239240
die_errno("Could not open '%s'", filename);
240241
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))
246243
die_errno("Could not write '%s'", filename);
247-
free(buf);
248244
} else
249245
fprintf(f, "%s\n", sha1_to_hex(obj->sha1));
250246
if (fclose(f))

0 commit comments

Comments
 (0)