From patchwork Tue Jul 30 05:22:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13746670 Received: from fhigh8-smtp.messagingengine.com (fhigh8-smtp.messagingengine.com [103.168.172.159]) (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 BA09C169AE6 for ; Tue, 30 Jul 2024 05:22:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.159 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722316972; cv=none; b=I0GNsQwYy4FpK4gzAba7pYmvZMkGdlWxYYKxFL7Gzc/FMo8NxEn8qBOuFsaeY7/XynBfY1+6EEXl/ytlfHSX+qosx9DgDyke271/Sa8jtts+WE9Hsktl5BvkKE8f0r0yIwXloKiWiygUJsM7vcjvRE/eAcnKee5avxEzTxJLSPs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722316972; c=relaxed/simple; bh=e/a5iOlmKSZOwDKftKEiLcxb8JPNrLOyhG04yqIazZY=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Z4sa2ZDqSDDpVkNK+5GjbxUEaFi+tFz0NTE7PPCOtaaRk0xy1KkYll2fPlh7hiB71lBq8/PldpVXTh9Vh4/2REQT6iZLJuvVQYe1RQtxsrau+smCyVCs54aa8yYwF3P6mWCbg6QEmI9IpnlIAIx/fR4hI792lnsS4oTyZ4YPqmw= 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=dzcxDQIv; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=jmnVB+Gc; arc=none smtp.client-ip=103.168.172.159 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="dzcxDQIv"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="jmnVB+Gc" Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailfhigh.nyi.internal (Postfix) with ESMTP id CF653114046B for ; Tue, 30 Jul 2024 01:22:49 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Tue, 30 Jul 2024 01:22:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc :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=fm3; t=1722316969; x=1722403369; bh=7MWSQs4DbQ aPlrobgGvb2tFjXlVw51dA63CfXka5VYo=; b=dzcxDQIvtyU3g2w8lb2k5OiBLo wq/uYYgqNw3uPG5kFZBzltY0yFayag/IUpAfF/37uTuBzvV4y0gORQIcXHTYQZC/ U+bguo6+WkMKwO5qSjhs4gV4v7VgKoYnPG9lnVKDYyFDDurgSe1aH8F3sRR+H2CP zwf3f14AHz8KceuYH4Ldb+TQAzhcylkIF7BLG/XuNUTj1YEC1VZpwY5/SaDjoCGw bFIXmDsWyqNdu+oCVubuC8HJRjwwvmTz33E9BHcSNdNqMiu7G8j1WPQgMBpWhG3D xeyfFS74pFYDF9tnfA6Ja1w5RMQnn3sjO2LkOAxeNE06lQQmbMoldGUJlsfA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc: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-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1722316969; x=1722403369; bh=7MWSQs4DbQaPlrobgGvb2tFjXlVw 51dA63CfXka5VYo=; b=jmnVB+Gcbhh1ZpLktdektnkzeBcKxhqRPyCUbKaql1HV qneUPABvar4zzxBx2m2ZSOLgaFWtyEpFBuf0zvabEAMEiMHujexM/85xMF7xN5TX dCVpiMAEkaJvPJagWDEwriAyYv3YBrsF/AA512E4AyFGZXWhFvnZFnS6PShkSIE5 z/yExZBlLsipDG8iZI6SOMKvjQ7IhTdmTLoYrNjtGPY51hVfSlnNNMd6ZfefsLhu KiFu3uDsXU4QFCfRw0iJEuOti/VvQloeHy+rpPDzcJmQg4dgE28QnKdSf0vk1Uz/ OlyPi14ImsK0s1/it70/xT/JPIYkfO9QQnwIVldwvA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrjeefgdeljecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepfffhvffukfhfgggtuggjsehgtderre dttddvnecuhfhrohhmpefrrghtrhhitghkucfuthgvihhnhhgrrhguthcuoehpshesphhk shdrihhmqeenucggtffrrghtthgvrhhnpeehgefhtdefueffheekgfffudelffejtdfhvd ejkedthfehvdelgfetgfdvtedthfenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgr mhepmhgrihhlfhhrohhmpehpshesphhkshdrihhmpdhnsggprhgtphhtthhopedt X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Tue, 30 Jul 2024 01:22:49 -0400 (EDT) Received: by localhost (OpenSMTPD) with ESMTPSA id 54e86b30 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Tue, 30 Jul 2024 05:21:22 +0000 (UTC) Date: Tue, 30 Jul 2024 07:22:46 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Subject: [PATCH 1/5] refs: stop using `the_repository` Message-ID: <482a06560a6e6aa27469b355e8c81034a8867a40.1722316795.git.ps@pks.im> References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Convert "refs.c" to stop using `the_repository` in favor of the repo that gets passed in via `struct ref_store`. Signed-off-by: Patrick Steinhardt --- refs.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/refs.c b/refs.c index 915aeb4d1d..94a41934d6 100644 --- a/refs.c +++ b/refs.c @@ -2,8 +2,6 @@ * The backend-independent part of the reference module. */ -#define USE_THE_REPOSITORY_VARIABLE - #include "git-compat-util.h" #include "advice.h" #include "config.h" @@ -1838,7 +1836,7 @@ const char *refs_resolve_ref_unsafe(struct ref_store *refs, failure_errno != ENOTDIR) return NULL; - oidclr(oid, the_repository->hash_algo); + oidclr(oid, refs->repo->hash_algo); if (*flags & REF_BAD_NAME) *flags |= REF_ISBROKEN; return refname; @@ -1848,7 +1846,7 @@ const char *refs_resolve_ref_unsafe(struct ref_store *refs, if (!(read_flags & REF_ISSYMREF)) { if (*flags & REF_BAD_NAME) { - oidclr(oid, the_repository->hash_algo); + oidclr(oid, refs->repo->hash_algo); *flags |= REF_ISBROKEN; } return refname; @@ -1856,7 +1854,7 @@ const char *refs_resolve_ref_unsafe(struct ref_store *refs, refname = sb_refname.buf; if (resolve_flags & RESOLVE_REF_NO_RECURSE) { - oidclr(oid, the_repository->hash_algo); + oidclr(oid, refs->repo->hash_algo); return refname; } if (check_refname_format(refname, REFNAME_ALLOW_ONELEVEL)) { @@ -2011,7 +2009,7 @@ struct ref_store *repo_get_submodule_ref_store(struct repository *repo, free(subrepo); goto done; } - refs = ref_store_init(subrepo, the_repository->ref_storage_format, + refs = ref_store_init(subrepo, repo->ref_storage_format, submodule_sb.buf, REF_STORE_READ | REF_STORE_ODB); register_ref_store_map(&repo->submodule_ref_stores, "submodule", @@ -2045,7 +2043,7 @@ struct ref_store *get_worktree_ref_store(const struct worktree *wt) common_path.buf, REF_STORE_ALL_CAPS); strbuf_release(&common_path); } else { - refs = ref_store_init(wt->repo, the_repository->ref_storage_format, + refs = ref_store_init(wt->repo, wt->repo->ref_storage_format, wt->repo->commondir, REF_STORE_ALL_CAPS); } From patchwork Tue Jul 30 05:22:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13746671 Received: from fhigh8-smtp.messagingengine.com (fhigh8-smtp.messagingengine.com [103.168.172.159]) (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 8AD9318FC87 for ; Tue, 30 Jul 2024 05:22:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.159 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722316979; cv=none; b=GBDoijMZkuRitdfkRu8TLCHOruOfaaBBxbEzikhuZNPvlNpBXF/UR0zfH543te8LsBxxarDzO71T8irJntRdK6nrayDo2X9tUF5attTpD+BKhBTu0dDxFNqyuJtBzH1C5vX5gzfmKnUtA4z9vMG+1noHEgf9eRBabsW4SXXBDDQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722316979; c=relaxed/simple; bh=06DN0cQvCX/xgSQDtLHHFMLnRtBy5XEcKO5VpcKUCII=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=SjtFUzUZZO+gfgSXaNgYJmcHclTAnUJGRSyKPQyqDeczYXsMTgl5BvMbsonzFsUYTtSYI6J/gHFBMUit2KzSyrfk04z+jHJpkzTa5TSBCv4zoFCQi4E1B/+aPogiSyyBrzcDVNzNZ36WmuA93wdqtILejfx/fOFKeTWomz8/a7o= 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=f2JFKXAu; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=q38+0oPB; arc=none smtp.client-ip=103.168.172.159 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="f2JFKXAu"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="q38+0oPB" Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailfhigh.nyi.internal (Postfix) with ESMTP id A87CD1140446 for ; Tue, 30 Jul 2024 01:22:55 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Tue, 30 Jul 2024 01:22:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc :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=fm3; t=1722316975; x=1722403375; bh=yTfldErJG5 GJEWbje7S4kXAOi2S++ydZ/lnt3D8e/kc=; b=f2JFKXAuLkbsnuR8CGdSKU4kKH x4ULNbXfZaCI2ZtUCeUmzmsj7VbCgPgglfvcK4V5stJwEZ2rbyMAfoyMYNzaEYUS btujj2EKWvrzDhfCLyeP9IRHJV0XJe7h5xt8eWQZVocq5nHx/TjFzADZCWrcvVUC hMbQqAOGfmIe4n7nirZPiGIV8sccE37ugPpV8KuehOr/pkC2YKnlHupU2WqbpC5c IpXFKExsbxJCI7bZBdd+iBQfmftV0eB/WrCTJnTe40jEY7dEwsaffe5lAYgEbI/e GZWYdB34IGyPVH9PKzC7YhI52y0aUpEGaRVwqCiZY6dGEOqAryyHsOnn8Nxg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc: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-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1722316975; x=1722403375; bh=yTfldErJG5GJEWbje7S4kXAOi2S+ +ydZ/lnt3D8e/kc=; b=q38+0oPBanuYyOsxOE+RlrMAweBOzo7x+Pc0CRetohh/ SRzNziFw8uOnLIyKjK/hwtRXFdf2WvsAZ5VCmkwmhYxaO7OrHVCUrcfFYWbknrJY VNrkBOtFej5SmpFNNaZDKWSnhY1a/W1SBRiOesZQ4netLOOSM3rDvi2hbg8QZz22 nNfbD/hRDuGvhyR+zE14fj++pS+ktVWM9OfAOcP3ld5HUxG3g5+0V/sqEJvF8ZQZ ECbQ0hitvvPzjsIDA8BuIVHhUKz9/5XbVIiTMz5jEiJVoA1irIeTl7CVKdmyp5CM LUgz9M/OGaNZNbsyx68XFFVWL0JkokIQFOove0Jgig== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrjeefgdeljecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepfffhvffukfhfgggtuggjsehgtderre dttddvnecuhfhrohhmpefrrghtrhhitghkucfuthgvihhnhhgrrhguthcuoehpshesphhk shdrihhmqeenucggtffrrghtthgvrhhnpeehgefhtdefueffheekgfffudelffejtdfhvd ejkedthfehvdelgfetgfdvtedthfenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgr mhepmhgrihhlfhhrohhmpehpshesphhkshdrihhmpdhnsggprhgtphhtthhopedt X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Tue, 30 Jul 2024 01:22:54 -0400 (EDT) Received: by localhost (OpenSMTPD) with ESMTPSA id 74b07d38 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Tue, 30 Jul 2024 05:21:26 +0000 (UTC) Date: Tue, 30 Jul 2024 07:22:51 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Subject: [PATCH 2/5] refs/files: stop using `the_repository` in `parse_loose_ref_contents()` Message-ID: References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: We implicitly rely on `the_repository` in `parse_loose_ref_contents()` by calling `parse_oid_hex()`. Convert the function to instead use `parse_oid_hex_algop()` and have callers pass in the hash algorithm to use. Signed-off-by: Patrick Steinhardt --- refs.c | 4 ++-- refs/files-backend.c | 21 ++++++++++++--------- refs/refs-internal.h | 3 ++- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/refs.c b/refs.c index 94a41934d6..e082fc59b0 100644 --- a/refs.c +++ b/refs.c @@ -1752,8 +1752,8 @@ static int refs_read_special_head(struct ref_store *ref_store, goto done; } - result = parse_loose_ref_contents(content.buf, oid, referent, type, - failure_errno); + result = parse_loose_ref_contents(ref_store->repo->hash_algo, content.buf, + oid, referent, type, failure_errno); done: strbuf_release(&full_path); diff --git a/refs/files-backend.c b/refs/files-backend.c index aa52d9be7c..3437c79699 100644 --- a/refs/files-backend.c +++ b/refs/files-backend.c @@ -552,7 +552,8 @@ static int read_ref_internal(struct ref_store *ref_store, const char *refname, strbuf_rtrim(&sb_contents); buf = sb_contents.buf; - ret = parse_loose_ref_contents(buf, oid, referent, type, &myerr); + ret = parse_loose_ref_contents(ref_store->repo->hash_algo, buf, + oid, referent, type, &myerr); out: if (ret && !myerr) @@ -586,7 +587,8 @@ static int files_read_symbolic_ref(struct ref_store *ref_store, const char *refn return !(type & REF_ISSYMREF); } -int parse_loose_ref_contents(const char *buf, struct object_id *oid, +int parse_loose_ref_contents(const struct git_hash_algo *algop, + const char *buf, struct object_id *oid, struct strbuf *referent, unsigned int *type, int *failure_errno) { @@ -604,7 +606,7 @@ int parse_loose_ref_contents(const char *buf, struct object_id *oid, /* * FETCH_HEAD has additional data after the sha. */ - if (parse_oid_hex(buf, oid, &p) || + if (parse_oid_hex_algop(buf, oid, &p, algop) || (*p != '\0' && !isspace(*p))) { *type |= REF_ISBROKEN; *failure_errno = EINVAL; @@ -1998,7 +2000,8 @@ static int files_delete_reflog(struct ref_store *ref_store, return ret; } -static int show_one_reflog_ent(struct strbuf *sb, each_reflog_ent_fn fn, void *cb_data) +static int show_one_reflog_ent(struct files_ref_store *refs, struct strbuf *sb, + each_reflog_ent_fn fn, void *cb_data) { struct object_id ooid, noid; char *email_end, *message; @@ -2008,8 +2011,8 @@ static int show_one_reflog_ent(struct strbuf *sb, each_reflog_ent_fn fn, void *c /* old SP new SP name SP time TAB msg LF */ if (!sb->len || sb->buf[sb->len - 1] != '\n' || - parse_oid_hex(p, &ooid, &p) || *p++ != ' ' || - parse_oid_hex(p, &noid, &p) || *p++ != ' ' || + parse_oid_hex_algop(p, &ooid, &p, refs->base.repo->hash_algo) || *p++ != ' ' || + parse_oid_hex_algop(p, &noid, &p, refs->base.repo->hash_algo) || *p++ != ' ' || !(email_end = strchr(p, '>')) || email_end[1] != ' ' || !(timestamp = parse_timestamp(email_end + 2, &message, 10)) || @@ -2108,7 +2111,7 @@ static int files_for_each_reflog_ent_reverse(struct ref_store *ref_store, strbuf_splice(&sb, 0, 0, bp + 1, endp - (bp + 1)); scanp = bp; endp = bp + 1; - ret = show_one_reflog_ent(&sb, fn, cb_data); + ret = show_one_reflog_ent(refs, &sb, fn, cb_data); strbuf_reset(&sb); if (ret) break; @@ -2120,7 +2123,7 @@ static int files_for_each_reflog_ent_reverse(struct ref_store *ref_store, * Process it, and we can end the loop. */ strbuf_splice(&sb, 0, 0, buf, endp - buf); - ret = show_one_reflog_ent(&sb, fn, cb_data); + ret = show_one_reflog_ent(refs, &sb, fn, cb_data); strbuf_reset(&sb); break; } @@ -2170,7 +2173,7 @@ static int files_for_each_reflog_ent(struct ref_store *ref_store, return -1; while (!ret && !strbuf_getwholeline(&sb, logfp, '\n')) - ret = show_one_reflog_ent(&sb, fn, cb_data); + ret = show_one_reflog_ent(refs, &sb, fn, cb_data); fclose(logfp); strbuf_release(&sb); return ret; diff --git a/refs/refs-internal.h b/refs/refs-internal.h index fa975d69aa..309b382284 100644 --- a/refs/refs-internal.h +++ b/refs/refs-internal.h @@ -705,7 +705,8 @@ struct ref_store { * Parse contents of a loose ref file. *failure_errno maybe be set to EINVAL for * invalid contents. */ -int parse_loose_ref_contents(const char *buf, struct object_id *oid, +int parse_loose_ref_contents(const struct git_hash_algo *algop, + const char *buf, struct object_id *oid, struct strbuf *referent, unsigned int *type, int *failure_errno); From patchwork Tue Jul 30 05:22:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13746672 Received: from fout4-smtp.messagingengine.com (fout4-smtp.messagingengine.com [103.168.172.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 5A78618FDC4 for ; Tue, 30 Jul 2024 05:23:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.147 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722316982; cv=none; b=Qil0HuE6+glfrNt1RuD+oHyTMS4RMtNFpGnJIABY674u0sH7vbUIgmzejxmZQyagBbYeQzky9J/FBU338Xvj3h9xNmvTQquzVxUv8sS+rI8juTQjntbMOl6IPO1N8zvoma5pqo+Bjpl963BqBDxW1PCeTDQWBg8AUwaT6hUJvTw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722316982; c=relaxed/simple; bh=ISKkhNJEpWJvz44vAzpWgh5jroYDf/d7pjP+4Rgicn8=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=fIpaReBtqSN7pts1OySHowd4+QYSBiUGVRvGOKJKGctz9OFac0HcgiJC7RjVWhjpW0Gmgu8Mwhejgon2v8ZhV2wHKypnaGe4K3ZM3gwLsDM3gcw+GCLBxjJWhdFVzkN+0/117JU4AjI2EenxiVNQ5dCx0Z0SSpWoNQ3XTelDEhg= 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=RfA0GK67; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=AWSpt2WE; arc=none smtp.client-ip=103.168.172.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="RfA0GK67"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="AWSpt2WE" Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailfout.nyi.internal (Postfix) with ESMTP id 7CDC513807A6 for ; Tue, 30 Jul 2024 01:22:59 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Tue, 30 Jul 2024 01:22:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc :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=fm3; t=1722316979; x=1722403379; bh=rxU7dGD8Nb HSi2iUzxHR8zSRnBmmaFz5FL8UpWYPWE8=; b=RfA0GK67bnsoOjf/FPb/245jTj emTAIWgDUcrM2kbbnWITLYWEQaq73/f0v5lEoJ+pFalpSG6hu1GMB1kUhC/DqGvX VuRaGy499jkWZEE4HJEHZaurnor3I2v1FHKZNljtGy97DskU+5JOZ5tXH4fZwbnd M2ONY9DSvtDbi0iXDDtrGgooxx4SQbcA12OjjvSa5XV/g2awIf9CMDWbM625YOO0 Ws2tsPusTtqxyYR8/D/Zlp6mNUE+w7QluodjGVwzSpWYXjls+kRrT0a9fHjIKf8f Hxi2I1EvNojqpzUb3UFiep4BQ0qSHRynZy80EhBPe7rtY1nx4TY0+dnGg/Bg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc: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-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1722316979; x=1722403379; bh=rxU7dGD8NbHSi2iUzxHR8zSRnBmm aFz5FL8UpWYPWE8=; b=AWSpt2WEB8GhrR8iV1cW8cI90OFLMhuD3npJ8EHg7qrI fsJulH8epDRdq19RnLBb5hL9CG/8ecZc9mE7QbQrtSr4Gf/UpTv77vuhmGP1yI5V ATXicMlWXniS0jxobjZS2DL0rPxmfqJv3mjuW/76p6sp0i8LCZFEJ0pFxCWtiGF+ DM116mfaBAuh6AjwwrHXG3O7GbSiwfVVO99dytEEJT5Rf+HfBC8MTx+OvglBMnGe J4D/hM1Ue1q1uGDaa8fipqLpq3McJbYrEwPZL/sL5CKn/vriMGoElhk+O5sMb/2p 8M4Ji5tlaJyD8jqvEvPYe+Hb8aWQev3oxMSESicukg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrjeefgdeljecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepfffhvffukfhfgggtuggjsehgtderre dttddvnecuhfhrohhmpefrrghtrhhitghkucfuthgvihhnhhgrrhguthcuoehpshesphhk shdrihhmqeenucggtffrrghtthgvrhhnpeehgefhtdefueffheekgfffudelffejtdfhvd ejkedthfehvdelgfetgfdvtedthfenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgr mhepmhgrihhlfhhrohhmpehpshesphhkshdrihhmpdhnsggprhgtphhtthhopedt X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Tue, 30 Jul 2024 01:22:58 -0400 (EDT) Received: by localhost (OpenSMTPD) with ESMTPSA id c30e09dd (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Tue, 30 Jul 2024 05:21:31 +0000 (UTC) Date: Tue, 30 Jul 2024 07:22:56 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Subject: [PATCH 3/5] refs/files: stop using `the_repository` Message-ID: References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Convert the files ref backend to stop using `the_repository` in favor of the repo that gets passed in via `struct ref_store`. Signed-off-by: Patrick Steinhardt --- refs/files-backend.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/refs/files-backend.c b/refs/files-backend.c index 3437c79699..c73f95ecf2 100644 --- a/refs/files-backend.c +++ b/refs/files-backend.c @@ -1,5 +1,3 @@ -#define USE_THE_REPOSITORY_VARIABLE - #include "../git-compat-util.h" #include "../copy.h" #include "../environment.h" @@ -248,7 +246,7 @@ static void loose_fill_ref_dir_regular_file(struct files_ref_store *refs, if (!refs_resolve_ref_unsafe(&refs->base, refname, RESOLVE_REF_READING, &oid, &flag)) { - oidclr(&oid, the_repository->hash_algo); + oidclr(&oid, refs->base.repo->hash_algo); flag |= REF_ISBROKEN; } else if (is_null_oid(&oid)) { /* @@ -265,7 +263,7 @@ static void loose_fill_ref_dir_regular_file(struct files_ref_store *refs, if (check_refname_format(refname, REFNAME_ALLOW_ONELEVEL)) { if (!refname_is_safe(refname)) die("loose refname is dangerous: %s", refname); - oidclr(&oid, the_repository->hash_algo); + oidclr(&oid, refs->base.repo->hash_algo); flag |= REF_BAD_NAME | REF_ISBROKEN; } add_entry_to_dir(dir, create_ref_entry(refname, &oid, flag)); @@ -1154,7 +1152,7 @@ static struct ref_lock *lock_ref_oid_basic(struct files_ref_store *refs, if (!refs_resolve_ref_unsafe(&refs->base, lock->ref_name, 0, &lock->old_oid, NULL)) - oidclr(&lock->old_oid, the_repository->hash_algo); + oidclr(&lock->old_oid, refs->base.repo->hash_algo); goto out; error_return: From patchwork Tue Jul 30 05:23:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13746673 Received: from fout4-smtp.messagingengine.com (fout4-smtp.messagingengine.com [103.168.172.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 3013119004E for ; Tue, 30 Jul 2024 05:23:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.147 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722316987; cv=none; b=cQeCRu5z1aZw4J3F7dOHhSeKt0I3NKGeM0wV46VaXlQzuA53U2oqwelVjpkXICSxDR9BFY2L+HyxhjPgrsrkIsWWQC0Mt9K3L8xRQiDJ8qL26aIEFL+UckEC0tPk+qQJ9xSahK6kgqjjUKptxvdxrtPPNt2SlzNRuuDGBPkhC6U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722316987; c=relaxed/simple; bh=7RnIvN6yNva92PD4iEA1aIr2vjZvr+VW4+rHgDzyMsc=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=CLUItiKuPHWM9qrK3INykY/r/swK66zaLZ+LyymO2qsy21dbgUwpqg52UPMcQAgEyFR/cchyYmCSLJMow/seVz4IcGQcPo8ypDk1/NHjsrO1UBsh9YXL+c4aD0kKCr35uUM1wEZeJUxtSccve4z8TTIoWUIgOxC8lacm7K3PCzU= 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=Prssf/Cg; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=O3se7qrr; arc=none smtp.client-ip=103.168.172.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="Prssf/Cg"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="O3se7qrr" Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailfout.nyi.internal (Postfix) with ESMTP id 48121138072A for ; Tue, 30 Jul 2024 01:23:04 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Tue, 30 Jul 2024 01:23:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc :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=fm3; t=1722316984; x=1722403384; bh=cEo2I46n7W XN/U2kk3rjlf4PgqjeD10xph1rpTXNlMk=; b=Prssf/Cg74xgUoIXlZWYu3gU+W Q5i3esu8bZv2ill3C0EIvbg6IsT4+Z4Ghjks7C5ZMBMcvVMYSN2hRpZ5x5FceBR8 r5Xb1ytTn2WoMmpCuZj+MYXZU1JngZzmT1asOLIPDtu9kmb9n/SKN5Xe3596q00h GP5m/3msCY8rL5HLoV6Xn45jxJzOh2plphhnmH5hnNnRDXcUYfVEnfV6ekBbO/AG cNzEe3Ub2Q6fgeG+/xRR7VDhu0xyWqDbXzOS5A5BlK1CiCs5drLIHbwHiO/KvT5d zjjJtvsvBzFCeYXgP6Nors8muTNAhrOl7nCVSfCx91506toMsKBI0wNuuO2Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc: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-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1722316984; x=1722403384; bh=cEo2I46n7WXN/U2kk3rjlf4Pgqje D10xph1rpTXNlMk=; b=O3se7qrryhxY3gfRz1UDK1+IFobcY6qIEDMmAaZqKZAE 2viUayRyc98rGyoysy8NoVT9Kh366YCCv9Mion9SXOBJj0XV75zAmWeNWP+TRNFT ulWx9QpkulTx/ZFDyfGx2dmssaUzjB5zFuY6jo9xdHydJmK97AIRtE8XkJCjFlE2 ph4iCY8tKcgoacSuDzYCMvABf9grpAeXtR5zMbneD9BC6ES3K7sUYwFuHyALKtrz EwnFd0f9scx+z0u7qOQj1OqFdD/JGs/h3uBhd8C9HrvmcowIy3Ify8mN9AulgJLh sb+DCuxfEHhl4vkMqMaOD9vntPiSa6iy1i1zFir4aw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrjeefgdeljecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepfffhvffukfhfgggtuggjsehgtderre dttddvnecuhfhrohhmpefrrghtrhhitghkucfuthgvihhnhhgrrhguthcuoehpshesphhk shdrihhmqeenucggtffrrghtthgvrhhnpeehgefhtdefueffheekgfffudelffejtdfhvd ejkedthfehvdelgfetgfdvtedthfenucevlhhushhtvghrufhiiigvpedunecurfgrrhgr mhepmhgrihhlfhhrohhmpehpshesphhkshdrihhmpdhnsggprhgtphhtthhopedt X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Tue, 30 Jul 2024 01:23:03 -0400 (EDT) Received: by localhost (OpenSMTPD) with ESMTPSA id ca3f248a (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Tue, 30 Jul 2024 05:21:36 +0000 (UTC) Date: Tue, 30 Jul 2024 07:23:01 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Subject: [PATCH 4/5] refs/packed: stop using `the_repository` Message-ID: References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Convert the packed ref backend to stop using `the_repository` in favor of the repo that gets passed in via `struct ref_store`. Signed-off-by: Patrick Steinhardt --- refs/packed-backend.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/refs/packed-backend.c b/refs/packed-backend.c index a0666407cd..89976aa359 100644 --- a/refs/packed-backend.c +++ b/refs/packed-backend.c @@ -1,5 +1,3 @@ -#define USE_THE_REPOSITORY_VARIABLE - #include "../git-compat-util.h" #include "../config.h" #include "../dir.h" @@ -794,7 +792,7 @@ static int packed_read_raw_ref(struct ref_store *ref_store, const char *refname, return -1; } - if (get_oid_hex(rec, oid)) + if (get_oid_hex_algop(rec, oid, ref_store->repo->hash_algo)) die_invalid_line(refs->path, rec, snapshot->eof - rec); *type = REF_ISPACKED; @@ -879,7 +877,7 @@ static int next_record(struct packed_ref_iterator *iter) p = iter->pos; if (iter->eof - p < snapshot_hexsz(iter->snapshot) + 2 || - parse_oid_hex(p, &iter->oid, &p) || + parse_oid_hex_algop(p, &iter->oid, &p, iter->repo->hash_algo) || !isspace(*p++)) die_invalid_line(iter->snapshot->refs->path, iter->pos, iter->eof - iter->pos); @@ -896,7 +894,7 @@ static int next_record(struct packed_ref_iterator *iter) if (!refname_is_safe(iter->base.refname)) die("packed refname is dangerous: %s", iter->base.refname); - oidclr(&iter->oid, the_repository->hash_algo); + oidclr(&iter->oid, iter->repo->hash_algo); iter->base.flags |= REF_BAD_NAME | REF_ISBROKEN; } if (iter->snapshot->peeled == PEELED_FULLY || @@ -909,7 +907,7 @@ static int next_record(struct packed_ref_iterator *iter) if (iter->pos < iter->eof && *iter->pos == '^') { p = iter->pos + 1; if (iter->eof - p < snapshot_hexsz(iter->snapshot) + 1 || - parse_oid_hex(p, &iter->peeled, &p) || + parse_oid_hex_algop(p, &iter->peeled, &p, iter->repo->hash_algo) || *p++ != '\n') die_invalid_line(iter->snapshot->refs->path, iter->pos, iter->eof - iter->pos); @@ -921,13 +919,13 @@ static int next_record(struct packed_ref_iterator *iter) * we suppress it if the reference is broken: */ if ((iter->base.flags & REF_ISBROKEN)) { - oidclr(&iter->peeled, the_repository->hash_algo); + oidclr(&iter->peeled, iter->repo->hash_algo); iter->base.flags &= ~REF_KNOWS_PEELED; } else { iter->base.flags |= REF_KNOWS_PEELED; } } else { - oidclr(&iter->peeled, the_repository->hash_algo); + oidclr(&iter->peeled, iter->repo->hash_algo); } return ITER_OK; From patchwork Tue Jul 30 05:23:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13746674 Received: from fhigh8-smtp.messagingengine.com (fhigh8-smtp.messagingengine.com [103.168.172.159]) (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 CFADC19004E for ; Tue, 30 Jul 2024 05:23:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.159 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722316991; cv=none; b=cV15pKZQNwW0jG4V/2XUYGWVQp3rc3gjKZ2jcliOgil/J/5QhYHe1AtLH9FYupXvnObIY+rOT7Dbe7kn2zVDNoJq566KIqrDS5+wbHEy+7a4II5Lw7t4hMh4mftlBTP/aD4gjv62DgbGe+X6jnjFJDhgJlmLXLN2mnHPL+eE6u0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722316991; c=relaxed/simple; bh=cl4JFjkpTzFrD8Iu7gwZSNtDdbchvCHhy2MFUdtBaOA=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=CncYqiA04mFy++rWKIm8/3zqPZryXu6510NL2ZWLGKnpqRdIeiJ37lZ9jTYmPnbOGlw84nAg6pxdkw2f/0xcq1TJgqLHtDuzs1Jt6M6G24VnTk9JY70khYIMTyMRKLEstju+XGemYhl1y0WUja9+LpzP7u5sc4CLcy3uJRkllAY= 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=Abl7vQZf; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=QXNaJoHB; arc=none smtp.client-ip=103.168.172.159 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="Abl7vQZf"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="QXNaJoHB" Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 1B7AC1140446 for ; Tue, 30 Jul 2024 01:23:09 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Tue, 30 Jul 2024 01:23:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc :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=fm3; t=1722316989; x=1722403389; bh=d+zddLIBMN zz8W8iJXlCreGDSdwqj8M+yMQrhqQI2tk=; b=Abl7vQZfer3JLOLs2Hg1TwSAmg 7nEzpDNmfp3tVlmbZNJje9ED4T19WrFYqz7EgmnVc55Tngg0eV/lME1xDmUo6/TL 07l0920vJE/cPj+lNsNtX92HPuvjhsqBrcE6GzZznFP29aVVVhOndBhiuIOK+8cm rC4XqtGyTypNqLLlsdMLl1m/dCeCagd9sZyNiwBqI4A6UueKDyH9y21atAs2TB0r JEBscN+WXZCrefzj93GtIzh1cub+NZhs6iTaLSGMZkktiK3g28sxkkHZ+V4aaFVx 0Chu5eC8ysa8M/gDianChnwhkEWh5Wn3FxCd5/eYcAVVo/WXx1dkuxwl7U1A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc: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-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1722316989; x=1722403389; bh=d+zddLIBMNzz8W8iJXlCreGDSdwq j8M+yMQrhqQI2tk=; b=QXNaJoHBDz8GTwE64lF4e6JtPx64T/1S4i3syQH9MtbP mnvAXiPcwQNi9hisZo+nxR9xufrjV+WxkwwcxI8ksr3YIkVSHqO5CYm9PBUaaoBp xjPPJ2dwnRDoiMCUg2LaHdTAOgwmWdeTAY0FyISvV/VRSeVvZWwvGIcc99DJEvWE 2SVy9S7DUTKFTOIMaCz+qkJ2C4ygooP2ZfT6aOgpnIY1i1p5rLT19LSXSMNiPHNe mpBMmOrzk+/FOos/S4scfasidQyQ03h53hkxBLWU5HUr4CuUHUkq5shBSbLAUOup xZxQQeLfoFvvPWfvhc6L8Dk6pau3PLyA3mTZlYtTsg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrjeefgdeljecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepfffhvffukfhfgggtuggjsehgtderre dttddvnecuhfhrohhmpefrrghtrhhitghkucfuthgvihhnhhgrrhguthcuoehpshesphhk shdrihhmqeenucggtffrrghtthgvrhhnpeelhffffeethefhteeigfetgeehhffhudduhf eiieehhfevkedthfdugfejhefftdenucffohhmrghinhepuhhpuggrthgvrdhtiidpvhgr lhdvrdhtrghrghgvthdpuhhpuggrthgvrdhnvgifpdhuphgurghtvgdrvghmrghilhenuc evlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehpshesphhk shdrihhmpdhnsggprhgtphhtthhopedt X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Tue, 30 Jul 2024 01:23:08 -0400 (EDT) Received: by localhost (OpenSMTPD) with ESMTPSA id 3885ed2b (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Tue, 30 Jul 2024 05:21:40 +0000 (UTC) Date: Tue, 30 Jul 2024 07:23:05 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Subject: [PATCH 5/5] refs/reftable: stop using `the_repository` Message-ID: <0e440360a83a02afd2d247a5ae9d2a250ff6a10b.1722316795.git.ps@pks.im> References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Convert the reftable ref backend to stop using `the_repository` in favor of the repo that gets passed in via `struct ref_store`. Signed-off-by: Patrick Steinhardt --- refs/reftable-backend.c | 51 +++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/refs/reftable-backend.c b/refs/reftable-backend.c index fbe74c239d..bf4446afd3 100644 --- a/refs/reftable-backend.c +++ b/refs/reftable-backend.c @@ -1,5 +1,3 @@ -#define USE_THE_REPOSITORY_VARIABLE - #include "../git-compat-util.h" #include "../abspath.h" #include "../chdir-notify.h" @@ -201,7 +199,8 @@ static void fill_reftable_log_record(struct reftable_log_record *log, const stru log->value.update.tz_offset = sign * atoi(tz_begin); } -static int read_ref_without_reload(struct reftable_stack *stack, +static int read_ref_without_reload(struct reftable_ref_store *refs, + struct reftable_stack *stack, const char *refname, struct object_id *oid, struct strbuf *referent, @@ -220,7 +219,7 @@ static int read_ref_without_reload(struct reftable_stack *stack, *type |= REF_ISSYMREF; } else if (reftable_ref_record_val1(&ref)) { oidread(oid, reftable_ref_record_val1(&ref), - the_repository->hash_algo); + refs->base.repo->hash_algo); } else { /* We got a tombstone, which should not happen. */ BUG("unhandled reference value type %d", ref.value_type); @@ -487,16 +486,16 @@ static int reftable_ref_iterator_advance(struct ref_iterator *ref_iterator) switch (iter->ref.value_type) { case REFTABLE_REF_VAL1: oidread(&iter->oid, iter->ref.value.val1, - the_repository->hash_algo); + refs->base.repo->hash_algo); break; case REFTABLE_REF_VAL2: oidread(&iter->oid, iter->ref.value.val2.value, - the_repository->hash_algo); + refs->base.repo->hash_algo); break; case REFTABLE_REF_SYMREF: if (!refs_resolve_ref_unsafe(&iter->refs->base, iter->ref.refname, RESOLVE_REF_READING, &iter->oid, &flags)) - oidclr(&iter->oid, the_repository->hash_algo); + oidclr(&iter->oid, refs->base.repo->hash_algo); break; default: BUG("unhandled reference value type %d", iter->ref.value_type); @@ -508,7 +507,7 @@ static int reftable_ref_iterator_advance(struct ref_iterator *ref_iterator) if (check_refname_format(iter->ref.refname, REFNAME_ALLOW_ONELEVEL)) { if (!refname_is_safe(iter->ref.refname)) die(_("refname is dangerous: %s"), iter->ref.refname); - oidclr(&iter->oid, the_repository->hash_algo); + oidclr(&iter->oid, refs->base.repo->hash_algo); flags |= REF_BAD_NAME | REF_ISBROKEN; } @@ -551,7 +550,7 @@ static int reftable_ref_iterator_peel(struct ref_iterator *ref_iterator, if (iter->ref.value_type == REFTABLE_REF_VAL2) { oidread(peeled, iter->ref.value.val2.target_value, - the_repository->hash_algo); + iter->refs->base.repo->hash_algo); return 0; } @@ -659,7 +658,7 @@ static int reftable_be_read_raw_ref(struct ref_store *ref_store, if (ret) return ret; - ret = read_ref_without_reload(stack, refname, oid, referent, type); + ret = read_ref_without_reload(refs, stack, refname, oid, referent, type); if (ret < 0) return ret; if (ret > 0) { @@ -868,8 +867,8 @@ static int reftable_be_transaction_prepare(struct ref_store *ref_store, goto done; } - ret = read_ref_without_reload(stack_for(refs, "HEAD", NULL), "HEAD", &head_oid, - &head_referent, &head_type); + ret = read_ref_without_reload(refs, stack_for(refs, "HEAD", NULL), "HEAD", + &head_oid, &head_referent, &head_type); if (ret < 0) goto done; ret = 0; @@ -936,7 +935,7 @@ static int reftable_be_transaction_prepare(struct ref_store *ref_store, string_list_insert(&affected_refnames, new_update->refname); } - ret = read_ref_without_reload(stack, rewritten_ref, + ret = read_ref_without_reload(refs, stack, rewritten_ref, ¤t_oid, &referent, &u->type); if (ret < 0) goto done; @@ -1500,7 +1499,8 @@ static int write_copy_table(struct reftable_writer *writer, void *cb_data) memcpy(logs[logs_nr].value.update.old_hash, old_ref.value.val1, GIT_MAX_RAWSZ); logs_nr++; - ret = read_ref_without_reload(arg->stack, "HEAD", &head_oid, &head_referent, &head_type); + ret = read_ref_without_reload(arg->refs, arg->stack, "HEAD", &head_oid, + &head_referent, &head_type); if (ret < 0) goto done; append_head_reflog = (head_type & REF_ISSYMREF) && !strcmp(head_referent.buf, arg->oldname); @@ -1790,15 +1790,16 @@ static struct ref_iterator *reftable_be_reflog_iterator_begin(struct ref_store * ref_iterator_select, NULL); } -static int yield_log_record(struct reftable_log_record *log, +static int yield_log_record(struct reftable_ref_store *refs, + struct reftable_log_record *log, each_reflog_ent_fn fn, void *cb_data) { struct object_id old_oid, new_oid; const char *full_committer; - oidread(&old_oid, log->value.update.old_hash, the_repository->hash_algo); - oidread(&new_oid, log->value.update.new_hash, the_repository->hash_algo); + oidread(&old_oid, log->value.update.old_hash, refs->base.repo->hash_algo); + oidread(&new_oid, log->value.update.new_hash, refs->base.repo->hash_algo); /* * When both the old object ID and the new object ID are null @@ -1841,7 +1842,7 @@ static int reftable_be_for_each_reflog_ent_reverse(struct ref_store *ref_store, break; } - ret = yield_log_record(&log, fn, cb_data); + ret = yield_log_record(refs, &log, fn, cb_data); if (ret) break; } @@ -1886,7 +1887,7 @@ static int reftable_be_for_each_reflog_ent(struct ref_store *ref_store, } for (i = logs_nr; i--;) { - ret = yield_log_record(&logs[i], fn, cb_data); + ret = yield_log_record(refs, &logs[i], fn, cb_data); if (ret) goto done; } @@ -2200,7 +2201,7 @@ static int reftable_be_reflog_expire(struct ref_store *ref_store, goto done; if (reftable_ref_record_val1(&ref_record)) oidread(&oid, reftable_ref_record_val1(&ref_record), - the_repository->hash_algo); + ref_store->repo->hash_algo); prepare_fn(refname, &oid, policy_cb_data); while (1) { @@ -2216,9 +2217,9 @@ static int reftable_be_reflog_expire(struct ref_store *ref_store, } oidread(&old_oid, log.value.update.old_hash, - the_repository->hash_algo); + ref_store->repo->hash_algo); oidread(&new_oid, log.value.update.new_hash, - the_repository->hash_algo); + ref_store->repo->hash_algo); /* * Skip over the reflog existence marker. We will add it back @@ -2250,9 +2251,9 @@ static int reftable_be_reflog_expire(struct ref_store *ref_store, *dest = logs[i]; oidread(&old_oid, logs[i].value.update.old_hash, - the_repository->hash_algo); + ref_store->repo->hash_algo); oidread(&new_oid, logs[i].value.update.new_hash, - the_repository->hash_algo); + ref_store->repo->hash_algo); if (should_prune_fn(&old_oid, &new_oid, logs[i].value.update.email, (timestamp_t)logs[i].value.update.time, @@ -2269,7 +2270,7 @@ static int reftable_be_reflog_expire(struct ref_store *ref_store, if (flags & EXPIRE_REFLOGS_UPDATE_REF && last_hash && reftable_ref_record_val1(&ref_record)) - oidread(&arg.update_oid, last_hash, the_repository->hash_algo); + oidread(&arg.update_oid, last_hash, ref_store->repo->hash_algo); arg.refs = refs; arg.records = rewritten;