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

Re: [PATCH 2/2] builtin/repack: fix `--keep-unreachable` when there are no packs

From
Patrick Steinhardt <ps@pks.im>
Date
Feb 4, 2025, 07:01 UTC
Message-ID
<Z6G7LTVqw3l-b7lN@pks.im>
In-Reply-To
<20250204030157.GC23954@coredump.intra.peff.net>
On Mon, Feb 03, 2025 at 10:01:57PM -0500, Jeff King wrote:
Show 14 quoted lines
> On Mon, Feb 03, 2025 at 02:06:55PM +0100, Patrick Steinhardt wrote:
> > Fix the bug by splitting out the "--pack-loose-unreachable" and only
> > making it depend on the second and third condition. Like this, loose
> > unreachable objects will be packed regardless of any preexisting
> > packfiles.
> 
> Makes sense. My only question would be whether there are any gotchas
> inside pack-objects about using --pack-loose-unreachable without
> --keep-unreachable (since the two were up until now always used
> together).
> 
> It was added by e26a8c4721. And looking over that patch, I don't see
> anything that would let the options be used independently. So this seems
> like a good solution.

You probably meant "I don't see anything that would *not* let the options be used independently." But yeah, they don't seem to require one another.

Show 23 quoted lines
> > diff --git a/builtin/repack.c b/builtin/repack.c
> > index 81d13630ea..8194344b04 100644
> > --- a/builtin/repack.c
> > +++ b/builtin/repack.c
> > @@ -1370,9 +1370,12 @@ int cmd_repack(int argc,
> >  					    "--unpack-unreachable");
> >  			} else if (keep_unreachable) {
> >  				strvec_push(&cmd.args, "--keep-unreachable");
> > -				strvec_push(&cmd.args, "--pack-loose-unreachable");
> >  			}
> >  		}
> > +
> > +		if (keep_unreachable && delete_redundant &&
> > +		    !(pack_everything & PACK_CRUFT))
> > +			strvec_push(&cmd.args, "--pack-loose-unreachable");
> 
> One funny thing here is that previously unpack_unreachable took
> precedence over keep_unreachable in the if-else chain. I wondered if we
> could end up invoking pack-objects with both --unpack-unreachable and
> --pack-loose-unreachable, which is nonsense.
> 
> But I think the answer is no, because we forbid --unpack-unreachable/-A
> and --keep-unreachable from both being passed up front.
Yup.
Show 10 quoted lines
> > -test_expect_failure '--keep-unreachable packs unreachable loose object without existing packs' '
> > +test_expect_success '--keep-unreachable packs unreachable loose object without existing packs' '
> >  	test_when_finished "rm -rf repo" &&
> >  	git init repo &&
> >  	(
> 
> Your test from patch 1 looked reasonable to me. If you fold patch 1 into
> the existing tests in t7701, you might want to adjust it to match the
> techniques those tests use for checking the object (rather than the new
> helpers you added).
Will do.
Thanks!
Patrick
Previous: Jeff KingNext: Jeff King
Message 4 of 15 in “builtin/repack: fix `--keep-unreachable` when there are no packs”
  1. 0/2 builtin/repack: fix `--keep-unreachable` when there are no packsPatrick Steinhardt, Feb 3, 2025
  2. 2/2 builtin/repack: fix `--keep-unreachable` when there are no packsPatrick Steinhardt, Feb 3, 2025
  3. Jeff KingFeb 4, 2025
  4. Patrick SteinhardtFeb 4, 2025
  5. Jeff KingFeb 4, 2025
  6. Junio C HamanoFeb 4, 2025
  7. 1/2 t7700: add tests for `--keep-unreachable`Patrick Steinhardt, Feb 3, 2025
  8. Junio C HamanoFeb 3, 2025
  9. Jeff KingFeb 3, 2025
  10. Junio C HamanoFeb 3, 2025
  11. Jeff KingFeb 4, 2025
  12. Patrick SteinhardtFeb 4, 2025
  13. builtin/repack: fix `--keep-unreachable` when there are no packsPatrick Steinhardt, Feb 4, 2025
  14. Jeff KingFeb 4, 2025
  15. Patrick SteinhardtFeb 5, 2025

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.