From patchwork Fri Jan 26 17:12:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Cai X-Patchwork-Id: 13532897 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (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 B112D1EA7D for ; Fri, 26 Jan 2024 17:13:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706289187; cv=none; b=MqjYTtyUFOyxwWaItoJPc3Bq3mK49aXF8ZaODLE/KQXO1kbClQS0DSD8ZOORNHyEfvvLgJ/DJnz4QkkjyQcp2kfr1AKeb91GlHanzuwfqNU3lRmWqK+jErIwWzXzd7Iq+F+swqBhX8w1WMoDpx2ksUvd0TItomiciDApGOvU2Ng= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706289187; c=relaxed/simple; bh=tuKf+RwY7GtXE76x4ySPNqJGiPLqQ8oGIymxbEAqh0s=; h=Message-ID:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=hH7BxjMOzjSn/jX1BD9gr2bVI9mIv+hp3CHrX2LdibTG21b6+g/gsraAJXuXZktFOa/9o7T7vE/s+FhTF1SGka0NbnrHX2zWDg1/PnfeYsp+r0szukmbPwqMg0sMkdb+TjqknS7wgZ2Vi0PqRpg3O3Qlo1HCLjtAxHBPsGyJtnc= 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=RnjZX9N6; arc=none smtp.client-ip=209.85.128.46 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="RnjZX9N6" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-40ed3101ce3so12967445e9.2 for ; Fri, 26 Jan 2024 09:13:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706289183; x=1706893983; 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=aC8jWT/C7WqkDa1vvGgTXcbRk3q+dtF07loxlkg2IKM=; b=RnjZX9N6p78cA13N5+UtnjfG36rrV0Zpsdcecq2Pr62nLTSy3lZz/vaQQdrb/6LGKd jf9iXhu6KNGkp8G4EkemzMMZy2UvsOcice74/ZkPZ9naagchA0khnqId2HgQyKQnkbo6 jXvfRm5p8TOVJ8DctFnx3EaMt0/cN4il+3NsOw5k8hY1Rw57ZXAVGmc0X3CNhmXukI3b CwkaVl+j9Ll8bPaK/19aRoQk884Y8TnSng9jjcYNOCDL+/7JMgKBUT4/I84rdApt0fDm Xr8ehhGifUCcXFogL7LPeC8l9Cvxek0dT18UyyR4X8Ydm+PdrDHHjP7fU1aVdCIT1ef+ MDbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706289183; x=1706893983; 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=aC8jWT/C7WqkDa1vvGgTXcbRk3q+dtF07loxlkg2IKM=; b=Lc/VKlWzy5gv8felg+udf5MeqZhsRf1r8CJyClF+MYKhSK43Yb116LqeZK5F/d182m fXUVhtO48lgir6t2hfk/l0wia9zsX/kRfyCv9k3/0Iop7JYithPgW//j4sxUkx6dtam/ 3FUhkXr3VfUO+f+IlvUjvA2Vy5UCU48e13eIYcKx8Qv5OqEV3JjQneBmxn9BQh0K+wyt vGg/kzc3M+1QDlF69fJvC1wEDyWV+k3TfpTrxpLkRbFqnjYNaHcfmnHgP8QPo/F5JTSl qiG95mdeUT3RnbioYl3wulfF6dTMkcCXHrZ17RrdiaFxZhrzcaMQu0nyrK36VRbQCMVN OdNw== X-Gm-Message-State: AOJu0Yz2DZru1g0kYQaa1HnAkV3uMBU/GKNrFqVb+UjMYroHIIBdXra2 iGxApLe/jSFVcuX9eDR+XbvGjmhsM9IzAWoMuh/dkfV+woYTKbGsCz+Iomus X-Google-Smtp-Source: AGHT+IEsMNLc42ymKnSAFmy+kMTCY2b3sHmApzLMexcdPGgdRt+49unzoaNWqoOtS2MZ980HOJlVwQ== X-Received: by 2002:a05:600c:1c1b:b0:40e:7e40:10c6 with SMTP id j27-20020a05600c1c1b00b0040e7e4010c6mr50003wms.182.1706289182991; Fri, 26 Jan 2024 09:13:02 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id f19-20020a05600c155300b0040e541ddcb1sm2435640wmg.33.2024.01.26.09.13.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 09:13:02 -0800 (PST) Message-ID: In-Reply-To: References: Date: Fri, 26 Jan 2024 17:12:59 +0000 Subject: [PATCH v2 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: 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. 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..f7a98bbf9c8 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. If `` is passed, + it should be a comma-separated list of `=` elements where + `` and `` are used 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..1e53ca23775 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: 13532898 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (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 ED5081EB3D for ; Fri, 26 Jan 2024 17:13:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706289187; cv=none; b=XUNdxxLhdrKetXQ748jSNn19mOPp4swlSSgKj60DONYcdABvf4SYrgRpsYX0N7LGjiGUPoQ2qh+J6SyBAgH1m/YV69mxbwYOTKDnktOfRAarp+RVJVSoqIejyOxDLrXW95ApPwdfck5/+oFormqeJkl0R/OwVWwDLiuXbshZmYM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706289187; c=relaxed/simple; bh=m4IM3M3fnzvHGTJIInUYW+mIddH+rgmR7zkVFDsVnPA=; h=Message-ID:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=dKZOHJr+X8dWl9LW5aDi6OHPda30NsEUCFNQ/JEKxNE2jOU7MZTVhK0flAQyA6pxHuOVm+W9bk4cu9+ELzsPkwzOvudN7zeTCktFZbQiJe1gfYpBB95Mo2uVZ+vZnFfNYaKRMWB89ullS48vvr9MxmfagoDM6Sju4A8UEwTq+xc= 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=Lp6qNihW; arc=none smtp.client-ip=209.85.128.52 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="Lp6qNihW" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-40ed356a6ecso4883135e9.2 for ; Fri, 26 Jan 2024 09:13:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706289184; x=1706893984; 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=R8Bg2/Wt0GmYkE9Durb96bgw18SOTtvXu9iXETYma0M=; b=Lp6qNihWHwI7aRWS0hsTWc+5ptt/WhfOsZW/a9Dyb1oZ7WqTZfhl9bOUF+K3vUJUNE 1nPAbxgj9ojM7HlUHq10yFnKs2UE7VGaDmMR4GGiZM3dxbbrP9CUCMV4qfe/+cLnYl/T y/X74H/+1uqscXwNo6zyr9q39tnWFPCDueM/8VJCDhJY/pzNuEp6t9e8M/U+wx45JetS RQC2duUP+8i+w1rJluJXUs5wlNJnlzOsf1zMndrf07+7zo55rAYfgLkoJW5RWiJa+eOS pIS4IGy+P0jbjoaCRHvXEOPCLu92ApDg/rqFa4Ykq0NjaK/QlxILtdY7Qm/ynjiP54ar tbBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706289184; x=1706893984; 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=R8Bg2/Wt0GmYkE9Durb96bgw18SOTtvXu9iXETYma0M=; b=KSdwnnSvkT0cTC6V02wPIqveHuahPJZdmR6C2KIZyHKXfQLJuZV9J4iKG8xokqzMQd /Tee14eqBPjk+SdedKTD9C/KmxiG3u0/DILWCO/hpFJ9uuIkJGYOivsvJyqLnDD4VTIb MaYbFu1OcuwzhVbJqyPrbU1yeu9Rm0nl8LqZrUuuFs8Wed/KueRY02xCbSz/1GsU3JIb 7VnvRjDoUUS2vyDXkCnnSjLZ1VAvBMloduH7MXJ09xWUtlvDfsdE97xuw7I5sBNuOXh5 wza9V85AlznpJi2/iUCDg8v4LGIJrA+pztiiwsy7XRg11T3UI/qJeSO61o7lv7NvHK7f 9gKA== X-Gm-Message-State: AOJu0Yz5rhgH0L8thQ74Gx/GzpjnQvs+aRZBdipPp4V4XZ7O6emQq3X/ CqGrdh++fVKkNQmgAL7xDuZ7FNZ2zs/YnBhGTe+eBhV6UedLPNlpvwyHGNtD X-Google-Smtp-Source: AGHT+IE1JrvRBZZHF3XTvEISlgygUv1qUBmjERYsi8iZ/p+4FHCN5pt1l5wBZSpqgd920SF/hsXvVg== X-Received: by 2002:a5d:5191:0:b0:33a:dfe1:9004 with SMTP id k17-20020a5d5191000000b0033adfe19004mr24961wrv.47.1706289183502; Fri, 26 Jan 2024 09:13:03 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id v15-20020adfedcf000000b00336898daceasm1636194wro.96.2024.01.26.09.13.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 09:13:03 -0800 (PST) Message-ID: In-Reply-To: References: Date: Fri, 26 Jan 2024 17:13:00 +0000 Subject: [PATCH v2 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: 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. Signed-off-by: John Cai --- Documentation/git-index-pack.txt | 10 ++++++++-- builtin/index-pack.c | 5 +++-- t/t5300-pack-object.sh | 29 ++++++++++++++++++++++++----- 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/Documentation/git-index-pack.txt b/Documentation/git-index-pack.txt index f7a98bbf9c8..916652d3b1b 100644 --- a/Documentation/git-index-pack.txt +++ b/Documentation/git-index-pack.txt @@ -96,8 +96,14 @@ 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[==...]:: + Instructs index-pack to check for broken objects, but unlike `--strict`, + does not choke on broken links. If `` is passed, it should be + a comma-separated list of `=` where `` and + `` are used to change the severity of `fsck` errors e.g., + `--strict="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 ``. + 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 diff --git a/builtin/index-pack.c b/builtin/index-pack.c index 1e53ca23775..519162f5b91 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