From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fout-b4-smtp.messagingengine.com (fout-b4-smtp.messagingengine.com [202.12.124.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CCA1820E715 for ; Thu, 17 Jul 2025 04:57:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.147 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752728246; cv=none; b=qX3+0iyQYcGZC0QEUhw0NcDOntpcnXKWRLsnY3xbyBzjAW9rlgURwo2LMBtbZ3qZ/DFZRBKCprjWr3ZvIi2ndkoGsvpnwTt3o+ort8Nzbpb5RoJfdTqArGe1daxGUCLMG9Z8vLDmpBzuxV0uXFL6RUlxQs7FbC0uTNbNJYQBOqY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752728246; c=relaxed/simple; bh=m8yuKAweHzTQTQp3HUL863oEdh9/RqIlf4zVnoGSTec=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WkHG5tepYVnD9EmuX/lDr7q6zMBh6kSobarDdIjqu44IIzF3S6umYU6/C/3SAxa0t9e6o3q+m2tgoJMJTJhdZn67P1GfudomxVUnBaNXNwQ5pXcx9k8cZlgAHviGeRALRG2G0OxfAYhQgPWFqg1BcnbcgMQsKzKjj/dj7lI9K9U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b=ZfUit9ld; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=F6LyBjnT; arc=none smtp.client-ip=202.12.124.147 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="ZfUit9ld"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="F6LyBjnT" Received: from phl-compute-12.internal (phl-compute-12.phl.internal [10.202.2.52]) by mailfout.stl.internal (Postfix) with ESMTP id 1A21A1D001A5; Thu, 17 Jul 2025 00:57:24 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-12.internal (MEProxy); Thu, 17 Jul 2025 00:57:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc:cc :content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1752728243; x=1752814643; bh=LkOHbvh35N2bKD9DH5V4d4hqI8uXIiLwwA+MdRQH2z4=; b= ZfUit9ldg1cURlHosWmF2L+3K/eOAVXbUPOg0QC4p3E3wordB62LqAeifq2gWaii 7vfVfNjyHuFa83UX6IKyCgK1R9kjFndv6A8RIywymigJ3lE/lRap0Uem5JQmZa/1 ZhRZDLV4vIvz/T5/AOnhwETkM0kmgig0Z6KEUrY92ghm5TWugvlC1vNhoITv/BJF wc88nd4nxm+bKRohRTM+77k7zxDncWbJAVDFZS4w8Wd0okFbjQtZxjcXk7cI3HeW NTPfnhxszhFXtlOVtvo6us2GxcVAhuo0FBVEep0YcKHdOJYI33hzHNrLD5u3VTy1 DqQ9IogQX9L0Q+MktCJm5w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1752728243; x= 1752814643; bh=LkOHbvh35N2bKD9DH5V4d4hqI8uXIiLwwA+MdRQH2z4=; b=F 6LyBjnTpXoZawZDzRPZoAs6tYsKqem1pFwssbGwot6M96qhKg12Kqe4rQwXlfYYC cPxvAVeVLlSBkxMCAtKbceLNovA66qq8Nkrese196m73Z4jrFu05PNVuitwaXNn0 By3sbL6/zTpLvdSiyb+QCvkHVSUQHWA2mH6tfxwVjD7f5ZKkow40EFdZm6iwxZ0X kJfn4Lg0vaO/zpd/MJWwnyg+2ISHsYP6gsx2S1WudLXXq8vMKRYbgGbIVqzeGzi9 LHpdzxzvEjwu+LYPfYpU+98Ic4l2ThBSh3ab7G9ZjuJSDntbtyBkKMSpV18A6d4N C58u39UnHkOwfyRWm2fvA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdehleeilecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpefhfffugggtgffkfhgjvfevofesthejredtredtjeenucfhrhhomheprfgrthhrihgt khcuufhtvghinhhhrghrughtuceophhssehpkhhsrdhimheqnecuggftrfgrthhtvghrnh epffeuiedujedvkeehuedvkeefffeivdeuleetkeduheejteekgedvudfgtdfgieelnecu vehluhhsthgvrhfuihiivgepgeenucfrrghrrghmpehmrghilhhfrhhomhepphhssehpkh hsrdhimhdpnhgspghrtghpthhtohephedpmhhouggvpehsmhhtphhouhhtpdhrtghpthht ohepthhoohhnsehiohhttghlrdgtohhmpdhrtghpthhtohepghhithhsthgvrhesphhosg hogidrtghomhdprhgtphhtthhopehgihhtsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhr tghpthhtohepphhhihhllhhiphdrfihoohguuddvfeesghhmrghilhdrtghomhdprhgtph htthhopehkrghrthhhihhkrddukeeksehgmhgrihhlrdgtohhm X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 17 Jul 2025 00:57:22 -0400 (EDT) Received: by mail (OpenSMTPD) with ESMTPSA id 8e7b5cbf (TLSv1.3:TLS_CHACHA20_POLY1305_SHA256:256:NO); Thu, 17 Jul 2025 04:57:22 +0000 (UTC) From: Patrick Steinhardt Date: Thu, 17 Jul 2025 06:56:41 +0200 Subject: [PATCH v2 15/16] object-file: get rid of `the_repository` in `force_object_loose()` Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20250717-pks-object-file-wo-the-repository-v2-15-36d2cd6c700e@pks.im> References: <20250717-pks-object-file-wo-the-repository-v2-0-36d2cd6c700e@pks.im> In-Reply-To: <20250717-pks-object-file-wo-the-repository-v2-0-36d2cd6c700e@pks.im> To: git@vger.kernel.org Cc: Phillip Wood , Junio C Hamano , Karthik Nayak , Toon Claes X-Mailer: b4 0.14.2 The function `force_object_loose()` forces an object to become a loose object in case it only exists in its packed form. To do so it implicitly relies on `the_repository`. Refactor the function by passing a `struct odb_source` as parameter. While the check whether any such loose object exists already acts on the whole object database, writing the loose object happens in one specific source. Signed-off-by: Patrick Steinhardt --- builtin/pack-objects.c | 3 ++- object-file.c | 18 +++++++++--------- object-file.h | 3 ++- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index 9e85293730b..7ff79d6b376 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -4411,7 +4411,8 @@ static void loosen_unused_packed_objects(void) if (!packlist_find(&to_pack, &oid) && !has_sha1_pack_kept_or_nonlocal(&oid) && !loosened_object_can_be_discarded(&oid, p->mtime)) { - if (force_object_loose(&oid, p->mtime)) + if (force_object_loose(the_repository->objects->sources, + &oid, p->mtime)) die(_("unable to force loose object")); loosened_objects_nr++; } diff --git a/object-file.c b/object-file.c index f7c07acadc9..e9152d9e04c 100644 --- a/object-file.c +++ b/object-file.c @@ -1077,10 +1077,10 @@ int write_object_file(struct odb_source *source, return 0; } -int force_object_loose(const struct object_id *oid, time_t mtime) +int force_object_loose(struct odb_source *source, + const struct object_id *oid, time_t mtime) { - struct repository *repo = the_repository; - const struct git_hash_algo *compat = repo->compat_hash_algo; + const struct git_hash_algo *compat = source->odb->repo->compat_hash_algo; void *buf; unsigned long len; struct object_info oi = OBJECT_INFO_INIT; @@ -1090,24 +1090,24 @@ int force_object_loose(const struct object_id *oid, time_t mtime) int hdrlen; int ret; - for (struct odb_source *source = repo->objects->sources; source; source = source->next) - if (has_loose_object(source, oid)) + for (struct odb_source *s = source->odb->sources; s; s = s->next) + if (has_loose_object(s, oid)) return 0; oi.typep = &type; oi.sizep = &len; oi.contentp = &buf; - if (odb_read_object_info_extended(the_repository->objects, oid, &oi, 0)) + if (odb_read_object_info_extended(source->odb, oid, &oi, 0)) return error(_("cannot read object for %s"), oid_to_hex(oid)); if (compat) { - if (repo_oid_to_algop(repo, oid, compat, &compat_oid)) + if (repo_oid_to_algop(source->odb->repo, oid, compat, &compat_oid)) return error(_("cannot map object %s to %s"), oid_to_hex(oid), compat->name); } hdrlen = format_object_header(hdr, sizeof(hdr), type, len); - ret = write_loose_object(repo->objects->sources, oid, hdr, hdrlen, buf, len, mtime, 0); + ret = write_loose_object(source, oid, hdr, hdrlen, buf, len, mtime, 0); if (!ret && compat) - ret = repo_add_loose_object_map(the_repository->objects->sources, oid, &compat_oid); + ret = repo_add_loose_object_map(source, oid, &compat_oid); free(buf); return ret; diff --git a/object-file.h b/object-file.h index 52f7979267d..15d97630d3b 100644 --- a/object-file.h +++ b/object-file.h @@ -161,7 +161,8 @@ int stream_loose_object(struct odb_source *source, struct input_stream *in_stream, size_t len, struct object_id *oid); -int force_object_loose(const struct object_id *oid, time_t mtime); +int force_object_loose(struct odb_source *source, + const struct object_id *oid, time_t mtime); /** * With in-core object data in "buf", rehash it to make sure the -- 2.50.1.465.gcb3da1c9e6.dirty