Re: [PATCH] t5530-upload-pack-error: Check more carefully for failures.
Johannes Sixt <johannes.sixt@telecom.at> writes:
Show 11 quoted lines
> On Monday 05 November 2007 21:05, Junio C Hamano wrote:
> > > The test case checks for failures in rev-list (a missing
> > > object). Any hints how to trigger a failure in pack-objects
> > > that does not also trigger in rev-list would be welcome.
> >
> > How about removing a blob from the test repository to corrupt
> > it? rev-list --objects I think would happily list the blob
> > because it sees its name in its containing tree without checking
> > its existence.
>
> That does it. This goes on top of my previous patch.
Thanks. Will squash with further changes attached for readability.
---
t/t5530-upload-pack-error.sh | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/t/t5530-upload-pack-error.sh b/t/t5530-upload-pack-error.sh
index 70d4f86..cc8949e 100755
--- a/t/t5530-upload-pack-error.sh
+++ b/t/t5530-upload-pack-error.sh
@@ -6,6 +6,13 @@ test_description='errors in upload-pack'
D=`pwd`
+corrupt_repo () {
+ object_sha1=$(git rev-parse "$1") &&
+ ob=$(expr "$object_sha1" : "\(..\)") &&
+ ject=$(expr "$object_sha1" : "..\(..*\)") &&
+ rm -f ".git/objects/$ob/$ject"
+}
+
test_expect_success 'setup and corrupt repository' '
echo file >file &&
@@ -15,7 +22,7 @@ test_expect_success 'setup and corrupt repository' '
test_tick &&
echo changed >file &&
git commit -a -m changed &&
- rm -f .git/objects/5e/a2ed416fbd4a4cbe227b75fe255dd7fa6bd4d6
+ corrupt_repo HEAD:file
'
@@ -35,7 +42,7 @@ test_expect_success 'upload-pack fails due to error in pack-objects' '
test_expect_success 'corrupt repo differently' '
git hash-object -w file &&
- rm -f .git/objects/be/c63e37d08c454ad3a60cde90b70f3f7d077852
+ corrupt_repo HEAD^^{tree}
'