From patchwork Sun Jul 26 19:54:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "brian m. carlson" X-Patchwork-Id: 11686067 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2CDA86C1 for ; Sun, 26 Jul 2020 19:55:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0BB9020715 for ; Sun, 26 Jul 2020 19:55:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (3072-bit key) header.d=crustytoothpaste.net header.i=@crustytoothpaste.net header.b="yq4yO1xe" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728019AbgGZTy6 (ORCPT ); Sun, 26 Jul 2020 15:54:58 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:40712 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727979AbgGZTy4 (ORCPT ); Sun, 26 Jul 2020 15:54:56 -0400 Received: from camp.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:b610:a2f0:36c1:12e3]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id 9422C6101D; Sun, 26 Jul 2020 19:54:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1595793295; bh=HkneMgZLTAdXgA8gNNuOhVNAwlHJ7abUKjddmrETEQ0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Reply-To: Subject:Date:To:CC:Resent-Date:Resent-From:Resent-To:Resent-Cc: In-Reply-To:References:Content-Type:Content-Disposition; b=yq4yO1xeoB9LnTtLAS5iKIM/UYpX0icjYagvFrEbVb74jTbSAVa0PxO9VpjapZh1D ZrRSSPXqH6FpzukvCKdAoP0tMKkDuCEnPFf4Da9TnlZWmw/BJhjlup1YcM40dYq60Q j886IDhHDImqU1dyRYSpGad/h6B/9d1VKLr2kxP+hVFbphhi9aRc+C75EHvtm/2xu3 m9RfcT9KIjMn2E9dxVcNRywJDSH05VvaBCVGvDVWyC+XrEzwiE+2PY964NiVpKnjfC tkeKNSRf25BNuis9zMh97E8SWdCcJao3ZT2XouDVwoz8SpVeEjVN+Vr0uB2ayVJtEw bNc+r+2F+4lRmTHWN33Aa+S18ZxjKN/Klb1rxV33PlbsGlWI9YbRIE5jl46Oc1KJdq /4n+XPRIf9d4QAqBH6YmhCeqizDkEIWiD/SIDT1otrCLD+lo3hCMiE9iQy82Rd/jMc wCn2bJshfa3A2mIAlxonscHmQIWoMizSepeNcbf+TJfIyjf04px From: "brian m. carlson" To: Cc: Eric Sunshine Subject: [PATCH v4 32/39] setup: add support for reading extensions.objectformat Date: Sun, 26 Jul 2020 19:54:17 +0000 Message-Id: <20200726195424.626969-33-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.28.0.rc2.160.gd0b3904b262 In-Reply-To: <20200726195424.626969-1-sandals@crustytoothpaste.net> References: <20200726195424.626969-1-sandals@crustytoothpaste.net> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The transition plan specifies extensions.objectFormat as the indication that we're using a given hash in a certain repo. Read this as one of the extensions we support. If the user has specified an invalid value, fail. Ensure that we reject the extension if the repository format version is 0. Signed-off-by: brian m. carlson --- setup.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/setup.c b/setup.c index 3a81307602..94e68bb4f4 100644 --- a/setup.c +++ b/setup.c @@ -470,7 +470,16 @@ static int check_repo_format(const char *var, const char *value, void *vdata) data->partial_clone = xstrdup(value); } else if (!strcmp(ext, "worktreeconfig")) data->worktree_config = git_config_bool(var, value); - else + else if (!strcmp(ext, "objectformat")) { + int format; + + if (!value) + return config_error_nonbool(var); + format = hash_algo_by_name(value); + if (format == GIT_HASH_UNKNOWN) + return error("invalid value for 'extensions.objectformat'"); + data->hash_algo = format; + } else string_list_append(&data->unknown_extensions, ext); } @@ -613,6 +622,11 @@ int verify_repository_format(const struct repository_format *format, return -1; } + if (format->version <= 0 && format->hash_algo != GIT_HASH_SHA1) { + strbuf_addstr(err, _("extensions.objectFormat is not valid in repo v0")); + return -1; + } + return 0; }