streaming_write_entry: propagate streaming errors
commitd9c31e14d0aafdd45a382d01fcfd66c65a5f4b95
authorJeff King <peff@peff.net>
Mon, 25 Mar 2013 21:49:36 +0000 (25 17:49 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 27 Mar 2013 20:47:09 +0000 (27 13:47 -0700)
treeaf3c236d6349befe9562be57255e752523aeaeba
parent7b6257b0d45f562629ac660cb1845c8a2aac7df1
streaming_write_entry: propagate streaming errors

When we are streaming an index blob to disk, we store the
error from stream_blob_to_fd in the "result" variable, and
then immediately overwrite that with the return value of
"close". That means we catch errors on close (e.g., problems
committing the file to disk), but miss anything which
happened before then.

We can fix this by using bitwise-OR to accumulate errors in
our result variable.

While we're here, we can also simplify the error handling
with an early return, which makes it easier to see under
which circumstances we need to clean up.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
entry.c
t/t1060-object-corruption.sh