git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Taylor Blau <me@ttaylorr.com>
To: Derrick Stolee <derrickstolee@github.com>
Cc: Junio C Hamano <gitster@pobox.com>,
	Derrick Stolee via GitGitGadget <gitgitgadget@gmail.com>,
	git@vger.kernel.org, chakrabortyabhradeep79@gmail.com
Subject: Re: [PATCH] test-lib-functions: fix test_subcommand_inexact
Date: Wed, 23 Mar 2022 17:45:38 -0400	[thread overview]
Message-ID: <YjuVAgjaiqrcT7P1@nand.local> (raw)
In-Reply-To: <e5331972-512a-c498-6a1b-927f21ef9de2@github.com>

On Wed, Mar 23, 2022 at 10:55:37AM -0400, Derrick Stolee wrote:
> > So, perhaps #3 ;-)?
>
> I'll default to #3 (do nothing), but if this shows up again
> I'll plan on adding a comment to the helper to be clear on
> how "inexact" the helper really is.

I wonder if we could sidestep the whole issue with
test_subcommand_inexact by testing this behavior by looking at the
contents of the packs themselves.

If we have a kept pack, and then add some new objects, and run "git
repack --write-midx -adb", the new pack should not contain any of the
objects found in the old (kept) pack. And that's the case after this
patch, but was broken before it.

Here's a test which constructs that scenario and then asserts that there
isn't any overlap between the newly created pack and the old, kept pack.

--- 8< ---

diff --git a/t/t7700-repack.sh b/t/t7700-repack.sh
index 5922fb5bdd..96812fa226 100755
--- a/t/t7700-repack.sh
+++ b/t/t7700-repack.sh
@@ -370,9 +370,31 @@ test_expect_success '--write-midx with preferred bitmap tips' '
 '

 test_expect_success '--write-midx -b packs non-kept objects' '
-	GIT_TRACE2_EVENT="$(pwd)/trace.txt" \
-		git repack --write-midx -a -b &&
-	test_subcommand_inexact git pack-objects --honor-pack-keep <trace.txt
+	git init repo &&
+	test_when_finished "rm -fr repo" &&
+	(
+		cd repo &&
+
+		test_commit base &&
+		git repack -ad &&
+
+		find $objdir/pack -name "*.idx" >before &&
+		>$objdir/pack/$(basename $(cat before) .idx).keep &&
+
+		test_commit other &&
+		git repack --write-midx -a -b -d &&
+
+		find $objdir/pack -name "*.idx" | sort >after &&
+
+		git show-index <$(cat before) >old.raw &&
+		git show-index <$(comm -13 before after) >new.raw &&
+
+		cut -d" " -f2 old.raw | sort >old.objects &&
+		cut -d" " -f2 new.raw | sort >new.objects &&
+
+		comm -12 old.objects new.objects >shared.objects &&
+		test_must_be_empty shared.objects
+	)
 '

 test_expect_success TTY '--quiet disables progress' '

--- >8 ---

It does seem a little word-y to me, but I think you could clean it up a
little bit, too. If you want to take that patch, I think we could
reasonably use the above diff as a first patch, and then remove the
declaration of test_subcommand_inexact in a second patch.

(Feel free to forge my s-o-b if you do want to pick that up).

Thanks,
Taylor

  reply	other threads:[~2022-03-23 21:45 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-21 20:34 [PATCH] test-lib-functions: fix test_subcommand_inexact Derrick Stolee via GitGitGadget
2022-03-22 15:17 ` Derrick Stolee
2022-03-23 14:53   ` Junio C Hamano
2022-03-23 14:55     ` Derrick Stolee
2022-03-23 21:45       ` Taylor Blau [this message]
2022-03-23 23:10         ` Junio C Hamano
2022-03-24 15:42           ` Derrick Stolee
2022-03-24 16:02             ` Taylor Blau
2022-03-24 16:39               ` Derrick Stolee
2022-03-24 16:38             ` Junio C Hamano
2022-03-24 18:10     ` Abhradeep Chakraborty
2022-03-25  0:33       ` Junio C Hamano
2022-03-25  8:13         ` Abhradeep Chakraborty
2022-03-24 18:34 ` [PATCH v2 0/2] " Derrick Stolee via GitGitGadget
2022-03-24 18:34   ` [PATCH v2 1/2] t7700: check post-condition in kept-pack test Derrick Stolee via GitGitGadget
2022-03-24 18:58     ` Taylor Blau
2022-03-25 13:55       ` Derrick Stolee
2022-03-25 17:07     ` Junio C Hamano
2022-03-25 17:23       ` Derrick Stolee
2022-03-25 17:36         ` Taylor Blau
2022-03-25 18:22           ` Junio C Hamano
2022-03-24 18:34   ` [PATCH v2 2/2] test-lib-functions: fix test_subcommand_inexact Derrick Stolee via GitGitGadget
2022-03-24 18:49     ` Taylor Blau
2022-03-24 20:48     ` Junio C Hamano
2022-03-25 14:03       ` Derrick Stolee
2022-03-25 17:25         ` Junio C Hamano
2022-03-25 19:02   ` [PATCH v3 0/2] " Derrick Stolee via GitGitGadget
2022-03-25 19:02     ` [PATCH v3 1/2] t7700: check post-condition in kept-pack test Derrick Stolee via GitGitGadget
2022-03-25 19:02     ` [PATCH v3 2/2] test-lib-functions: remove test_subcommand_inexact Derrick Stolee via GitGitGadget
2022-03-30  2:44     ` [PATCH v3 0/2] test-lib-functions: fix test_subcommand_inexact Taylor Blau

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=YjuVAgjaiqrcT7P1@nand.local \
    --to=me@ttaylorr.com \
    --cc=chakrabortyabhradeep79@gmail.com \
    --cc=derrickstolee@github.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=gitster@pobox.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).