git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] t5530-upload-pack-error: Check more carefully for failures.

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 6, 2007, 00:22 UTC
Message-ID
<7vve8gkyti.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<200711052240.12822.johannes.sixt@telecom.at>
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}
 
 '
 
Previous: Johannes Sixt
Message 5 of 5 in “upload-pack: Use finish_{command,async}() instead of waitpid().”
  1. upload-pack: Use finish_{command,async}() instead of waitpid().Johannes Sixt, Nov 4, 2007
  2. Michael J. CohenNov 5, 2007
  3. Junio C HamanoNov 5, 2007
  4. t5530-upload-pack-error: Check more carefully for failures.Johannes Sixt, Nov 5, 2007
  5. Junio C HamanoNov 6, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.