From patchwork Wed Nov 27 23:33:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Tobler X-Patchwork-Id: 13887441 Received: from mail-oo1-f54.google.com (mail-oo1-f54.google.com [209.85.161.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 62478193432 for ; Wed, 27 Nov 2024 23:35:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732750554; cv=none; b=lRlxQmHM7kFWS8vq7tx92g8vL+z9YBbiiSeb7D+cIbt2Kl51F4v3h6140gDp4BNfh38bzrubV7DKKmCZgl4Ogpl3NC5J5AK5jNCrih+RjwLlGCNRGMJvwK+DXCrR3hPfbBmid3bnKP7i3QRocJdoUXp7HY8+26tR0l5lEhM5+u0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732750554; c=relaxed/simple; bh=wtw4IqE1Bvc2CzKKYsqjndJA50WqpmlP+DG+nS8iZ1o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=US7EJwk3kPGjgtVI/wPtNYLoXQbeweXvMxiYhFymypcnZ4IYQvg4reiDmzQM4EfaPkAoHQXUkDR4o0BTNjxCiMQ2BfXT8yawTNL7WQNKALMwF+rAHGPhkyVC65s0ccptQ8TQ6bWl2TjzmYcdpPQ3RwYxHcKDS+o2yD53WSo9syo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=D+KG+yyZ; arc=none smtp.client-ip=209.85.161.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="D+KG+yyZ" Received: by mail-oo1-f54.google.com with SMTP id 006d021491bc7-5f1f5075cf2so155054eaf.0 for ; Wed, 27 Nov 2024 15:35:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732750551; x=1733355351; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hhauHutODHFANCW4hs0xz+fYr1BuPMFJVuyibdfT4/A=; b=D+KG+yyZhBDSYRyuxHFfqVeD/FdYPTi1XaaYoW4D8xS40lzvrNGPw+qzqzfgGxo2cG yJdJdpMCcgqFG7x7fGpcXWlC3NmIXVdPEaihScnGngJ5cUpkHlB3gzwrdlhw1nLzj7Bz 9aI8l+39fK39AAd31wxYtfcobCRHMfMEtj7AkgO1zd/JgwoRnH9rLKga4cg7nRIxBf1w 8LUsBClLkrbzIWmXKTbtkJ0UypP6MQpvwpGA4dNnsk6dG4NsZrY304WErD/gyWIFgBeP ePGhQS6+yEgU8Ek1uBs6/LeL+/w0TzTv9mLwcl5EvFm7T7wVr6+RQDeHXBJqK/fhgBy3 Wu3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732750551; x=1733355351; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hhauHutODHFANCW4hs0xz+fYr1BuPMFJVuyibdfT4/A=; b=Ux2Oux82s1AWlVi9rc0X5kLAaOvzedwA19rL2k42JopS+fTV1yQJ6FeWeKzXYmNJbz 73GF7KSeT/ILi5x1Xm33mdG5Nk2C7SWLlVFnqaGIDwrXpXm500CoPenPe81EEE4n38so Jz5U2OWQWw1fkT8quW9DCeRd1dYpIWCszVzSByKUlz5kjjm+c+lIqeqkS9godDjFkufr uEl46LLmiElakf+exUgBDmgEMA8DVP73YcuyyWAp2+KfXiVlqgaeDw/0qzcoWV7LipWN Z3eRISEoKpH3A8qoKVrpbRmwHG4NdW8GGnA+8s9xmpPK5+8tUIlgJTSAAWbzdr77M3vc 0VEw== X-Gm-Message-State: AOJu0Yzm7IIwSPrvr6D/OyORXBnELte8Xs688QPxMDBJh2MB3g6bfXn9 1+FnOPXlSuKFDNIX2syVj+65vS9+zrTaFNs6yM0Y+F/rVKnefbm3SrNQEQ== X-Gm-Gg: ASbGncsreaa/EntGrodA9DP+bf/c5PPKVgHR+5WGYIUlNCpqWYNtxle0Hnpt1lNdGoR Ksz8sgGX4+oFyVxJCBQrXxboVCPoXr8dmu3WQrPzioaLZLCFmsA2S9q2cb+UQSLlahmmVJESTS8 yIZAhRV2JDyKh84KO6fDXyunSZzzvLIRTvDTW6SNjY0hIarTqld3Yv21iuj32QZxPYbSOln/JDE /z2Dw8x/mPcQmoWgKT9IXLF9WQIGAb1gGxqTNCgVwYj2YnYSKv/h6CWVw== X-Google-Smtp-Source: AGHT+IEx72VZbH0Qiucj5oYTgMcTwYCcA5zSwPN/VUK3R88Sg10FpOJG12hcTWxM/t6rCY68L5HYpg== X-Received: by 2002:a05:6830:4114:b0:71d:5f65:ce2f with SMTP id 46e09a7af769-71d65cfa6a7mr4109560a34.22.1732750551207; Wed, 27 Nov 2024 15:35:51 -0800 (PST) Received: from denethor.localdomain ([136.50.74.45]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-29de8f31cefsm109260fac.2.2024.11.27.15.35.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Nov 2024 15:35:50 -0800 (PST) From: Justin Tobler To: git@vger.kernel.org Cc: Justin Tobler Subject: [PATCH v3 1/4] bundle: add bundle verification options type Date: Wed, 27 Nov 2024 17:33:09 -0600 Message-ID: <20241127233312.27710-2-jltobler@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241127233312.27710-1-jltobler@gmail.com> References: <20241127005707.319881-1-jltobler@gmail.com> <20241127233312.27710-1-jltobler@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 When `unbundle()` is invoked, fsck verification may be configured by passing the `VERIFY_BUNDLE_FSCK` flag. This mechanism allows fsck checks on the bundle to be enabled or disabled entirely. To facilitate more fine-grained fsck configuration, additional context must be provided to `unbundle()`. Introduce the `unbundle_opts` type, which wraps the existing `verify_bundle_flags`, to facilitate future extension of `unbundle()` configuration. Also update `unbundle()` and its call sites to accept this new options type instead of the flags directly. The end behavior is functionally the same, but allows for the set of configurable options to be extended. This is leveraged in a subsequent commit to enable fsck message severity configuration. Signed-off-by: Justin Tobler --- builtin/bundle.c | 2 +- bundle-uri.c | 7 +++++-- bundle.c | 6 +++++- bundle.h | 10 +++++++--- transport.c | 6 ++++-- 5 files changed, 22 insertions(+), 9 deletions(-) diff --git a/builtin/bundle.c b/builtin/bundle.c index 127518c2a8..15ac75ab51 100644 --- a/builtin/bundle.c +++ b/builtin/bundle.c @@ -218,7 +218,7 @@ static int cmd_bundle_unbundle(int argc, const char **argv, const char *prefix) strvec_pushl(&extra_index_pack_args, "-v", "--progress-title", _("Unbundling objects"), NULL); ret = !!unbundle(the_repository, &header, bundle_fd, - &extra_index_pack_args, 0) || + &extra_index_pack_args, NULL) || list_bundle_refs(&header, argc, argv); bundle_header_release(&header); diff --git a/bundle-uri.c b/bundle-uri.c index 0df66e2872..cdf9e4f9e1 100644 --- a/bundle-uri.c +++ b/bundle-uri.c @@ -367,6 +367,10 @@ static int unbundle_from_file(struct repository *r, const char *file) struct string_list_item *refname; struct strbuf bundle_ref = STRBUF_INIT; size_t bundle_prefix_len; + struct unbundle_opts opts = { + .flags = VERIFY_BUNDLE_QUIET | + (fetch_pack_fsck_objects() ? VERIFY_BUNDLE_FSCK : 0), + }; bundle_fd = read_bundle_header(file, &header); if (bundle_fd < 0) { @@ -379,8 +383,7 @@ static int unbundle_from_file(struct repository *r, const char *file) * a reachable ref pointing to the new tips, which will reach * the prerequisite commits. */ - result = unbundle(r, &header, bundle_fd, NULL, - VERIFY_BUNDLE_QUIET | (fetch_pack_fsck_objects() ? VERIFY_BUNDLE_FSCK : 0)); + result = unbundle(r, &header, bundle_fd, NULL, &opts); if (result) { result = 1; goto cleanup; diff --git a/bundle.c b/bundle.c index 4773b51eb1..485033ea3f 100644 --- a/bundle.c +++ b/bundle.c @@ -628,9 +628,13 @@ int create_bundle(struct repository *r, const char *path, int unbundle(struct repository *r, struct bundle_header *header, int bundle_fd, struct strvec *extra_index_pack_args, - enum verify_bundle_flags flags) + struct unbundle_opts *opts) { struct child_process ip = CHILD_PROCESS_INIT; + enum verify_bundle_flags flags = 0; + + if (opts) + flags = opts->flags; if (verify_bundle(r, header, flags)) return -1; diff --git a/bundle.h b/bundle.h index 5ccc9a061a..6a09cc7bfb 100644 --- a/bundle.h +++ b/bundle.h @@ -39,6 +39,10 @@ enum verify_bundle_flags { int verify_bundle(struct repository *r, struct bundle_header *header, enum verify_bundle_flags flags); +struct unbundle_opts { + enum verify_bundle_flags flags; +}; + /** * Unbundle after reading the header with read_bundle_header(). * @@ -49,12 +53,12 @@ int verify_bundle(struct repository *r, struct bundle_header *header, * (e.g. "-v" for verbose/progress), NULL otherwise. The provided * "extra_index_pack_args" (if any) will be strvec_clear()'d for you. * - * Before unbundling, this method will call verify_bundle() with the - * given 'flags'. + * Before unbundling, this method will call verify_bundle() with 'flags' + * provided in 'opts'. */ int unbundle(struct repository *r, struct bundle_header *header, int bundle_fd, struct strvec *extra_index_pack_args, - enum verify_bundle_flags flags); + struct unbundle_opts *opts); int list_bundle_refs(struct bundle_header *header, int argc, const char **argv); diff --git a/transport.c b/transport.c index 47fda6a773..8536b14181 100644 --- a/transport.c +++ b/transport.c @@ -176,6 +176,9 @@ static int fetch_refs_from_bundle(struct transport *transport, int nr_heads UNUSED, struct ref **to_fetch UNUSED) { + struct unbundle_opts opts = { + .flags = fetch_pack_fsck_objects() ? VERIFY_BUNDLE_FSCK : 0, + }; struct bundle_transport_data *data = transport->data; struct strvec extra_index_pack_args = STRVEC_INIT; int ret; @@ -186,8 +189,7 @@ static int fetch_refs_from_bundle(struct transport *transport, if (!data->get_refs_from_bundle_called) get_refs_from_bundle_inner(transport); ret = unbundle(the_repository, &data->header, data->fd, - &extra_index_pack_args, - fetch_pack_fsck_objects() ? VERIFY_BUNDLE_FSCK : 0); + &extra_index_pack_args, &opts); transport->hash_algo = data->header.hash_algo; strvec_clear(&extra_index_pack_args); From patchwork Wed Nov 27 23:33:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Tobler X-Patchwork-Id: 13887442 Received: from mail-oa1-f50.google.com (mail-oa1-f50.google.com [209.85.160.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A5A1F1991C8 for ; Wed, 27 Nov 2024 23:35:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732750557; cv=none; b=Y5M/sPOWJGIVP3rXLpvJSruVbZ5P4E9Ja5rUdn0zWJR3LhK790ahLPx5lZM1xu3IwFLTld9wifhsaatAd6rzUB4/10SY1MQD9ONq+Nb2AOnh+ZFxS2Gt60NeEpadtsJ6LAs9FxMdW4C/P0xEZU8k7TiclvgSS+vXzn60LcTIn3Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732750557; c=relaxed/simple; bh=xWJzmReKNiOq3EBZ3LddoIvJdjNQx8spXBSE4Qh1vcs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Wm4NuBFszK+gJNZSh57nHUE/dmFZYJGTFgtDiTYOpX3q7SmhZTiOQWsdYkHHySdBgmv2lIsfeLh7e4I8wwYBboqrjGxPpsyzxSj++tjUKePUBt+P1+qyUxhyoSEfRZP/PQXe65Z4ZJTuIFbc9JQy41HxmBzM0w39St2aYpKWXwM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=NREPhJ22; arc=none smtp.client-ip=209.85.160.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NREPhJ22" Received: by mail-oa1-f50.google.com with SMTP id 586e51a60fabf-288fa5ce8f0so142796fac.3 for ; Wed, 27 Nov 2024 15:35:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732750554; x=1733355354; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=N0uAu+Y40SIGHl9Nv1g/lFR+LKAEcjOrqQRF49iJSnY=; b=NREPhJ22xsbKEhqknZ9F3z3ysObqzVZNundcxiiwMTlgQyF7BSbHLG5giVShghqgC7 6PtP06gYlreNp7kQYvqBLQPOYDsjUTY3KlJnPKV44IaBf3RmzCbcWaOuzOqJxb44bbby ta4h3gqqDzZHzVk1Pw3mWWoPRUOyO1BQnHBQRArtxtOnKwon7KtbzE65Ri9c00MvKGkM ZzawyeKzNMgcYBhVv/sShTCvxL6b5qlJXNuelkIswrM4HYnKqeft70PFjcS6FyDIBIfV DRJL8OD25O5DIim4WeMY7hrtyJQX63dnEVkN4g/1+23WEgIY/VtRfPaTEHbysDO68lHh XQ8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732750554; x=1733355354; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=N0uAu+Y40SIGHl9Nv1g/lFR+LKAEcjOrqQRF49iJSnY=; b=mWJSInWtVOZLpTk+nXTOzRwGM3hfcnKVzYCSY5rA7gKOXe/HSL4MxyYHV+O6VSg1iO VMbGPQGMqDFxv5kzlXn4p2VhbaCGrujRvIFYO5Bwd97W3Zwp3N8VId711FiCYtnfwGiE b/c3o4YceYUvEq4I0pjsmetMatu2piDdrRz6zvhv7e8zAHQLqmOaSpAQg5WXWuLIT+Kr ERDEjBIXfnkeXdvN1GXVbdDksGBd9APi+63dwAWPTTtL0OxTOu91Rm36cYT4h/pvSYVd Z4DECxnq3rm/0EgzWcJGUxKhcnEEqnodoRVEgyQu7c97e9AI9QwI70XBa2JcSB2f77Zg NE/w== X-Gm-Message-State: AOJu0Yw0mPxP8ZQXOd6jUOrcbP/q4Ov+80A+ZueyMHK8MRY4hFm13R06 CkGHZYYqcm0/co6HW94QvVOpRo/3Oa4shQZa+ske0HCyJREFTMj6QP5wvg== X-Gm-Gg: ASbGncsY1Tsc/EJX9QypTHlWT39bpqKHsHWC/dGARzWzAZv2DmsvQgrlS+McAvxonZf 4nxhbZT7pZVHCJtLHWVFij+6ldHVIdpu6hPZzXPuYRXmcOpMQEtIfZcdSord2JJrzihHnm3nn9O 6Qxlq/tdF0z26u6RFVTOAnjFTuNyOjhrA8XHc68mCfojiHzc6dyymiiY1JJmqM7a+jOJwVIVfax 41XV/zZDmGxSA8qwhE74Hm2ooSX2ItmZDxPJWMRYZDdduiqBULmtVQUtw== X-Google-Smtp-Source: AGHT+IGrEF9wolC6Fe/OWWCZXOB97mSrb9iqbO8AehPqHv8so1/qNFh3mNdDNQxAfqxcf9lT5vTVTg== X-Received: by 2002:a05:6871:c519:b0:29d:c870:74 with SMTP id 586e51a60fabf-29dc870066fmr3182199fac.27.1732750554438; Wed, 27 Nov 2024 15:35:54 -0800 (PST) Received: from denethor.localdomain ([136.50.74.45]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-29de8f31cefsm109260fac.2.2024.11.27.15.35.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Nov 2024 15:35:53 -0800 (PST) From: Justin Tobler To: git@vger.kernel.org Cc: Justin Tobler Subject: [PATCH v3 2/4] bundle: support fsck message configuration Date: Wed, 27 Nov 2024 17:33:10 -0600 Message-ID: <20241127233312.27710-3-jltobler@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241127233312.27710-1-jltobler@gmail.com> References: <20241127005707.319881-1-jltobler@gmail.com> <20241127233312.27710-1-jltobler@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 If the `VERIFY_BUNDLE_FLAG` is set during `unbundle()`, the git-index-pack(1) spawned is configured with the `--fsck-options` flag to perform fsck verification. With this flag enabled, there is not a way to configure fsck message severity though. Extend the `unbundle_opts` type to store fsck message severity configuration and update `unbundle()` to conditionally append it to the `--fsck-objects` flag if provided. This enables `unbundle()` call sites to support optionally setting the severity for specific fsck messages. Signed-off-by: Justin Tobler --- bundle.c | 13 +++++++------ bundle.h | 7 +++++++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/bundle.c b/bundle.c index 485033ea3f..4e53ddfca2 100644 --- a/bundle.c +++ b/bundle.c @@ -631,12 +631,12 @@ int unbundle(struct repository *r, struct bundle_header *header, struct unbundle_opts *opts) { struct child_process ip = CHILD_PROCESS_INIT; - enum verify_bundle_flags flags = 0; + struct unbundle_opts opts_fallback = { 0 }; - if (opts) - flags = opts->flags; + if (!opts) + opts = &opts_fallback; - if (verify_bundle(r, header, flags)) + if (verify_bundle(r, header, opts->flags)) return -1; strvec_pushl(&ip.args, "index-pack", "--fix-thin", "--stdin", NULL); @@ -645,8 +645,9 @@ int unbundle(struct repository *r, struct bundle_header *header, if (header->filter.choice) strvec_push(&ip.args, "--promisor=from-bundle"); - if (flags & VERIFY_BUNDLE_FSCK) - strvec_push(&ip.args, "--fsck-objects"); + if (opts->flags & VERIFY_BUNDLE_FSCK) + strvec_pushf(&ip.args, "--fsck-objects%s", + opts->fsck_msg_types ? opts->fsck_msg_types : ""); if (extra_index_pack_args) strvec_pushv(&ip.args, extra_index_pack_args->v); diff --git a/bundle.h b/bundle.h index 6a09cc7bfb..a80aa8ad9b 100644 --- a/bundle.h +++ b/bundle.h @@ -41,6 +41,13 @@ int verify_bundle(struct repository *r, struct bundle_header *header, struct unbundle_opts { enum verify_bundle_flags flags; + /* + * fsck_msg_types may optionally contain fsck message severity + * configuration. If present, this configuration gets directly appended + * to a '--fsck-objects' option and therefore must be prefixed with '='. + * (E.g. "=missingEmail=ignore,gitmodulesUrl=ignore") + */ + const char *fsck_msg_types; }; /** From patchwork Wed Nov 27 23:33:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Tobler X-Patchwork-Id: 13887443 Received: from mail-oa1-f50.google.com (mail-oa1-f50.google.com [209.85.160.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A5B6F199E9D for ; Wed, 27 Nov 2024 23:35:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732750560; cv=none; b=GmHsGe0u/F4msjmhn8YnARImEF33o6CvAuQEaLdz1hnxtRoMPXR4L6N2hM89D2kUZ2u8bKYs7UB+R8jl1VRrrc0oCNJdGAKcawOwOW/Erea70m/3ItoEdROSExja42IhWpOusB747680Tmw3b2LqcEHj3Seo1741mhpMG8uGfFM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732750560; c=relaxed/simple; bh=JWPYztCAk+Dse92p5aS/+CxWXANUxUsFUNr6ww4auoY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dQx5TQg0TjlUEQQyOz0IbEoSQJC5AV65I+rLLLXdazObBR6aaV+07kCdAaHEN0XRqgixK+tB/GwjNZBhgqZ9hUslrUbD8umvkCYn5/39p9c2cyVSRvXZNiOZpQtdoPZELUFFWOWtR2lCki5oySBEDjvlKTg4og2OxYM78Som/4I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=jX47vkSn; arc=none smtp.client-ip=209.85.160.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jX47vkSn" Received: by mail-oa1-f50.google.com with SMTP id 586e51a60fabf-29678315c06so187126fac.1 for ; Wed, 27 Nov 2024 15:35:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732750557; x=1733355357; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=B0ROPFKsVEUkfPPpJWkV5nAFRJudcOO8Luq6aaDwNfA=; b=jX47vkSnWXjleQMRFhuJTN8IX/7YawRclYntcz16On+cwJBjcjwZ5CW0B7XHaDvEg3 VxPlArd4YUAw2OaFYgqYUfV3v379A6H+VPbbrRypA0+MmooxTE/hBw4WnKBYjyzGuxrb HH4y3gCykBDjPZmalc3MqbIQR1hB+ao0+AlFcUUKFxRbZCZVq2MDwQLGRNC+Q23wNL29 2htAAT5zTbnHwxibtpmueaZCcCREwnkZl/sXfag9SHKRZz3txJGHPJL8e7d2JSCqWQkY iXm3BOHOWmXaHkoKNCRUhLjCVvnVyXsnwXMPF+P8FAawF7EA5KrZZmavwmMs4uVL5qf4 K7rA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732750557; x=1733355357; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=B0ROPFKsVEUkfPPpJWkV5nAFRJudcOO8Luq6aaDwNfA=; b=NIITshVzi3pJQ824BekCkitEpl9s821sgdUIMkSU5sS6kk6YuABx9zBYk/zxpvqOI0 utuHXhYWFPJZGkVu7T+wv9PtUR/+4I5SDVoP5QX3rc4FkBa1J7WFwVYxBgnGJ7j5n1YR gwCKstuI1DAQjPWb60pboi9+OhLK8nOWepVHHrc+9JckJ+rD2RPA6OuMj7+oJhPXdloz KWCXyFSBalAfzQc/QUi08SUs2ygOamJibBU7V5QLYkVliwd8Vm3sMD0uz/jvBAJE8ds2 jS6aGqT4nZUDSa33xZV8RAVqlVl9fTHyhqMR9q8V+ihfgW8WQsrZSjv0w9HFU8MguFp8 R2pg== X-Gm-Message-State: AOJu0YzHQEifJW+Bwtt9T6wSDlC5Oi97oab18AJKPUXHxjug8Ub//8d0 /DE634qu2uSilwbkUDGy2bKsRpMWZv9S1Cuy+XlizPyyfs8i8Tf3daWKOA== X-Gm-Gg: ASbGncvQLj0bHYaTIsuX8nETgdy/9TM+9+Xkntfl2vkC1TqDoReWAPqt1vrTjTZ/0Uf NQa/O2hNEAyPYz+xd8KkBRCPkKmwLXEOmMk6itDMhEKeEtkPnzpYdYtLnw7BsUizOYWCUBXyVs2 aN2uiJQ06Nb7cn4N8FjzzIZPw6Z23roZv8AFwqKMkknggncF0C82YRtPEqD/FvV+cbmFE9Bk48A YAJtjH/eEm5JjbOivQhmt+/1IzEWyYv8D4p2lHY0mgWFWLF9iqhhr/D9w== X-Google-Smtp-Source: AGHT+IEt8xL3hvGyfGfkIVSgkWmBaYfIxTSkSua6CgDCy/ASEnUcHSrdkoEFEatckefg5e8rW35lvA== X-Received: by 2002:a05:6870:5d8f:b0:297:270c:575 with SMTP id 586e51a60fabf-29dc40097dbmr4622341fac.16.1732750557183; Wed, 27 Nov 2024 15:35:57 -0800 (PST) Received: from denethor.localdomain ([136.50.74.45]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-29de8f31cefsm109260fac.2.2024.11.27.15.35.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Nov 2024 15:35:56 -0800 (PST) From: Justin Tobler To: git@vger.kernel.org Cc: Justin Tobler Subject: [PATCH v3 3/4] fetch-pack: split out fsck config parsing Date: Wed, 27 Nov 2024 17:33:11 -0600 Message-ID: <20241127233312.27710-4-jltobler@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241127233312.27710-1-jltobler@gmail.com> References: <20241127005707.319881-1-jltobler@gmail.com> <20241127233312.27710-1-jltobler@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 When `fetch_pack_config()` is invoked, fetch-pack configuration is parsed from the config. As part of this operation, fsck message severity configuration is assigned to the `fsck_msg_types` global variable. This is optionally used to configure the downstream git-index-pack(1) when the `--strict` option is specified. The same parsed fsck message severity configuration is also needed outside of fetch-pack. Instead of exposing/relying on the existing global state, split out the fsck config parsing logic into `fetch_pack_fsck_config()` and expose it. In a subsequent commit, this is used to provide fsck configuration when invoking `unbundle()`. For `fetch_pack_fsck_config()` to discern between errors and unhandled config variables, the return code when `git_config_path()` errors is changed to a different value also indicating success. This frees up the previous return code to now indicate the provided config variable was unhandled. The behavior remains functionally the same. Signed-off-by: Justin Tobler --- fetch-pack.c | 26 ++++++++++++++++++-------- fetch-pack.h | 11 +++++++++++ 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/fetch-pack.c b/fetch-pack.c index fe1fb3c1b7..c095f3a84b 100644 --- a/fetch-pack.c +++ b/fetch-pack.c @@ -1857,8 +1857,8 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args, return ref; } -static int fetch_pack_config_cb(const char *var, const char *value, - const struct config_context *ctx, void *cb) +int fetch_pack_fsck_config(const char *var, const char *value, + struct strbuf *msg_types) { const char *msg_id; @@ -1866,9 +1866,9 @@ static int fetch_pack_config_cb(const char *var, const char *value, char *path ; if (git_config_pathname(&path, var, value)) - return 1; - strbuf_addf(&fsck_msg_types, "%cskiplist=%s", - fsck_msg_types.len ? ',' : '=', path); + return 0; + strbuf_addf(msg_types, "%cskiplist=%s", + msg_types->len ? ',' : '=', path); free(path); return 0; } @@ -1877,14 +1877,24 @@ static int fetch_pack_config_cb(const char *var, const char *value, if (!value) return config_error_nonbool(var); if (is_valid_msg_type(msg_id, value)) - strbuf_addf(&fsck_msg_types, "%c%s=%s", - fsck_msg_types.len ? ',' : '=', msg_id, value); + strbuf_addf(msg_types, "%c%s=%s", + msg_types->len ? ',' : '=', msg_id, value); else warning("Skipping unknown msg id '%s'", msg_id); return 0; } - return git_default_config(var, value, ctx, cb); + return 1; +} + +static int fetch_pack_config_cb(const char *var, const char *value, + const struct config_context *ctx, void *cb) +{ + int ret = fetch_pack_fsck_config(var, value, &fsck_msg_types); + if (ret > 0) + return git_default_config(var, value, ctx, cb); + + return ret; } static void fetch_pack_config(void) diff --git a/fetch-pack.h b/fetch-pack.h index b5c579cdae..9d3470366f 100644 --- a/fetch-pack.h +++ b/fetch-pack.h @@ -106,4 +106,15 @@ int report_unmatched_refs(struct ref **sought, int nr_sought); */ int fetch_pack_fsck_objects(void); +/* + * Check if the provided config variable pertains to fetch fsck and if so append + * the configuration to the provided strbuf. + * + * When a fetch fsck config option is successfully processed the function + * returns 0. If the provided config option is unrelated to fetch fsck, 1 is + * returned. Errors return -1. + */ +int fetch_pack_fsck_config(const char *var, const char *value, + struct strbuf *msg_types); + #endif From patchwork Wed Nov 27 23:33:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Tobler X-Patchwork-Id: 13887444 Received: from mail-oa1-f53.google.com (mail-oa1-f53.google.com [209.85.160.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3A5161990D6 for ; Wed, 27 Nov 2024 23:35:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732750561; cv=none; b=AierVtRT+r/9GHNZo7xNe6qVnETZLa4Ks9V2coRLSn7lhhRl1iYujuCDFDYXpg9TE+UwOR1Gj96PAIRm/SinE57QH9rMck0owVSaIJQoftTiZDhjW9sp1DeVBtX7cnui0GgaUNsCkPMjEbpUotzXPvELbNdwCpLWUweNshAhFi4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732750561; c=relaxed/simple; bh=W9pg0sU7KWpARDNhpNxbQjueZfSjMagxglG9BIOokHE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MYZKTgC+T1ycHiYw1bhWuOHYhAdvlsPE5p3PdQKLPNc5yekOibEAY9yKZNdfXmx97/vCv4AJQO8W12HFrQsttx9GFoaoYCoRXN8nW++jGF8rLkrlhlEP+MW1XDopTFFjvjM4foj8/MjU0fLbYZVmLSFoDqHCxO0q1USMj/epOtE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Uf50rGOL; arc=none smtp.client-ip=209.85.160.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Uf50rGOL" Received: by mail-oa1-f53.google.com with SMTP id 586e51a60fabf-2973b53ec02so212268fac.1 for ; Wed, 27 Nov 2024 15:35:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732750559; x=1733355359; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=xMxNdiuzrCvyzA276JFbhHsFz96hQOkPZvUXzScSV4E=; b=Uf50rGOLGuA3hEg0rJ5M+0UegdYRF+owkxMJLXCZP6Pe1YTt3PGSLVD9spu76GWImX CBQFoXPKgeMoaYQhGeyif1pyXBSKQHqk0Ftqmh7pbdR9o+T5do2pbJ5nEQmBOVj+URls Tw2NhP4slE8S/kZxRFcIygWzZ0w0vwS8O8VFI9N18PNXVBgsopNjavUfakDOJ7kZwV5x 9IvEEoRvSZSE8jARx9VbrsEN/7rWtd1QfktBnQdXP7DIwu2F+DJg1Swh393/xgie2X7C vKnjXrVFFTw6vHznaJoFNOTLvYuxb2oxEnVLzaUnGPSbzPvGWD6Wlvct9vjHi9vBaz2Z hHlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732750559; x=1733355359; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xMxNdiuzrCvyzA276JFbhHsFz96hQOkPZvUXzScSV4E=; b=GSqm8+f2pUliM2187p3JAd6anmrUTX9j3MoxtmcrvJwcHU2lQ1LDICQFm8i2YrAQop IWfjVJYZANQBhHSIBzF6+bRwr6EMiNdevxhgMXT4lseIf++W1HC0VYP6J2V0JBTucPJ+ +VsjiDf1/zg90kcmtrexAU7qO2REV/ThVR6mIjZqQAsZU8Y23Nwt4ZRE/KcbX/vwYfBN a91Ig7swQAyFyGLeEhH5jo4U+GVZ3AqmFjfBT9Ilf8B+Zgs3IweMhvbyTUuKcOdNuBcW NyOpJqH6dD1Lm99SipAbijP9YgVVDrpnP/aIcmGvwmqRRA2555sQJV15lJmAG+jqHipk wa4A== X-Gm-Message-State: AOJu0Yx9LjPHCvffNifotcJ3KR6lOk2Lu+z7r6fNw0Dkp23zsnY7TBSZ 0Ir1Ni08/dhpfMzq9y8CcDX7lyBb5F7wbNF+doWCJBs3oJNMXAZ6LZ777Q== X-Gm-Gg: ASbGncvWtX/oqHHvQoBP58irKqM8p9dO6T/y+SGEJJ+ljce4PBaplt3K9v5DIn0eXJ9 6Id6EkRVaY93t8YdEf3DMD6v/iSaGOlTnEqSGdrBKzzAHh0vOozUUns8zRHVvKt114OwXRlIU3/ J5SDbT73lLf6jP3vSz9LSz+XV6ryjY92XOBsk3peqIGJL9wuzvwbAEWEqWj14xVcF0pVqinx5gu bgKSnpNCRZPo/D0W6F1V8zvZQFIHS6Qtnq+IwS1qa3lRvUXylABLNitWw== X-Google-Smtp-Source: AGHT+IGaqVDiDTgyYgpoHvavgOTZgrs6kADhCNwnXU4bkNvgPSpzFXE3Y5/f2UltLlRJyShrWVrLsg== X-Received: by 2002:a05:6870:4f14:b0:27c:a414:b907 with SMTP id 586e51a60fabf-29dc4305152mr4622962fac.33.1732750558864; Wed, 27 Nov 2024 15:35:58 -0800 (PST) Received: from denethor.localdomain ([136.50.74.45]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-29de8f31cefsm109260fac.2.2024.11.27.15.35.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Nov 2024 15:35:58 -0800 (PST) From: Justin Tobler To: git@vger.kernel.org Cc: Justin Tobler Subject: [PATCH v3 4/4] transport: propagate fsck configuration during bundle fetch Date: Wed, 27 Nov 2024 17:33:12 -0600 Message-ID: <20241127233312.27710-5-jltobler@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241127233312.27710-1-jltobler@gmail.com> References: <20241127005707.319881-1-jltobler@gmail.com> <20241127233312.27710-1-jltobler@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 When fetching directly from a bundle, fsck message severity configuration is not propagated to the underlying git-index-pack(1). It is only capable of enabling or disabling fsck checks entirely. This does not align with the fsck behavior for fetches through git-fetch-pack(1). Use the fsck config parsing from fetch-pack to populate fsck message severity configuration and wire it through to `unbundle()` to enable the same fsck verification as done through fetch-pack. Signed-off-by: Justin Tobler --- t/t5607-clone-bundle.sh | 7 +++++++ transport.c | 20 ++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/t/t5607-clone-bundle.sh b/t/t5607-clone-bundle.sh index 7ceaa8194d..c69aa88eae 100755 --- a/t/t5607-clone-bundle.sh +++ b/t/t5607-clone-bundle.sh @@ -171,6 +171,13 @@ test_expect_success 'clone bundle with different fsckObjects configurations' ' test_must_fail git -c transfer.fsckObjects=true \ clone bundle-fsck/bad.bundle bundle-transfer-fsck 2>err && + test_grep "missingEmail" err && + + git -c fetch.fsckObjects=true -c fetch.fsck.missingEmail=ignore \ + clone bundle-fsck/bad.bundle bundle-fsck-ignore && + + test_must_fail git -c fetch.fsckObjects=true -c fetch.fsck.missingEmail=error \ + clone bundle-fsck/bad.bundle bundle-fsck-error 2>err && test_grep "missingEmail" err ' diff --git a/transport.c b/transport.c index 8536b14181..6966df51a8 100644 --- a/transport.c +++ b/transport.c @@ -19,6 +19,7 @@ #include "branch.h" #include "url.h" #include "submodule.h" +#include "strbuf.h" #include "string-list.h" #include "oid-array.h" #include "sigchain.h" @@ -172,6 +173,19 @@ static struct ref *get_refs_from_bundle(struct transport *transport, return result; } +static int fetch_fsck_config_cb(const char *var, const char *value, + const struct config_context *ctx UNUSED, void *cb) +{ + struct strbuf *msg_types = cb; + int ret; + + ret = fetch_pack_fsck_config(var, value, msg_types); + if (ret > 0) + return 0; + + return ret; +} + static int fetch_refs_from_bundle(struct transport *transport, int nr_heads UNUSED, struct ref **to_fetch UNUSED) @@ -181,6 +195,7 @@ static int fetch_refs_from_bundle(struct transport *transport, }; struct bundle_transport_data *data = transport->data; struct strvec extra_index_pack_args = STRVEC_INIT; + struct strbuf msg_types = STRBUF_INIT; int ret; if (transport->progress) @@ -188,11 +203,16 @@ static int fetch_refs_from_bundle(struct transport *transport, if (!data->get_refs_from_bundle_called) get_refs_from_bundle_inner(transport); + + git_config(fetch_fsck_config_cb, &msg_types); + opts.fsck_msg_types = msg_types.buf; + ret = unbundle(the_repository, &data->header, data->fd, &extra_index_pack_args, &opts); transport->hash_algo = data->header.hash_algo; strvec_clear(&extra_index_pack_args); + strbuf_release(&msg_types); return ret; }