From: Junio C Hamano <gitster@pobox.com>
To: Taylor Blau <me@ttaylorr.com>
Cc: git@vger.kernel.org, Derrick Stolee <derrickstolee@github.com>,
Jeff King <peff@peff.net>,
Johannes Schindelin <Johannes.Schindelin@gmx.de>,
Victoria Dye <vdye@github.com>
Subject: Re: [PATCH 1/2] builtin/repack.c: only repack `.pack`s that exist
Date: Mon, 10 Jul 2023 13:09:50 -0700 [thread overview]
Message-ID: <xmqqedlf4jg1.fsf@gitster.g> (raw)
In-Reply-To: <f14a88f1075093c870cd1d53b4e0cea10d5ab67d.1689017830.git.me@ttaylorr.com> (Taylor Blau's message of "Mon, 10 Jul 2023 15:37:15 -0400")
Taylor Blau <me@ttaylorr.com> writes:
> Add a check to see if the .pack file exists before adding it to the list
> for repacking. This will stop a number of maintenance failures seen in
> production but fixed by deleting the .idx files.
When we are adding we'd eventually add both and something that lack
one of them will eventually become complete and will be part of the
repacking once that happens. When we are removing (because another
repack has about to finish), removing either one of them will make
the pack ineligible, which is OK. If somebody crashed while adding
or removing and ended up leaving only one, not both, on the
filesystem, ignoring such a leftover stuff would be the least
disruptive for automation. Makes sense.
> diff --git a/t/t7700-repack.sh b/t/t7700-repack.sh
> index af79266c58..284954791d 100755
> --- a/t/t7700-repack.sh
> +++ b/t/t7700-repack.sh
> @@ -213,16 +213,16 @@ test_expect_success 'repack --keep-pack' '
> test_create_repo keep-pack &&
> (
> cd keep-pack &&
> - # avoid producing difference packs to delta/base choices
> + # avoid producing different packs due to delta/base choices
OK.
> git config pack.window 0 &&
> P1=$(commit_and_pack 1) &&
> P2=$(commit_and_pack 2) &&
> P3=$(commit_and_pack 3) &&
> P4=$(commit_and_pack 4) &&
> - ls .git/objects/pack/*.pack >old-counts &&
> + find .git/objects/pack -name "*.pack" -type f | sort >old-counts &&
> test_line_count = 4 old-counts &&
> git repack -a -d --keep-pack $P1 --keep-pack $P4 &&
> - ls .git/objects/pack/*.pack >new-counts &&
> + find .git/objects/pack -name "*.pack" -type f | sort >new-counts &&
> grep -q $P1 new-counts &&
> grep -q $P4 new-counts &&
> test_line_count = 3 new-counts &&
I do not think "sort" in both of these added lines is doing anything
useful. Does the test break without this hunk and if so how?
> @@ -239,14 +239,51 @@ test_expect_success 'repack --keep-pack' '
> mv "$from" "$to" || return 1
> done &&
>
> + # A .idx file without a .pack should not stop us from
> + # repacking what we can.
> + touch .git/objects/pack/pack-does-not-exist.idx &&
>.git/objects/pack/pack-does-not-exist.idx &&
> + find .git/objects/pack -name "*.pack" -type f | sort >packs.before &&
> git repack --cruft -d --keep-pack $P1 --keep-pack $P4 &&
> + find .git/objects/pack -name "*.pack" -type f | sort >packs.after &&
>
> - ls .git/objects/pack/*.pack >newer-counts &&
> - test_cmp new-counts newer-counts &&
> + test_cmp packs.before packs.after &&
I'd say the changes from "ls" to "find" in the earlier hunk is
excusable in the name of consistency with this updated on, if the
use of "sort" matters in this hunk, but as "ls" gives a consistent
output unless you say "ls (-U|--sort=none)", I am not sure if we
need "sort" in this hunk, either. So, I dunno.
"before vs after" does look like an improvement over "new vs newer".
> +test_expect_success 'repacking fails when missing .pack actually means missing objects' '
> + test_create_repo idx-without-pack &&
> + (
> + cd idx-without-pack &&
> +
> + # Avoid producing different packs due to delta/base choices
> + git config pack.window 0 &&
> + P1=$(commit_and_pack 1) &&
> + P2=$(commit_and_pack 2) &&
> + P3=$(commit_and_pack 3) &&
> + P4=$(commit_and_pack 4) &&
> + find .git/objects/pack -name "*.pack" -type f | sort >old-counts &&
> + test_line_count = 4 old-counts &&
> +
> + # Remove one .pack file
> + rm .git/objects/pack/$P2 &&
> +
> + find .git/objects/pack -name "*.pack" -type f |
> + sort >before-pack-dir &&
> +
> + test_must_fail git fsck &&
> + test_must_fail git repack --cruft -d 2>err &&
> + grep "bad object" err &&
> +
> + # Before failing, the repack did not modify the
> + # pack directory.
> + find .git/objects/pack -name "*.pack" -type f |
> + sort >after-pack-dir &&
> + test_cmp before-pack-dir after-pack-dir
> + )
> +'
Ditto for the use of "find | sort" vs "ls", but otherwise it looks
like it is testing the right thing.
Thanks.
next prev parent reply other threads:[~2023-07-10 20:09 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-10 19:37 [PATCH 0/2] repack: make `collect_pack_filenames()` consistent Taylor Blau
2023-07-10 19:37 ` [PATCH 1/2] builtin/repack.c: only repack `.pack`s that exist Taylor Blau
2023-07-10 20:09 ` Junio C Hamano [this message]
2023-07-11 17:28 ` Taylor Blau
2023-07-10 19:37 ` [PATCH 2/2] builtin/repack.c: avoid dir traversal in `collect_pack_filenames()` Taylor Blau
2023-07-10 21:35 ` Junio C Hamano
2023-07-11 17:29 ` Taylor Blau
2023-07-11 17:32 ` [PATCH v2 0/2] repack: make `collect_pack_filenames()` consistent Taylor Blau
2023-07-11 17:32 ` [PATCH v2 1/2] builtin/repack.c: only repack `.pack`s that exist Taylor Blau
2023-07-11 17:32 ` [PATCH v2 2/2] builtin/repack.c: avoid dir traversal in `collect_pack_filenames()` 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqedlf4jg1.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=derrickstolee@github.com \
--cc=git@vger.kernel.org \
--cc=me@ttaylorr.com \
--cc=peff@peff.net \
--cc=vdye@github.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.
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 NNTP newsgroup(s).