git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Cc: Junio C Hamano <gitster@pobox.com>,
	git@vger.kernel.org, Taylor Blau <me@ttaylorr.com>
Subject: Re: ab/fsck-unexpected-type (and "cat-file replace handling and optimization")
Date: Tue, 5 Oct 2021 18:01:41 -0400	[thread overview]
Message-ID: <YVzLRSa9/vUWJPL0@coredump.intra.peff.net> (raw)
In-Reply-To: <87bl43jit5.fsf@evledraar.gmail.com>

On Tue, Oct 05, 2021 at 10:47:26PM +0200, Ævar Arnfjörð Bjarmason wrote:

> > * ab/fsck-unexpected-type (2021-10-01) 17 commits
> [...]
> Note that Jeff's just-submitted cat-file series[3] will conflict with
> this, as they both adjust the same "garbage" object tests. The semantic
> conflict is minimal/none, but the textual one is probably annoying
> (e.g. his 1/5 uses a variable I split/renamed).
> 
> Jeff: Depending on what Junio thinks of queuing ab/fsck-unexpected-type
> for next what do you think about rebasing your series on top, or perhaps
> take a look at the v10[4] of it/ack it in case that helps with that (since
> you've been looking at some related code just now...).

The conflict is pretty easy to resolve: just keep my new cleanup tests,
but swap out the variable name. The combined diff is below for
reference (this is more readable than a remerge diff, but I guess a
remerge diff could actually be applied).

I don't mind rebasing on top if that's easier for Junio, but in that
case it may make sense to float the test cleanup to the front of the
series.

I can also just change mine to do the --batch-all-objects tests in a
separate repository (which is what the existing ones do). That has the
minor advantage that we know all objects in the repository, so rather
than picking out the interesting object with perl, we could generate the
full expected output.

-Peff

---
diff --cc t/t1006-cat-file.sh
index a5e7401af8,4a753705ec..0000000000
--- a/t/t1006-cat-file.sh
+++ b/t/t1006-cat-file.sh
@@@ -475,9 -332,18 +475,13 @@@ test_expect_success "Size of broken obj
  	test_cmp expect actual
  '
  
+ test_expect_success 'clean up broken object' '
 -	rm .git/objects/$(test_oid_to_path $bogus_sha1)
++	rm .git/objects/$(test_oid_to_path $bogus_short_sha1)
+ '
+ 
 -bogus_type="abcdefghijklmnopqrstuvwxyz1234679"
 -bogus_content="bogus"
 -bogus_size=$(strlen "$bogus_content")
 -bogus_sha1=$(echo_without_newline "$bogus_content" | git hash-object -t $bogus_type --literally -w --stdin)
 -
  test_expect_success "Type of broken object is correct when type is large" '
 -	echo $bogus_type >expect &&
 -	git cat-file -t --allow-unknown-type $bogus_sha1 >actual &&
 +	echo $bogus_long_type >expect &&
 +	git cat-file -t --allow-unknown-type $bogus_long_sha1 >actual &&
  	test_cmp expect actual
  '
  
@@@ -487,56 -353,8 +491,8 @@@ test_expect_success "Size of large brok
  	test_cmp expect actual
  '
  
- test_expect_success 'cat-file -t and -s on corrupt loose object' '
- 	git init --bare corrupt-loose.git &&
- 	(
- 		cd corrupt-loose.git &&
- 
- 		# Setup and create the empty blob and its path
- 		empty_path=$(git rev-parse --git-path objects/$(test_oid_to_path "$EMPTY_BLOB")) &&
- 		git hash-object -w --stdin </dev/null &&
- 
- 		# Create another blob and its path
- 		echo other >other.blob &&
- 		other_blob=$(git hash-object -w --stdin <other.blob) &&
- 		other_path=$(git rev-parse --git-path objects/$(test_oid_to_path "$other_blob")) &&
- 
- 		# Before the swap the size is 0
- 		cat >out.expect <<-EOF &&
- 		0
- 		EOF
- 		git cat-file -s "$EMPTY_BLOB" >out.actual 2>err.actual &&
- 		test_must_be_empty err.actual &&
- 		test_cmp out.expect out.actual &&
- 
- 		# Swap the two to corrupt the repository
- 		mv -f "$other_path" "$empty_path" &&
- 		test_must_fail git fsck 2>err.fsck &&
- 		grep "hash mismatch" err.fsck &&
- 
- 		# confirm that cat-file is reading the new swapped-in
- 		# blob...
- 		cat >out.expect <<-EOF &&
- 		blob
- 		EOF
- 		git cat-file -t "$EMPTY_BLOB" >out.actual 2>err.actual &&
- 		test_must_be_empty err.actual &&
- 		test_cmp out.expect out.actual &&
- 
- 		# ... since it has a different size now.
- 		cat >out.expect <<-EOF &&
- 		6
- 		EOF
- 		git cat-file -s "$EMPTY_BLOB" >out.actual 2>err.actual &&
- 		test_must_be_empty err.actual &&
- 		test_cmp out.expect out.actual &&
- 
- 		# So far "cat-file" has been happy to spew the found
- 		# content out as-is. Try to make it zlib-invalid.
- 		mv -f other.blob "$empty_path" &&
- 		test_must_fail git fsck 2>err.fsck &&
- 		grep "^error: inflate: data stream error (" err.fsck
- 	)
+ test_expect_success 'clean up broken object' '
 -	rm .git/objects/$(test_oid_to_path $bogus_sha1)
++	rm .git/objects/$(test_oid_to_path $bogus_long_sha1)
  '
  
  # Tests for git cat-file --follow-symlinks

  reply	other threads:[~2021-10-05 22:01 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-04 23:44 What's cooking in git.git (Oct 2021, #01; Mon, 4) Junio C Hamano
2021-10-04 23:52 ` Taylor Blau
2021-10-05 16:01 ` ab/refs-errno-cleanup Ævar Arnfjörð Bjarmason
2021-10-05 16:47 ` hm/paint-hits-in-log-grep Ævar Arnfjörð Bjarmason
2021-10-05 17:07 ` ab/designated-initializers-more Ævar Arnfjörð Bjarmason
2021-10-05 20:47 ` ab/fsck-unexpected-type (and "cat-file replace handling and optimization") Ævar Arnfjörð Bjarmason
2021-10-05 22:01   ` Jeff King [this message]
2021-10-06  8:54     ` Ævar Arnfjörð Bjarmason
2021-10-07 21:37     ` Junio C Hamano
2021-10-08  2:25       ` Jeff King
2021-10-08 20:50         ` Junio C Hamano
2021-10-06 10:14 ` ab/make-sparse-for-real Ævar Arnfjörð Bjarmason
2021-10-06 10:17 ` ab/parse-options-cleanup & ab/align-parse-options-help & ab/help-config-vars Ævar Arnfjörð Bjarmason
2021-10-06 16:44   ` Junio C Hamano
2021-10-06 10:26 ` ab/refs-errno-cleanup & "errno" removal in the refs backend Ævar Arnfjörð Bjarmason

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YVzLRSa9/vUWJPL0@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=me@ttaylorr.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).