Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-09-12 05:03:38 +0400
committerJunio C Hamano <gitster@pobox.com>2011-09-12 05:03:38 +0400
commiteb726f2d760dd78915e4a24f014ab411a165daa3 (patch)
tree600d0909cc2f3ab183e603a8aec88054f39c99a2 /builtin
parent509d59705ee07094bcc56b49a17ba0ae983da50f (diff)
fsck: do not abort upon finding an empty blob
Asking fwrite() to write one item of size bytes results in fwrite() reporting "I wrote zero item", when size is zero. Instead, we could ask it to write "size" items of 1 byte and expect it to report that "I wrote size items" when it succeeds, with any value of size, including zero. Noticed and reported by BJ Hargrave. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/fsck.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/builtin/fsck.c b/builtin/fsck.c
index 5ae0366bc8..df1a88b51a 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -231,12 +231,9 @@ static void check_unreachable_object(struct object *obj)
unsigned long size;
char *buf = read_sha1_file(obj->sha1,
&type, &size);
- if (buf) {
- if (fwrite(buf, size, 1, f) != 1)
- die_errno("Could not write '%s'",
- filename);
- free(buf);
- }
+ if (buf && fwrite(buf, 1, size, f) != size)
+ die_errno("Could not write '%s'", filename);
+ free(buf);
} else
fprintf(f, "%s\n", sha1_to_hex(obj->sha1));
if (fclose(f))