From patchwork Thu Feb 1 01:38:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Cai X-Patchwork-Id: 13540564 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.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 1CD664417 for ; Thu, 1 Feb 2024 01:38:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706751489; cv=none; b=qzBSUkVedlbfYcy003hM+GyaSdZBFSMKvqbArntWeWX34Qup04LqwzhEdE1EzegjD1H0Y5QVsgaQNBd6kfWghjucuus/VU8Rj1bLGnYjQejgHr0IB/BtJECzvUzKQy8BqD6q0jt6IY7OGpzfUqb+GhFGeWEs6C5v0dkCo24QXbo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706751489; c=relaxed/simple; bh=z73mdDzNaFG/F8/QUj7UaGTODOLyVEmawvUWo+PlGU0=; h=Message-ID:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=CiATcR52NqBq18h+iStcEeX35rGotQBSIz3m1Y1fKRbZ47vQpjepEEDTH56CPVbHaDNSPNnyCSZvprD8ICgVNPzf2Ov62cBMd0v5vDIty/G0p5gR/gQnNcOAiGxHtHi7w9FVA8DKUgon0K8JjpNJdNIU+6yfdpm+xEXFzmgPmbc= 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=VH/pmQp+; arc=none smtp.client-ip=209.85.128.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="VH/pmQp+" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-40ef75adf44so3694475e9.3 for ; Wed, 31 Jan 2024 17:38:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706751485; x=1707356285; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=UOOZa5dwNDVldGL3UVEGbXFAIPT2xntKxgTVQVWIFGQ=; b=VH/pmQp+UGJ2vigYcfBSiAt0Oy8QG5hFsjAOifi2vMJow7sRRrhvcwD4GYION1thmR Sj9GO6dNwEdNJiGtJDGNu8lSvtzIUXnLxpzlqzlkt+tZxI1h2/FusXq1gi64xVM9cmxR 7m1CqsYnBtK0yMMC25P0QfBpTqpQStISZQDfKQamRl5gr1ycz43JhSn6294UY1lfW7zN XnxNUqWw0oSCq+pb6WdH9K+pdUJjHGe0ci3HLsimWZnJq4ZNbKIbZA738FRW39U5N4bZ llpxdNy5vkgYQZbpJVDr/ckPLkh1GpBl/fJ4qHP8kezhjWjv6mwzQ8fVWlEEm1l56gNy bSCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706751485; x=1707356285; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UOOZa5dwNDVldGL3UVEGbXFAIPT2xntKxgTVQVWIFGQ=; b=NDjK09mQ201ptlrsHczHpeRsvU4SKp/YTUEL3tRueYUbh3a7QFbe+1xYDVYmvE+Pkg VoVynyIVM/C8KQ/d528AfGhL11102tsnD7gKI5nrWsyQIsWHANW5C5xV1GYrKx54A0sC xoGRrIdYbF7zQHYzD5OxT4gujnUBZww/FacReX+tBjcoLYmpjviMCJZo3KcHoWkjxW/D LX3TATrlv1t4oRQnlAC5rMptXkpjnjFsRP4Yod25q+j+/ZMeahpWd6UMdjVUSCydHi4r 9fyT/U8UOla+UI+ArBGikjmcRNi5zk86/Ndf2oaQtvZAPcOLcpe8DC1pdtUo9dZlJ5fp +hFA== X-Gm-Message-State: AOJu0YwsL4xLRMvX7JLwE2syc15LjRDXGgtYdc+bPEfB6QHXrQ0TYigS 1bppmEBq9bKbvaa3GwutGq3udfUJkX+iGM/WKZi0Fn6RLdsa3yHhwBUFlla6 X-Google-Smtp-Source: AGHT+IEfbP44k4jmlSRJHE5PmxvJwRxEMKCq5qQtVnROpxbBs9ad33rlsZGp7TZbEVIyvtvy6ei+Rw== X-Received: by 2002:a05:600c:1d0a:b0:40e:a32c:988d with SMTP id l10-20020a05600c1d0a00b0040ea32c988dmr2550150wms.4.1706751484793; Wed, 31 Jan 2024 17:38:04 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCU5Ic1ocwpkF7VGvHlBXgjP6rVYfKVdw2J0gJQ/UoGNMlmuLARAyQwVaiOfeNXnCNfDz0K/0PwTZAOsswlc6Ixb8K3ZzefaYBXSvm3qVYQ= Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id bk24-20020a0560001d9800b0033add8aa1d2sm14347971wrb.44.2024.01.31.17.38.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 17:38:04 -0800 (PST) Message-ID: In-Reply-To: References: Date: Thu, 01 Feb 2024 01:38:01 +0000 Subject: [PATCH v4 1/2] index-pack: test and document --strict==... Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: Jonathan Tan , Patrick Steinhardt , John Cai , John Cai From: John Cai From: John Cai 5d477a334a (fsck (receive-pack): allow demoting errors to warnings, 2015-06-22) allowed a list of fsck msg to downgrade to be passed to --strict. However this is a hidden argument that was not documented nor tested. Though it is true that most users would not call this option directly, (nor use index-pack for that matter) it is still useful to document and test this feature. Reviewed-by: Christian Couder Signed-off-by: John Cai --- Documentation/git-index-pack.txt | 9 +++++++-- builtin/index-pack.c | 2 +- t/t5300-pack-object.sh | 22 ++++++++++++++++++++++ 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/Documentation/git-index-pack.txt b/Documentation/git-index-pack.txt index 6486620c3d8..694bb9409bf 100644 --- a/Documentation/git-index-pack.txt +++ b/Documentation/git-index-pack.txt @@ -79,8 +79,13 @@ OPTIONS to force the version for the generated pack index, and to force 64-bit index entries on objects located above the given offset. ---strict:: - Die, if the pack contains broken objects or links. +--strict[==...]:: + Die, if the pack contains broken objects or links. An optional + comma-separated list of `=` can be passed to change + the severity of some possible issues, e.g., + `--strict="missingEmail=ignore,badTagName=error"`. See the entry for the + `fsck.` configuration options in linkgit:git-fsck[1] for more + information on the possible values of `` and ``. --progress-title:: For internal use only. diff --git a/builtin/index-pack.c b/builtin/index-pack.c index 1ea87e01f29..240c7021168 100644 --- a/builtin/index-pack.c +++ b/builtin/index-pack.c @@ -24,7 +24,7 @@ #include "setup.h" static const char index_pack_usage[] = -"git index-pack [-v] [-o ] [--keep | --keep=] [--[no-]rev-index] [--verify] [--strict] ( | --stdin [--fix-thin] [])"; +"git index-pack [-v] [-o ] [--keep | --keep=] [--[no-]rev-index] [--verify] [--strict[==...]] ( | --stdin [--fix-thin] [])"; struct object_entry { struct pack_idx_entry idx; diff --git a/t/t5300-pack-object.sh b/t/t5300-pack-object.sh index d402ec18b79..496fffa0f8a 100755 --- a/t/t5300-pack-object.sh +++ b/t/t5300-pack-object.sh @@ -441,6 +441,28 @@ test_expect_success 'index-pack with --strict' ' ) ' +test_expect_success 'index-pack with --strict downgrading fsck msgs' ' + test_when_finished rm -rf strict && + git init strict && + ( + cd strict && + test_commit first hello && + cat >commit <<-EOF && + tree $(git rev-parse HEAD^{tree}) + parent $(git rev-parse HEAD) + author A U Thor + committer A U Thor + + commit: this is a commit with bad emails + + EOF + git hash-object --literally -t commit -w --stdin commit_list && + PACK=$(git pack-objects test X-Patchwork-Id: 13540565 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (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 45630442A for ; Thu, 1 Feb 2024 01:38:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706751490; cv=none; b=dcOYU0Kscg0aW42XonFs8jPLCNjB37gwlQaOnq72r2FtSmCiJUFG5lu46LF/Kq8zfiaa7KQEfpjyhbO02C7pKBuftq9oD+gSRVGyiLOJTJGmB2kGKBnpQgqNxHEWuID5JAjWrg9P/Pm1QrtG8t3IOULlejCTZwAGr+OsrOciYOY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706751490; c=relaxed/simple; bh=6f3ymxW7go7bTXLUj3ASGa9fCnHupGQjdk3TttkOwqI=; h=Message-ID:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=mh+0F7yJ0c2uyIQj66IqRoxagsDeZCc0NHOD0WozhHv5Xr34kDeV0hSU8iUAD/dVCKkmwpKsSAaymauhj4r4CxES/ybXezSebkJsqhrCAnZoOoDeCT+lnmP07zCpCNs5sv2nZRu3qyoybrdT6F81YHQwXN8fH+Ba2fZjJhsoPI4= 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=EZCc0hmw; arc=none smtp.client-ip=209.85.128.42 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="EZCc0hmw" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-40e7e2e04f0so3782855e9.1 for ; Wed, 31 Jan 2024 17:38:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706751486; x=1707356286; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=2xVEioQQprtkdsv60zjjAfM3AVj5k/Vci4ZMkyUX2is=; b=EZCc0hmwC82hAyhqRcf55bhc96fV0UEj4E1GY1oEKc8T1BZJUpmAG182vdfPp8OMZi rmCGz9ghxgDZHuFEBzrslfvYaeXClJDQBX0t2Cg7t4HtfndXgXBV5gWFbYyA7s7SFdkd GRn74LFqH5tvQYIRXhaJUVxNOGgtFQsimerIyQf77UsSfaN8AGCEGq0d67HOqPowry4I NNwUkXlq0Wnv71lEsT8i4SBS8wDl+MiKMAZlYvFue4mcV6t/Co09iGiHziC8VVuQ1kUv JlZXyI39WWtNJd0CF88lvWwKdB1TA0RXDvz4+4tNMerfjIMaYRaqlBarEqoG0BLGgsTB oE4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706751486; x=1707356286; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2xVEioQQprtkdsv60zjjAfM3AVj5k/Vci4ZMkyUX2is=; b=djh+lKSol78iLrQk7jVl61ObFN4eTLtnr9StvWJ9XnGcxAzHoDbbnNukM7/zgqI6sH KP710rqZqdc/Gs10VUVbo3Drmpl9OUuiRj03dxsPn53kdYkhxCXPh5ED/Yrrt6/r3Xm4 wTzNvR1T7SDrpocP+iN1uLRSjOpcbPmG21kwz5P/0ewLIVp6uoD3HRlR7+4zhtBmP4ha auz4JSbOvTo9naUvl1L1S+h+oWjaNXHCafqWdTteaOz83cr2W2DaBH483IaIKXmhLRHR W93jZ9YGi9Qpa+5XHC3iZj9JvglT8VuYcSx6ITzUlmquYIdezHohspReiRckt8mv9yNM XCuw== X-Gm-Message-State: AOJu0YwSgiI69wfVlQsgEZRx++gVCKTyfultH25sScpeNEpyZYTL1ALp dOSEgM2jdCr/4gNrUVB/zR7BePy8tqJnATo4wMHDQ9lxIxbK+KAl6lryKpsc X-Google-Smtp-Source: AGHT+IHBxJxuHyQJbqNPiic1qVmu32v2N6q6xTw2y8ATkW9DZ3fZjLt4yNOXo/QU1Y0KWTRPtOXYBQ== X-Received: by 2002:a05:600c:3b96:b0:40e:b17d:2f56 with SMTP id n22-20020a05600c3b9600b0040eb17d2f56mr2249588wms.23.1706751485824; Wed, 31 Jan 2024 17:38:05 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCWUq0hLBfvqqZguxkQQdDgCm3jf9sfRDPSG1KUdh3XgzMXxhBUNSVOnS3ji36znBZSpMXxkfurt3yw3mhQnGvThWCEVFSeRqRJOHDJ1wEY= Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id c3-20020a05600c0a4300b0040e541ddcb1sm2971510wmq.33.2024.01.31.17.38.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 17:38:05 -0800 (PST) Message-ID: In-Reply-To: References: Date: Thu, 01 Feb 2024 01:38:02 +0000 Subject: [PATCH v4 2/2] index-pack: --fsck-objects to take an optional argument for fsck msgs Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: Jonathan Tan , Patrick Steinhardt , John Cai , John Cai From: John Cai From: John Cai git-index-pack has a --strict option that can take an optional argument to provide a list of fsck issues to change their severity. --fsck-objects does not have such a utility, which would be useful if one would like to be more lenient or strict on data integrity in a repository. Like --strict, allow --fsck-objects to also take a list of fsck msgs to change the severity. Remove the "For internal use only" note for --fsck-objects, and document the option. This won't often be used by the normal end user, but it turns out it is useful for Git forges like GitLab. Reviewed-by: Christian Couder Signed-off-by: John Cai --- Documentation/git-index-pack.txt | 17 +++++++++++------ builtin/index-pack.c | 5 +++-- t/t5300-pack-object.sh | 29 ++++++++++++++++++++++++----- 3 files changed, 38 insertions(+), 13 deletions(-) diff --git a/Documentation/git-index-pack.txt b/Documentation/git-index-pack.txt index 694bb9409bf..5a20deefd5f 100644 --- a/Documentation/git-index-pack.txt +++ b/Documentation/git-index-pack.txt @@ -96,13 +96,18 @@ default and "Indexing objects" when `--stdin` is specified. --check-self-contained-and-connected:: Die if the pack contains broken links. For internal use only. ---fsck-objects:: - For internal use only. +--fsck-objects[==...]:: + Die if the pack contains broken objects, but unlike `--strict`, don't + choke on broken links. If the pack contains a tree pointing to a + .gitmodules blob that does not exist, prints the hash of that blob + (for the caller to check) after the hash that goes into the name of the + pack/idx file (see "Notes"). + -Die if the pack contains broken objects. If the pack contains a tree -pointing to a .gitmodules blob that does not exist, prints the hash of -that blob (for the caller to check) after the hash that goes into the -name of the pack/idx file (see "Notes"). +An optional comma-separated list of `=` can be passed to +change the severity of some possible issues, e.g., +`--fsck-objects="missingEmail=ignore,badTagName=ignore"`. See the entry for the +`fsck.` configuration options in linkgit:git-fsck[1] for more +information on the possible values of `` and ``. --threads=:: Specifies the number of threads to spawn when resolving diff --git a/builtin/index-pack.c b/builtin/index-pack.c index 240c7021168..a3a37bd215d 100644 --- a/builtin/index-pack.c +++ b/builtin/index-pack.c @@ -24,7 +24,7 @@ #include "setup.h" static const char index_pack_usage[] = -"git index-pack [-v] [-o ] [--keep | --keep=] [--[no-]rev-index] [--verify] [--strict[==...]] ( | --stdin [--fix-thin] [])"; +"git index-pack [-v] [-o ] [--keep | --keep=] [--[no-]rev-index] [--verify] [--strict[==...]] [--fsck-objects[==...]] ( | --stdin [--fix-thin] [])"; struct object_entry { struct pack_idx_entry idx; @@ -1785,8 +1785,9 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix) } else if (!strcmp(arg, "--check-self-contained-and-connected")) { strict = 1; check_self_contained_and_connected = 1; - } else if (!strcmp(arg, "--fsck-objects")) { + } else if (skip_to_optional_arg(arg, "--fsck-objects", &arg)) { do_fsck_object = 1; + fsck_set_msg_types(&fsck_options, arg); } else if (!strcmp(arg, "--verify")) { verify = 1; } else if (!strcmp(arg, "--verify-stat")) { diff --git a/t/t5300-pack-object.sh b/t/t5300-pack-object.sh index 496fffa0f8a..a58f91035d1 100755 --- a/t/t5300-pack-object.sh +++ b/t/t5300-pack-object.sh @@ -441,8 +441,7 @@ test_expect_success 'index-pack with --strict' ' ) ' -test_expect_success 'index-pack with --strict downgrading fsck msgs' ' - test_when_finished rm -rf strict && +test_expect_success 'setup for --strict and --fsck-objects downgrading fsck msgs' ' git init strict && ( cd strict && @@ -457,12 +456,32 @@ test_expect_success 'index-pack with --strict downgrading fsck msgs' ' EOF git hash-object --literally -t commit -w --stdin commit_list && - PACK=$(git pack-objects test pack-name ) ' +test_with_bad_commit () { + must_fail_arg="$1" && + must_pass_arg="$2" && + ( + cd strict && + test_expect_fail git index-pack "$must_fail_arg" "test-$(cat pack-name).pack" + git index-pack "$must_pass_arg" "test-$(cat pack-name).pack" + ) +} + +test_expect_success 'index-pack with --strict downgrading fsck msgs' ' + test_with_bad_commit --strict --strict="missingEmail=ignore" +' + +test_expect_success 'index-pack with --fsck-objects downgrading fsck msgs' ' + test_with_bad_commit --fsck-objects --fsck-objects="missingEmail=ignore" +' + +test_expect_success 'cleanup for --strict and --fsck-objects downgrading fsck msgs' ' + rm -rf strict +' + test_expect_success 'honor pack.packSizeLimit' ' git config pack.packSizeLimit 3m && packname_10=$(git pack-objects test-10