From: Patrick Steinhardt <ps@pks.im>
To: Jeff King <peff@peff.net>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH v2] builtin/repack: fix `--keep-unreachable` when there are no packs
Date: Wed, 5 Feb 2025 06:36:04 +0100 [thread overview]
Message-ID: <Z6L4xDMqc6aXEA8A@pks.im> (raw)
In-Reply-To: <20250204152236.GB620055@coredump.intra.peff.net>
On Tue, Feb 04, 2025 at 10:22:36AM -0500, Jeff King wrote:
> On Tue, Feb 04, 2025 at 08:00:41AM +0100, Patrick Steinhardt wrote:
>
> > this small patch series fixes `git repack -ad --keep-unreachable` when
> > there aren't any preexisting packfiles.
> >
> > Changes in v2:
> > - Merge tests into t7701.
> > - Link to v1: https://lore.kernel.org/r/20250203-b4-pks-repack-unreachable-objects-wo-packfiles-v1-0-7c4d69c5072c@pks.im
>
> This looks good to me.
>
> One interesting thing I did notice:
>
> > +test_expect_success 'repack -k packs unreachable loose objects without existing packfiles' '
> > + test_when_finished "rm -rf repo" &&
> > + git init repo &&
> > + (
> > + cd repo &&
> > +
> > + oid=$(echo would-be-deleted-loose | git hash-object -w --stdin) &&
> > + objpath=.git/objects/$(echo $sha1 | sed "s,..,&/,") &&
> > + test_path_is_file $objpath &&
> > +
> > + git repack -ad --keep-unreachable &&
> > + test_path_is_missing $objpath &&
> > + git cat-file -p $oid
> > + )
> > +'
>
> In the test in v1, we had reachable commits to pack. And here we don't.
> So before your patch, the behavior in the v1 test was that we'd create a
> new pack, but it wouldn't pick up the loose object. But the behavior of
> this test is that we say "Nothing new to pack".
>
> I originally thought that output meant that we were not running
> pack-objects at all. But looking at builtin/repack.c, we do run it, and
> it simply chooses not to make a pack (which makes sense; how would
> repack even realize if there was stuff to pack, since pack-objects is
> what does the traversal).
>
> So the two outcomes are both the result of the same bug. In both cases
> we do not correctly pack the loose objects, so whether we make a pack is
> just a question of whether there was other reachable stuff to pack. And
> since your patch is fixing the bug at its root, both outcomes are fixed.
>
> And when I suggested in my response to v1 that "Nothing new to pack" in
> an empty repo was a separate bug, I was just wrong. ;) There is nothing
> else to fix after your patch.
>
> Thanks for finding and fixing.
Thanks for your thorough review!
Patrick
prev parent reply other threads:[~2025-02-05 5:36 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-03 13:06 [PATCH 0/2] builtin/repack: fix `--keep-unreachable` when there are no packs Patrick Steinhardt
2025-02-03 13:06 ` [PATCH 1/2] t7700: add tests for `--keep-unreachable` Patrick Steinhardt
2025-02-03 17:13 ` Junio C Hamano
2025-02-03 18:32 ` Jeff King
2025-02-03 23:53 ` Junio C Hamano
2025-02-04 2:35 ` Jeff King
2025-02-04 7:00 ` Patrick Steinhardt
2025-02-03 13:06 ` [PATCH 2/2] builtin/repack: fix `--keep-unreachable` when there are no packs Patrick Steinhardt
2025-02-04 3:01 ` Jeff King
2025-02-04 7:01 ` Patrick Steinhardt
2025-02-04 14:58 ` Jeff King
2025-02-04 13:28 ` Junio C Hamano
2025-02-04 7:00 ` [PATCH v2] " Patrick Steinhardt
2025-02-04 15:22 ` Jeff King
2025-02-05 5:36 ` Patrick Steinhardt [this message]
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=Z6L4xDMqc6aXEA8A@pks.im \
--to=ps@pks.im \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=peff@peff.net \
/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).