Git development
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Rasmus Villemoes <ravi@prevas.dk>
Cc: git@vger.kernel.org, emkan@prevas.dk
Subject: Re: git clone with --dissociate sometimes fails to check out target commit
Date: Mon, 4 May 2026 05:54:42 -0400	[thread overview]
Message-ID: <20260504095442.GA603346@coredump.intra.peff.net> (raw)
In-Reply-To: <20260504095110.GA599780@coredump.intra.peff.net>

On Mon, May 04, 2026 at 05:51:10AM -0400, Jeff King wrote:

> No, you're using it correctly. The dissociate step should copy all of
> the shared objects into the new repo, so it shouldn't matter whether we
> do it before or after checkout. The objects are there either way.
> 
> But there's an interesting bug here with commit graphs. What happens is
> this:

Oh, and ironically dissociating later _would_ fix this bug, like so:

diff --git a/builtin/clone.c b/builtin/clone.c
index fba3c9c508..7b7c83c717 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -1616,11 +1616,6 @@ int cmd_clone(int argc,
 	transport_unlock_pack(transport, 0);
 	transport_disconnect(transport);
 
-	if (option_dissociate) {
-		odb_close(the_repository->objects);
-		dissociate_from_references();
-	}
-
 	if (option_sparse_checkout && git_sparse_checkout_init(dir))
 		return 1;
 
@@ -1630,6 +1625,11 @@ int cmd_clone(int argc,
 		       filter_submodules,
 		       ref_storage_format);
 
+	if (option_dissociate) {
+		odb_close(the_repository->objects);
+		dissociate_from_references();
+	}
+
 	list_objects_filter_release(&filter_options);
 
 	string_list_clear(&option_not, 0);


But only because we are working around it: if we dissociate at the very
end, then there is no in-process code that will look at the objects
after that odb_close() call, and thus the bug cannot be triggered. It
would still potentially be lurking for other odb_close() callers,
though.

-Peff

  reply	other threads:[~2026-05-04  9:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-04  8:20 git clone with --dissociate sometimes fails to check out target commit Rasmus Villemoes
2026-05-04  9:51 ` Jeff King
2026-05-04  9:54   ` Jeff King [this message]
2026-05-04 11:36   ` Rasmus Villemoes

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=20260504095442.GA603346@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=emkan@prevas.dk \
    --cc=git@vger.kernel.org \
    --cc=ravi@prevas.dk \
    /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