зеркало из https://github.com/microsoft/git.git
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>
This commit is contained in:
Родитель
509d59705e
Коммит
eb726f2d76
|
@ -231,12 +231,9 @@ static void check_unreachable_object(struct object *obj)
|
||||||
unsigned long size;
|
unsigned long size;
|
||||||
char *buf = read_sha1_file(obj->sha1,
|
char *buf = read_sha1_file(obj->sha1,
|
||||||
&type, &size);
|
&type, &size);
|
||||||
if (buf) {
|
if (buf && fwrite(buf, 1, size, f) != size)
|
||||||
if (fwrite(buf, size, 1, f) != 1)
|
die_errno("Could not write '%s'", filename);
|
||||||
die_errno("Could not write '%s'",
|
free(buf);
|
||||||
filename);
|
|
||||||
free(buf);
|
|
||||||
}
|
|
||||||
} else
|
} else
|
||||||
fprintf(f, "%s\n", sha1_to_hex(obj->sha1));
|
fprintf(f, "%s\n", sha1_to_hex(obj->sha1));
|
||||||
if (fclose(f))
|
if (fclose(f))
|
||||||
|
|
Загрузка…
Ссылка в новой задаче