aboutsummaryrefslogtreecommitdiff
path: root/builtin/fsck.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2012-03-07 17:54:20 +0700
committerJunio C Hamano <gitster@pobox.com>2012-03-07 09:07:39 -0800
commit6f7f3beb2d19ab772729fc599d4a92ebf9140c5f (patch)
tree6c891a51f69667ccd12af3632e9df4a0f32c8b83 /builtin/fsck.c
parent74775a09b166fb85f5dce816548e337f11124c6b (diff)
downloadgit-6f7f3beb2d19ab772729fc599d4a92ebf9140c5f.tar.gz
git-6f7f3beb2d19ab772729fc599d4a92ebf9140c5f.tar.xz
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>
Diffstat (limited to 'builtin/fsck.c')
-rw-r--r--builtin/fsck.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/builtin/fsck.c b/builtin/fsck.c
index 67eb553c7..a710227a6 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -12,6 +12,7 @@
#include "parse-options.h"
#include "dir.h"
#include "progress.h"
+#include "streaming.h"
#define REACHABLE 0x0001
#define SEEN 0x0002
@@ -238,13 +239,8 @@ static void check_unreachable_object(struct object *obj)
if (!(f = fopen(filename, "w")))
die_errno("Could not open '%s'", filename);
if (obj->type == OBJ_BLOB) {
- enum object_type type;
- unsigned long size;
- char *buf = read_sha1_file(obj->sha1,
- &type, &size);
- if (buf && fwrite(buf, 1, size, f) != size)
+ if (stream_blob_to_fd(fileno(f), obj->sha1, NULL, 1))
die_errno("Could not write '%s'", filename);
- free(buf);
} else
fprintf(f, "%s\n", sha1_to_hex(obj->sha1));
if (fclose(f))