From patchwork Wed Dec 6 12:39:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13481738 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="qggpKXq8"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="XRAFqlAo" Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2E0011F for ; Wed, 6 Dec 2023 04:39:56 -0800 (PST) Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 1A7625C0296 for ; Wed, 6 Dec 2023 07:39:56 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Wed, 06 Dec 2023 07:39:56 -0500 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:sender :subject:subject:to:to; s=fm1; t=1701866396; x=1701952796; bh=CM Kql7Y6w2gk0ZgTan/FbtV8+K23/QmNr1OxXreKeuE=; b=qggpKXq8B841nnedva oKUhwjZtWMR02vLJSn0B2S1nRU9lPecur36QRgojhxgMBcCCc3aYdRDmuyRZGVYQ S5DLYuz0l5vKS9blPVjKNBl4Sd255S8SJY4Q067vrHnWnRCo45P8yY2X0pMqvMu8 eFiMfSKCN9ABQ1RkLZXY5h2Pf9kUIZJO23GyU+umFAM+pF/rstzCZvjszyYzJYYL Z+SWDk3AZEREiIOV7toVQllE8N8O8uG5k5kGiFUoeWx5zBlzF01RPMZIa/dwOHS8 MvYfRoVg+UZLJl1/uM1MF0YA4ze9qfO31BlnGnl4m066BJpKnZO3+e7292c4eG3v A9DQ== 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:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1701866396; x=1701952796; bh=CMKql7Y6w2gk0 ZgTan/FbtV8+K23/QmNr1OxXreKeuE=; b=XRAFqlAoMnKDuRmN05F1DlupKySmn AbgdkioyVmAJzuR6VVmnL3t4ftdQ7lY+tAF+Bs+PdsXBi4p037kE5ba7yawstLeG 2bywoF4WJ/+SW8+kGtZiE7JoDNppjr1zb4FKMCNqeKDPtTcPZIbCsob7XUAHrmPb ClY3yIE2o7FQmKnm/wHAAhfdvKrNzRodvFerrZyYqTR1dCyfl6ki/BiW1oow8k1g GILPwUy0vb+TwWnkcVoabS7s9mi/nRmuyOZeBLWNas42oWylcRsu2IjaP6KCt+VF 4FNgZoilg/1ziDmk8wOXPn4XfE2M5eOVaAPuC1pU/FzLxITn1NSriYVYQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrudektddggeegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuffkfhggtggujgesghdtre ertddtvdenucfhrhhomheprfgrthhrihgtkhcuufhtvghinhhhrghrughtuceophhssehp khhsrdhimheqnecuggftrfgrthhtvghrnhepheeghfdtfeeuffehkefgffduleffjedthf dvjeektdfhhedvlefgtefgvdettdfhnecuvehluhhsthgvrhfuihiivgeptdenucfrrghr rghmpehmrghilhhfrhhomhepphhssehpkhhsrdhimh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Wed, 6 Dec 2023 07:39:55 -0500 (EST) Received: by vm-mail (OpenSMTPD) with ESMTPSA id 6b8b4ed6 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Wed, 6 Dec 2023 12:38:29 +0000 (UTC) Date: Wed, 6 Dec 2023 13:39:53 +0100 From: Patrick Steinhardt To: git@vger.kernel.org Subject: [PATCH 2/7] setup: allow skipping creation of the refdb Message-ID: <090c52423e3de9c4e94c6694bb18fb8510a3ad08.1701863960.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: Allow callers to skip creation of the reference database via a new flag `INIT_DB_SKIP_REFDB`, which is required for git-clone(1) so that we can create it at a later point once the object format has been discovered from the remote repository. Note that we also uplift the call to `create_reference_database()` into `init_db()`, which makes it easier to handle the new flag for us. This changes the order in which we do initialization so that we now set up the Git configuration before we create the reference database. In practice this move should not result in any change in behaviour. Signed-off-by: Patrick Steinhardt --- setup.c | 13 +++++-------- setup.h | 5 +++-- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/setup.c b/setup.c index 9fcb64159f..a80fc09b9c 100644 --- a/setup.c +++ b/setup.c @@ -1941,11 +1941,9 @@ static void create_reference_database(const char *initial_branch, int quiet) static int create_default_files(const char *template_path, const char *original_git_dir, - const char *initial_branch, const struct repository_format *fmt, int prev_bare_repository, - int init_shared_repository, - int quiet) + int init_shared_repository) { struct stat st1; struct strbuf buf = STRBUF_INIT; @@ -2016,7 +2014,6 @@ static int create_default_files(const char *template_path, adjust_shared_perm(get_git_dir()); } - create_reference_database(initial_branch, quiet); initialize_repository_version(fmt->hash_algo, 0); /* Check filemode trustability */ @@ -2176,11 +2173,11 @@ int init_db(const char *git_dir, const char *real_git_dir, validate_hash_algorithm(&repo_fmt, hash); reinit = create_default_files(template_dir, original_git_dir, - initial_branch, &repo_fmt, - prev_bare_repository, - init_shared_repository, - flags & INIT_DB_QUIET); + &repo_fmt, prev_bare_repository, + init_shared_repository); + if (!(flags & INIT_DB_SKIP_REFDB)) + create_reference_database(initial_branch, flags & INIT_DB_QUIET); create_object_directory(); if (get_shared_repository()) { diff --git a/setup.h b/setup.h index b48cf1c43b..cbf538286b 100644 --- a/setup.h +++ b/setup.h @@ -169,8 +169,9 @@ int verify_repository_format(const struct repository_format *format, */ void check_repository_format(struct repository_format *fmt); -#define INIT_DB_QUIET 0x0001 -#define INIT_DB_EXIST_OK 0x0002 +#define INIT_DB_QUIET (1 << 0) +#define INIT_DB_EXIST_OK (1 << 1) +#define INIT_DB_SKIP_REFDB (1 << 2) int init_db(const char *git_dir, const char *real_git_dir, const char *template_dir, int hash_algo,