summaryrefslogtreecommitdiff
path: root/t/t1060-object-corruption.sh
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2013-03-25 21:49:36 (GMT)
committerJunio C Hamano <gitster@pobox.com>2013-03-27 20:47:09 (GMT)
commitd9c31e14d0aafdd45a382d01fcfd66c65a5f4b95 (patch)
treeaf3c236d6349befe9562be57255e752523aeaeba /t/t1060-object-corruption.sh
parent7b6257b0d45f562629ac660cb1845c8a2aac7df1 (diff)
downloadgit-d9c31e14d0aafdd45a382d01fcfd66c65a5f4b95.zip
git-d9c31e14d0aafdd45a382d01fcfd66c65a5f4b95.tar.gz
git-d9c31e14d0aafdd45a382d01fcfd66c65a5f4b95.tar.bz2
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>
Diffstat (limited to 't/t1060-object-corruption.sh')
-rwxr-xr-xt/t1060-object-corruption.sh25
1 files changed, 25 insertions, 0 deletions
diff --git a/t/t1060-object-corruption.sh b/t/t1060-object-corruption.sh
index c887dd8..cfd1f23 100755
--- a/t/t1060-object-corruption.sh
+++ b/t/t1060-object-corruption.sh
@@ -24,6 +24,15 @@ test_expect_success 'setup corrupt repo' '
)
'
+test_expect_success 'setup repo with missing object' '
+ git init missing &&
+ (
+ cd missing &&
+ test_commit content &&
+ rm -f "$(obj_to_file HEAD:content.t)"
+ )
+'
+
test_expect_success 'streaming a corrupt blob fails' '
(
cd bit-error &&
@@ -31,4 +40,20 @@ test_expect_success 'streaming a corrupt blob fails' '
)
'
+test_expect_success 'read-tree -u detects bit-errors in blobs' '
+ (
+ cd bit-error &&
+ rm -f content.t &&
+ test_must_fail git read-tree --reset -u HEAD
+ )
+'
+
+test_expect_success 'read-tree -u detects missing objects' '
+ (
+ cd missing &&
+ rm -f content.t &&
+ test_must_fail git read-tree --reset -u HEAD
+ )
+'
+
test_done