From patchwork Tue Jan 5 19:42:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12000257 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A08DFC433DB for ; Tue, 5 Jan 2021 19:44:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6671D22D6F for ; Tue, 5 Jan 2021 19:44:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730884AbhAEToN (ORCPT ); Tue, 5 Jan 2021 14:44:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728071AbhAEToJ (ORCPT ); Tue, 5 Jan 2021 14:44:09 -0500 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47DF3C061793 for ; Tue, 5 Jan 2021 11:43:29 -0800 (PST) Received: by mail-wm1-x32e.google.com with SMTP id c124so583041wma.5 for ; Tue, 05 Jan 2021 11:43:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TE/H6ocKosx2Jp2qItIeJhggW3gbgKvO2QtcAZMksw0=; b=sTR6KONyUTZuW205gtlbinmr31e3YujpjR5c2z7lA8ZkhIYrbdPRf2rupZqNjR0ChY /hw1anoaNF64JfniGvkVIxQKqO4SIZQ4ye3gyy3jimvuloRZn+J5nh8RuEIFIk9nTrlN +A4YEvij9dW40tjarWYBDvOL+wttVFHvu2VJd4N+JgBZC/wrjKyUL0W9NzjdMFXTqUE5 0jGCpj49tLK/IIpJSuMeMHebq1TO6430PSK7grih0+7wMEXRv1zdCULGOToC8xwKp88J YqDGLSWM5ItOXci7vXyo/562BT8NIS+p1WhGNrcR3hLf1a3VWjJZeO5PVry3NWgvKP3S FLQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TE/H6ocKosx2Jp2qItIeJhggW3gbgKvO2QtcAZMksw0=; b=Pmds81cr05NEjrCHMQsX3zSUYAQsqkc8Ba9MqSH8wKabgR9K4R07ptVx3N8GIJANmE +uZDdpkS41o3le4vpb+P5qhrfIYVNQPcZa+31zrN0vtvpwd4B0arJIMRXZmvLaXL/lxX 7fdqx1U4qWSSnQ6H+2vmbB3yaToRml7PJXDe1Tv88ApZff95XOqZtlPrC8OcjjRZfyEs n61ZMKIfatq9Qd9e4smHPwCHefqzMPCynIcLdEiyOi4b6PZE6WcBw+4MxDH7Pm4btwkE ZkZc/awdFrbPtWP4tehfL3aBg6KlK4bqIReOBLKpCndDdChLM8rk5SBgkx9uzxNOOMeG 50nw== X-Gm-Message-State: AOAM530k6SNZldTuUILNTQl5/LJoOM7ixjgcMjI91a4MG+JO9R74Sb0F gfZn9bPFXnz9hu/GdFl/ixUXWBElJvkIfw== X-Google-Smtp-Source: ABdhPJxFszPTBl9QUuVnYhjHZZ7h5RH9DtqXNy8hykdtKZrSA5J6s1nEyL1Qy3PVbCIHJasBMxRqsQ== X-Received: by 2002:a1c:6205:: with SMTP id w5mr661583wmb.26.1609875807833; Tue, 05 Jan 2021 11:43:27 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id s6sm151113wro.79.2021.01.05.11.43.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 11:43:27 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , "brian m . carlson" , Eric Sunshine , Johannes Schindelin , =?utf-8?q?SZEDER_G=C3=A1b?= =?utf-8?q?or?= , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v5 01/23] mktag doc: say not Date: Tue, 5 Jan 2021 20:42:30 +0100 Message-Id: <20210105194252.627-2-avarab@gmail.com> X-Mailer: git-send-email 2.29.2.222.g5d2a92d10f8 In-Reply-To: <20201223013606.7972-1-avarab@gmail.com> References: <20201223013606.7972-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Change the "mktag" documentation to refer to the input hash as just "hash", not "sha1". This command has supported SHA-256 for a while now. Signed-off-by: Ævar Arnfjörð Bjarmason --- Documentation/git-mktag.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/git-mktag.txt b/Documentation/git-mktag.txt index fa6a7561236..a158428eb9f 100644 --- a/Documentation/git-mktag.txt +++ b/Documentation/git-mktag.txt @@ -23,7 +23,7 @@ Tag Format A tag signature file, to be fed to this command's standard input, has a very simple fixed format: four lines of - object + object type tag tagger From patchwork Tue Jan 5 19:42:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12000263 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CF78CC433E9 for ; Tue, 5 Jan 2021 19:44:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A4B2422D74 for ; Tue, 5 Jan 2021 19:44:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730896AbhAEToO (ORCPT ); Tue, 5 Jan 2021 14:44:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730878AbhAEToL (ORCPT ); Tue, 5 Jan 2021 14:44:11 -0500 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62E02C061795 for ; Tue, 5 Jan 2021 11:43:30 -0800 (PST) Received: by mail-wr1-x42f.google.com with SMTP id m5so327485wrx.9 for ; Tue, 05 Jan 2021 11:43:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wwUGvVur+FvIq4/QiGKaq0bgr2Q0NO9gp1We0037vu0=; b=JrkiuciiZ4sLW0HSjMGfTjdBrHx9U6wZGggXw1jlY/e1jdG6L4xFccObC8FUXazMzm QtmeBsYwakKnuYAVWk9usAUeC0Zqs6XA4HzT3o8MCvTC0XM2jZXHlu7hoZUi+mfTcTTF 0TBodYjf8mAR5bAglxvV20vQbhJFVYhifert4DPKU8M+bia6y8k6s92GAvJSXe/4ndNz qagFB063y94IKcqfqV+rK+NcWKXlZSelP8PeiUq04KQ3I7KqhfItbwcP5mOphaAlfYT6 tgoBfoNPJLqEyPsgLSdVBHCmFF05OaeNLR+X7h9evVYsXaxl45H+u8nB3GdgVNdZZCwO CJCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wwUGvVur+FvIq4/QiGKaq0bgr2Q0NO9gp1We0037vu0=; b=kp+DOQpQffVe0POFcI2tJZcov9NUIlnNARLUAwG5L+qGzPNTDOchLTSBaGpYHDeU7A e531WWZce1bQLsimPefRLXtG9vlyit7huNl24abfOq0huVfIbx+lO+0xQBld2T8nn8xQ 7JCGexcl9Wa9JTRbkjbANPfRU9Q0w8XVLoAC3NBWOuBAZFhIgFiAyVFb/qKMgiWVvdQm 8OAbuNIv6UrjyS/czROtAXbUJ0kBwJGMKEhRP8TmghwuqlJMyWtw76V+30o31eRXG2v8 3+1nar0XtMfpyJ0E/UFgeo+r85MxIzEvzbD6i0TPKomHJleDL9k5ef87ATczOWTh+M9S K9Yw== X-Gm-Message-State: AOAM531UIXmS8jrlcAtIsFAGCoBWFYG3vG3pdxWb8/+6+eiaDz96auym sfaCEUt2TPqHKzynrYwO5iaGqa6tZB+faA== X-Google-Smtp-Source: ABdhPJxb0ARPyZVM2A0cw885rYZlQ4c8C1rxOs3Cz7gXgwZ3/xeMXT0LpoQ1y8YZqFf7OS2NHicXrg== X-Received: by 2002:adf:ba49:: with SMTP id t9mr1067185wrg.183.1609875808903; Tue, 05 Jan 2021 11:43:28 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id s6sm151113wro.79.2021.01.05.11.43.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 11:43:28 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , "brian m . carlson" , Eric Sunshine , Johannes Schindelin , =?utf-8?q?SZEDER_G=C3=A1b?= =?utf-8?q?or?= , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v5 02/23] mktag doc: grammar fix, when exists -> when it exists Date: Tue, 5 Jan 2021 20:42:31 +0100 Message-Id: <20210105194252.627-3-avarab@gmail.com> X-Mailer: git-send-email 2.29.2.222.g5d2a92d10f8 In-Reply-To: <20201223013606.7972-1-avarab@gmail.com> References: <20201223013606.7972-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Amend the wording of documentation added in 6cfec03680 (mktag: minimally update the description., 2007-06-10). It makes more sense to say "when it exists" here, as we're referring to "the message". Signed-off-by: Ævar Arnfjörð Bjarmason --- Documentation/git-mktag.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/git-mktag.txt b/Documentation/git-mktag.txt index a158428eb9f..1b0667e372a 100644 --- a/Documentation/git-mktag.txt +++ b/Documentation/git-mktag.txt @@ -29,7 +29,7 @@ has a very simple fixed format: four lines of tagger followed by some 'optional' free-form message (some tags created -by older Git may not have `tagger` line). The message, when +by older Git may not have `tagger` line). The message, when it exists, is separated by a blank line from the header. The message part may contain a signature that Git itself doesn't care about, but that can be verified with gpg. From patchwork Tue Jan 5 19:42:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12000259 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B1F7BC433E6 for ; Tue, 5 Jan 2021 19:44:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 84AB622D72 for ; Tue, 5 Jan 2021 19:44:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730892AbhAEToO (ORCPT ); Tue, 5 Jan 2021 14:44:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730880AbhAEToL (ORCPT ); Tue, 5 Jan 2021 14:44:11 -0500 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6709DC061796 for ; Tue, 5 Jan 2021 11:43:31 -0800 (PST) Received: by mail-wm1-x331.google.com with SMTP id g185so623333wmf.3 for ; Tue, 05 Jan 2021 11:43:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=V1YEaCkjPz0KNEeXzNPgbWhGO2r4fyI1mxyNllWJhA8=; b=aPxFgKc4fjiEoPXV5csHpGeTgivawbc2yomYmAS0kWpuvzlQnSfKhnOswBesLB0cHK LkgVrdFCrGB4EZsRBIddrYLP4svY1iafo31PGS3MlV4b0C/qPZe4HwYb+mslmK/ismRN 4xlfpmPtHC+2hcYciojSmlyDDIj98o6PbDBLy0eInmBuGXWNJmnwWQ/PiLmtUPofMRJI DqkAnMtiQH1OfmOlUteFlVkc1sitYk05AQutQw2e5X2gZMAFt7LXar8/FhgVzKH8tIe4 ua0xwKUO12bsLufK8v1U8EFNfH71ffXYFFY4saiQwwW4Hb5VRv7uFT5nMM6wQmO3KvVg 6BiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=V1YEaCkjPz0KNEeXzNPgbWhGO2r4fyI1mxyNllWJhA8=; b=dnrwMSRN99MdY5f6q4gWdddv55yT8P+Rl7106TWdnuYdzfsZ8NjahCd+oZWVQ4+tpl igiaEt4AFiv2ltPR0a8i17/kL+jwubQNfoSNvdDU/wZ9RfiB808yOD+g6o3UvTVJ5o/R GUP6JGfirOvv0M+3JSD9/VfTfcw8yvnmvLZyEwf/ocza0Ag9M+I13l+mvvL0LDUBYpTR 3j4089Eg9o/GqCwwRuc1YFeTt2PwCCz2GIqr3oPw/j6EFRx1c0AK/RkSkhAcXdTjM3B5 ufh2Be4xorAfDxyohzDs0gw8n25nOpshqF1ftgFvb7lH3pEuwVk8xCzmZO6pNKfFlWpr /FqQ== X-Gm-Message-State: AOAM53138uLyk01xwbHNGA6XyefksGYrhEm6iRA4Sv9/MyysMRYjS4EW JlEKL8xcvesj0+exBqO6c86qDE80Uq8KUw== X-Google-Smtp-Source: ABdhPJytFWrp2ac0KlICs50k30yYbKY6VhOXP5wSGb+AI0PfY4FrxX+9lH9E5VVaroWnGw1WCzGZNg== X-Received: by 2002:a7b:c773:: with SMTP id x19mr581563wmk.127.1609875809957; Tue, 05 Jan 2021 11:43:29 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id s6sm151113wro.79.2021.01.05.11.43.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 11:43:29 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , "brian m . carlson" , Eric Sunshine , Johannes Schindelin , =?utf-8?q?SZEDER_G=C3=A1b?= =?utf-8?q?or?= , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v5 03/23] mktag doc: update to explain why to use this Date: Tue, 5 Jan 2021 20:42:32 +0100 Message-Id: <20210105194252.627-4-avarab@gmail.com> X-Mailer: git-send-email 2.29.2.222.g5d2a92d10f8 In-Reply-To: <20201223013606.7972-1-avarab@gmail.com> References: <20201223013606.7972-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Change the mktag documentation to compare itself to the similar "hash-object -t tag" command. Before this someone reading the documentation wouldn't have much of an idea what the difference was. Let's allude to our own validation logic, and cross-link the "mktag" and "hash-object" documentation to aid discover-ability. A follow-up change to migrate "mktag" to use "fsck" validation will make the part about validation logic clearer. Signed-off-by: Ævar Arnfjörð Bjarmason --- Documentation/git-mktag.txt | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Documentation/git-mktag.txt b/Documentation/git-mktag.txt index 1b0667e372a..20af1915e9e 100644 --- a/Documentation/git-mktag.txt +++ b/Documentation/git-mktag.txt @@ -3,7 +3,7 @@ git-mktag(1) NAME ---- -git-mktag - Creates a tag object +git-mktag - Creates a tag object with extra validation SYNOPSIS @@ -13,10 +13,19 @@ SYNOPSIS DESCRIPTION ----------- -Reads a tag contents on standard input and creates a tag object -that can also be used to sign other objects. -The output is the new tag's identifier. +Reads a tag contents on standard input and creates a tag object. The +output is the new tag's identifier. + +This command is mostly equivalent to linkgit:git-hash-object[1] +invoked with `-t tag -w --stdin`. I.e. both of these will create and +write a tag found in `my-tag`: + + git mktag X-Patchwork-Id: 12000261 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E2BF9C43381 for ; Tue, 5 Jan 2021 19:44:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BFEFF22D6F for ; Tue, 5 Jan 2021 19:44:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730887AbhAEToO (ORCPT ); Tue, 5 Jan 2021 14:44:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730882AbhAEToN (ORCPT ); Tue, 5 Jan 2021 14:44:13 -0500 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BD82C061798 for ; Tue, 5 Jan 2021 11:43:32 -0800 (PST) Received: by mail-wr1-x432.google.com with SMTP id r3so364243wrt.2 for ; Tue, 05 Jan 2021 11:43:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LMaLfHsrFtR5TbYrAS2TUcw4yJ/c8dS9VHRIf5BDh/o=; b=Te9611pfANkc1f34KVNPH28Lx0cG/O8b+YKepg+qVygHXJ3/BQcTEUvTiIYjgqSa3n mnwR17gZneg+cTq9L9c3Alzf8ClkDpO3sjLxoMn1PUDBkIic77xKycVmzo6YZM/vqz64 vvGElvz/bt8F0D7vJ4AaaZgrKIY30MSMl1UeudhZWMxYxab99K/M7Wuu/VfgRBXwGoww TY0Gczqzw6aTnUtG3RWIEQ/uZaMO8TLFvR3qOcu2+29R3WtmNxpqqHOL3TvamybYEiA+ 0EQYFT4hYMkL3ckMUpHv6eOqTIfwKTVBoNL47dJ+eb7v8UglcEjVx7UnxMJhRa1oAZZg C1yQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LMaLfHsrFtR5TbYrAS2TUcw4yJ/c8dS9VHRIf5BDh/o=; b=b1/1Yy3GplMqv2uJpmG7Cf+5emTr613M68u+2vtgjspU2i+Pq/5lhSEjTJfpTX+4sm VpnPQszfINcmvVzCFFQrXVkw8QVpKeP61EC0uQJIBOl7g929Eqb1Jy3yXZheOUZ3/lmx 08gsFyZ0iRbb8aHJ8PeLTzd/hJLWETUQtpaJ273vFMKfSCS7C3ROY1oCPMkZMqvofdVZ hW2O2D6ovIJIq/VlEx/RRMB9fkhaZKjji+6+ulpZ0Vg1fRzUv/HOQNtupf0WTRYpLuUU ozPX2M56zkZuI+n5/4E3Z6v8khrFNVGgzMZIoqJ/K7nKu/oz+PmDJV0Fbic4SzofrPMO NR4g== X-Gm-Message-State: AOAM531leTwiLY/r1C+gJr+jNKZiQyyzVe0GMosBQLaJw0frSXQlQa8G 2103FHSyRAhJIFACAVe5TZrHrxp2Hzk3bg== X-Google-Smtp-Source: ABdhPJypCWNBEGztuhL+hyrioV7BILff5YkFQYaNQMdFKX+T58LoqD7kswimkNDfvi85XNsWHJrt4g== X-Received: by 2002:a05:6000:1d0:: with SMTP id t16mr1051286wrx.203.1609875811149; Tue, 05 Jan 2021 11:43:31 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id s6sm151113wro.79.2021.01.05.11.43.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 11:43:30 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , "brian m . carlson" , Eric Sunshine , Johannes Schindelin , =?utf-8?q?SZEDER_G=C3=A1b?= =?utf-8?q?or?= , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v5 04/23] mktag tests: don't needlessly use a subshell Date: Tue, 5 Jan 2021 20:42:33 +0100 Message-Id: <20210105194252.627-5-avarab@gmail.com> X-Mailer: git-send-email 2.29.2.222.g5d2a92d10f8 In-Reply-To: <20201223013606.7972-1-avarab@gmail.com> References: <20201223013606.7972-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The use of a subshell dates back to e9b20943b77 (t/t3800: do not use a temporary file to hold expected result., 2008-01-04). It's not needed anymore, if it ever was. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t3800-mktag.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/t3800-mktag.sh b/t/t3800-mktag.sh index d696aa4e52e..0e411e3c45f 100755 --- a/t/t3800-mktag.sh +++ b/t/t3800-mktag.sh @@ -14,7 +14,7 @@ test_description='git mktag: tag object verify test' check_verify_failure () { expect="$2" test_expect_success "$1" ' - ( test_must_fail git mktag message ) && + test_must_fail git mktag message && grep "$expect" message ' } From patchwork Tue Jan 5 19:42:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12000267 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 60304C433E0 for ; Tue, 5 Jan 2021 19:44:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 35CD022D6F for ; Tue, 5 Jan 2021 19:44:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730900AbhAETot (ORCPT ); Tue, 5 Jan 2021 14:44:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730868AbhAETos (ORCPT ); Tue, 5 Jan 2021 14:44:48 -0500 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7D57C06179A for ; Tue, 5 Jan 2021 11:43:33 -0800 (PST) Received: by mail-wm1-x330.google.com with SMTP id k10so594093wmi.3 for ; Tue, 05 Jan 2021 11:43:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RGCEbG3r9vJyDszwDye8xvPIIaJtBo9NAN9QrwG5HB4=; b=tJq4DcU3yhIpV7Wi4PvuI0s1eTyirpwBymoveMkCXI+B6P/kxmnlkfjJ1cx5PhrmOj 2iNunK7ld379ioLrFWTF6MsnZzOTzFBvFqJVYw4gHDDofj0j5sRQ+qPeEdfagzodulQM Zv4tEFMp8DFXIKyCvIe8xXhLLvXdhSvqlrHQXMlwcqVCj2k1dbYSxgePV7cKV8iTeC5s 3BSz3cj61SBA6VMWu24EhiMo6Rbtg1jX9mPuGdR499KXJtwv9KI9LVqFvGmRCFSFT6zH Rdk/KptXKYJcLwJXaC3zFT1PBNdNuzPvfpdJDGgcHc0D9ieBxd85G8njJ9g9zq+VXmHb +hRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RGCEbG3r9vJyDszwDye8xvPIIaJtBo9NAN9QrwG5HB4=; b=buf/p8ObOXefHaoXnxjExh4gvOQ4/eqZ4Em5t5XDwI22hKagewY8Dv/HeJdOq9Dcxs tNFF7FpqXOdZcGGLhPCpWvc0nihAESQmwQssXzkMtkU3mSzLT7HTtR1lhkXdpJxlclJA 2pcyf+vl3gTzHC/bmnouFV2xYZLgbieREiNY2kuix3OYOWLqCWJgeITcMbBwhZEtM5+z wajqRj6gNyeePDfHa/kotCTgLueeVDBTXiwKn0IZQiTKt2nnmGKM+IWY4KizsWM3+8qs xhy5AUWW5mPiYCwv/9SDRSDLOcVk5S7QQIB3bj66IBND9EcHf/s4rOoKAp//uSlTVM2s rrBA== X-Gm-Message-State: AOAM531hGqyfl+F5zKnQvT7v/Y6dMYpA3kt/frcUD2q5VLOe15Slzr9w kFUNzUzKXckSR3V1i+F6Q+jHppiiD+//rA== X-Google-Smtp-Source: ABdhPJxue5LDgtlsfrzjTuMESAng3PVDPEVVBwlcWUyInK9X7lnZ5Y1j0PlPVqAZ7tGYPT963CBZ8w== X-Received: by 2002:a05:600c:21d1:: with SMTP id x17mr621882wmj.160.1609875812164; Tue, 05 Jan 2021 11:43:32 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id s6sm151113wro.79.2021.01.05.11.43.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 11:43:31 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , "brian m . carlson" , Eric Sunshine , Johannes Schindelin , =?utf-8?q?SZEDER_G=C3=A1b?= =?utf-8?q?or?= , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v5 05/23] mktag tests: use "test_commit" helper Date: Tue, 5 Jan 2021 20:42:34 +0100 Message-Id: <20210105194252.627-6-avarab@gmail.com> X-Mailer: git-send-email 2.29.2.222.g5d2a92d10f8 In-Reply-To: <20201223013606.7972-1-avarab@gmail.com> References: <20201223013606.7972-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Replace ad-hoc setup of a single commit in the "mktag" tests with our standard helper pattern. The old setup dated back to 446c6faec69 (New tests and en-passant modifications to mktag., 2006-07-29) before the helper existed. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t3800-mktag.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/t/t3800-mktag.sh b/t/t3800-mktag.sh index 0e411e3c45f..dd21a1247a2 100755 --- a/t/t3800-mktag.sh +++ b/t/t3800-mktag.sh @@ -23,9 +23,7 @@ check_verify_failure () { # first create a commit, so we have a valid object/type # for the tag. test_expect_success 'setup' ' - echo Hello >A && - git update-index --add A && - git commit -m "Initial commit" && + test_commit A && head=$(git rev-parse --verify HEAD) ' From patchwork Tue Jan 5 19:42:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12000265 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C66FCC433DB for ; Tue, 5 Jan 2021 19:44:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 92CC822D6F for ; Tue, 5 Jan 2021 19:44:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730905AbhAETot (ORCPT ); Tue, 5 Jan 2021 14:44:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730881AbhAETos (ORCPT ); Tue, 5 Jan 2021 14:44:48 -0500 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B15D2C06179E for ; Tue, 5 Jan 2021 11:43:34 -0800 (PST) Received: by mail-wr1-x42f.google.com with SMTP id t16so358641wra.3 for ; Tue, 05 Jan 2021 11:43:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=g7RJmA0lqTKzFD6S5AZu66MR563n9lmpCQKVwSCDQQM=; b=RTdEUgXM/E4SB35PfUiV2REa80irTk5v2cj/8ARfdk2zFJGq1RwtW2iwImcT63mTK6 yQUyQlYic89E3ie7AIiYPV1hhrmUzhTuXskU/7udEc9V3Nc8euF/scx/RwbCJEEsOSx8 Q958TzJL43vCGk71Qme30H3bbxTfa/kNEvzh4RQRAKI/MzYUrtuNnJbriOvpb1FfsZSD 0xd6pFDyO6HyShAGCKVBBEk58cwN9SMwW2JPCC6wn+TfalIR/4Tjb8JMmRzxpqqdYzEx 8TCZHy2zDaEa4BfssPlG4OnwwOSh7OkUMluqLeexRSTH75ly1YaDiOid/UCsGT2sWGdC t/vQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=g7RJmA0lqTKzFD6S5AZu66MR563n9lmpCQKVwSCDQQM=; b=VkWQL3TPLZacawOoyxjnkpX3Hyuzr6Ll+1IYJOoI+5P49mwsoUlqaPSBeqBIYyb/H5 FPmC0ihsmNpRmlm07Udb3yGIuk+bnZjg4nDtroBw+UI7cJLkK/LZK1B7YjXzQAfrxYhM eriO2GoB6pzAHJYtfwPCYiPev8uycI6TEP3rIrwAJqA8yDGNG+5bqKrHpr34feKqH8mF DXibZE8vjE5MYhU8gW9UR0AMmQg+nmIhNDqE6Zqeo5yMxPcZ5rqOwfOnx4N7GO4/sgCA 3EfCiMS5GtQamquzQY5bHWKkkbcUJSxXuNcUQcy9TmXsJT4rWysPn2y18k8VnjtVo7nn /QJA== X-Gm-Message-State: AOAM532X1f1ZnKMurqr0QHAsGo2xBPduEan2G/hlmRs/eN38OYh0hF2j S+whhjVogmJQ697uF5yCTtG1UUV+HvHzNQ== X-Google-Smtp-Source: ABdhPJx2fBMRUzkmWiC7iPe7AIUlBQZ6gp+Nig8wjN2Dzhvc0GUT0pnFgV9kKcwMjbqDD8cYf92lJg== X-Received: by 2002:a5d:4101:: with SMTP id l1mr1113160wrp.196.1609875813251; Tue, 05 Jan 2021 11:43:33 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id s6sm151113wro.79.2021.01.05.11.43.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 11:43:32 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , "brian m . carlson" , Eric Sunshine , Johannes Schindelin , =?utf-8?q?SZEDER_G=C3=A1b?= =?utf-8?q?or?= , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v5 06/23] mktag tests: remove needless SHA-1 hardcoding Date: Tue, 5 Jan 2021 20:42:35 +0100 Message-Id: <20210105194252.627-7-avarab@gmail.com> X-Mailer: git-send-email 2.29.2.222.g5d2a92d10f8 In-Reply-To: <20201223013606.7972-1-avarab@gmail.com> References: <20201223013606.7972-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Change the tests amended in acb49d1cc8b (t3800: make hash-size independent, 2019-08-18) even more to make them independent of either SHA-1 or SHA-256. Some of these tests were failing for the wrong reasons. The first one being modified here would fail because the line starts with "xxxxxx" instead of "object", the rest of the line doesn't matter. Let's just put a valid hash on the rest of the line anyway to narrow the test down for just the s/object/xxxxxx/ case. The second one being modified here would fail under GIT_TEST_DEFAULT_HASH=sha256 because is an invalid SHA-256, but we should really be testing when under SHA-256. This doesn't really matter since we should be able to trust other parts of the code to validate things in the 0-9a-f range, but let's keep it for good measure. There's a later test which tests an invalid SHA which looks like a valid one, to stress the "We refuse to tag something we can't verify[...]" logic in mktag.c. But here we're testing for a SHA-length string which contains characters outside of the /[0-9a-f]/i set. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t3800-mktag.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/t/t3800-mktag.sh b/t/t3800-mktag.sh index dd21a1247a2..e1a2892f58b 100755 --- a/t/t3800-mktag.sh +++ b/t/t3800-mktag.sh @@ -41,7 +41,7 @@ check_verify_failure 'Tag object length check' \ # 2. object line label check cat >tag.sig < 0 +0000 @@ -51,10 +51,10 @@ EOF check_verify_failure '"object" line label check' '^error: char0: .*"object "$' ############################################################ -# 3. object line SHA1 check +# 3. object line hash check cat >tag.sig < 0 +0000 From patchwork Tue Jan 5 19:42:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12000269 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B47C4C433E6 for ; Tue, 5 Jan 2021 19:44:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7FEAD22D6F for ; Tue, 5 Jan 2021 19:44:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730911AbhAETou (ORCPT ); Tue, 5 Jan 2021 14:44:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730881AbhAETou (ORCPT ); Tue, 5 Jan 2021 14:44:50 -0500 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7295C06179F for ; Tue, 5 Jan 2021 11:43:35 -0800 (PST) Received: by mail-wr1-x431.google.com with SMTP id r7so346742wrc.5 for ; Tue, 05 Jan 2021 11:43:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4WIjBFfNv1h/HVQS42c1uH9CIVsBC3PyVvLQO43R9WU=; b=HxTwDTTiHREIYSqxzH1gAms93MWsxwWbySoXbHz1yithOHMyNJ0CIV03+0RoeCsYxt qigxfHuSGEJ4jmHEoDhUjFPPv2zRYLEQBvoZbGDOjzyB4XcnRpTvp5yDxyRZ6cI0092C u7iSp7BwlR4svNExKVTyhid4e6KuHdIeoRCMzBYFPWf6k5bdZ32Oj8DZEPd6y6DTnkNC TxQJHpyqwPyBcKH+I/VfW9iuKArZSAfezMO3NqscWv7cJmjp5TPQu0eIrVKszzyxHdov yFpq4nOv7MlHqnbtY/N1YuVE5ELKnEuqRdzO2c7hu3iGKhozrtaJE8bGiVsHnFEAewq2 LscA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4WIjBFfNv1h/HVQS42c1uH9CIVsBC3PyVvLQO43R9WU=; b=UGNtW9tovmCNTfO4XZ1hgD6k9Nzhcl5kMQb8HqFBXLk9n+zN46p6wGls0lCLw/gkdH HYp21qYk7hXLeJeqdUZ0nuitLkI1HINjel1LLfbB5JwNdn3gtTpBdY/Jcm6/YBvUh075 wsPNxIjDNLgzebMbYrwAHEw3N43vbzzZVsBdDMB8KCcb4MtgDMEByNwpI+pCLpU1Qirq DSYzMnIxyqU70QKAMF7Y6pS+2FTXnz8i1ckkzSjrvspw1kdK6FDwKusxcw9jM3VkDVFr 7bdolyQQQuXVd3CUoFAFjF6pVR6LMlS+zqPziSHTjwouWafaUum0jqmQlNIcnHaw/oRT o6hw== X-Gm-Message-State: AOAM531lDR5VYJ/udpt3B5rpOJNbCSpUrI4wujOkHRiw27v2yjOCnX4h XsqJAJgnzfTFuACepmgDy+HK452Xvvzh6Q== X-Google-Smtp-Source: ABdhPJzYGGFsOn158aQdaH2z9X/WekRsV7lunubC8yMmrlvrkyx/fbguhkexXlzZRgKaTEBSugt8zw== X-Received: by 2002:a5d:404b:: with SMTP id w11mr1137087wrp.14.1609875814281; Tue, 05 Jan 2021 11:43:34 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id s6sm151113wro.79.2021.01.05.11.43.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 11:43:33 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , "brian m . carlson" , Eric Sunshine , Johannes Schindelin , =?utf-8?q?SZEDER_G=C3=A1b?= =?utf-8?q?or?= , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v5 07/23] mktag tests: don't redirect stderr to a file needlessly Date: Tue, 5 Jan 2021 20:42:36 +0100 Message-Id: <20210105194252.627-8-avarab@gmail.com> X-Mailer: git-send-email 2.29.2.222.g5d2a92d10f8 In-Reply-To: <20201223013606.7972-1-avarab@gmail.com> References: <20201223013606.7972-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Remove the redirection of stderr to "message" in the valid tag test. This pattern seems to have been copy/pasted from the failure case in 446c6faec6 (New tests and en-passant modifications to mktag., 2006-07-29). While I'm at it do the same for the "replace" tests. The tag creation I'm changing here seems to have been copy/pasted from the "mktag" tests to those tests in cc400f50112 (mktag: call "check_sha1_signature" with the replacement sha1, 2009-01-23). Nobody examines the contents of the resulting "message" file, so the net result is that error messages cannot be seen in "sh t3800-mktag.sh -v" output. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t3800-mktag.sh | 4 ++-- t/t6050-replace.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/t/t3800-mktag.sh b/t/t3800-mktag.sh index e1a2892f58b..c542c3e1a8e 100755 --- a/t/t3800-mktag.sh +++ b/t/t3800-mktag.sh @@ -222,7 +222,7 @@ EOF test_expect_success \ 'allow empty tag email' \ - 'git mktag .git/refs/tags/mytag 2>message' + 'git mktag .git/refs/tags/mytag' ############################################################ # 16. disallow spaces in tag email @@ -350,7 +350,7 @@ EOF test_expect_success \ 'create valid tag' \ - 'git mktag .git/refs/tags/mytag 2>message' + 'git mktag .git/refs/tags/mytag' ############################################################ # 25. check mytag diff --git a/t/t6050-replace.sh b/t/t6050-replace.sh index c80dc10b8f1..0dbe086118a 100755 --- a/t/t6050-replace.sh +++ b/t/t6050-replace.sh @@ -129,7 +129,7 @@ tagger T A Gger <> 0 +0000 EOF test_expect_success 'tag replaced commit' ' - git mktag .git/refs/tags/mytag 2>message + git mktag .git/refs/tags/mytag ' test_expect_success '"git fsck" works' ' From patchwork Tue Jan 5 19:42:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12000271 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 56971C433E0 for ; Tue, 5 Jan 2021 19:44:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1E05D22D6F for ; Tue, 5 Jan 2021 19:44:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730916AbhAETov (ORCPT ); Tue, 5 Jan 2021 14:44:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730906AbhAETou (ORCPT ); Tue, 5 Jan 2021 14:44:50 -0500 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2143C0617A0 for ; Tue, 5 Jan 2021 11:43:36 -0800 (PST) Received: by mail-wr1-x431.google.com with SMTP id c5so343276wrp.6 for ; Tue, 05 Jan 2021 11:43:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=y73RTM2CzwNsFUtuH4bVhFDjnUQf4pKzMQOA0TBPuWk=; b=izjpqdasRE8TTyrorcSLS2ntshcnoHojR6rSvEmZ5tFA3TismxDho4FiMIzau1IQ+A lCw6QF9N4IMhT92sYZhiU2LPHdJSnFXt7TeCWcyFsA6ULPlAiODbHaGcGhNZWaikoMFR MLrUZQZGh9uPDEk/Gd6m8iTJb5QDOEwWjXcWfW/+34ml9FOyCl+nuzYX/PdoD+xTsRBJ 8anXlDrJOAnfmWfMHarRQtr+GmbMipMA1ec0MHZWz+oQRoa1KeK8q7PBLbWtGz6FGjwx szlLrCe4mikBRK6+tqOJB+9qiZx/HCFUPIIUANYviI0eLDs9xTtyJO/JTrJZY1kYIEsi ym2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=y73RTM2CzwNsFUtuH4bVhFDjnUQf4pKzMQOA0TBPuWk=; b=EMylk6+OP/Rhn5KWi0k9j2YS9mH4prYA9IzcMiAud4jJXd9IsHgxjrjJP1RQVPOiJh 5CvWk1ZzdSe+g6R4eCOZ9hEqr6itlZyGDuDZGayF1OQndZb4WLGLqSvkGdfLH64W9QQn Q8/6YrXnnQTKhKIct8a6zmPVpxXLZsdOjGQaZJv3ARHlCgecOxg2mxk6HiUTx4gxdBiB /zGUkTsY38+UfVzMQdoJoj9Pr5TbFYCMeXdk/y+JuKnbPkyL6h+yitrqfoJy2eF8plkj 8lqOI7379nnH9Hitib8hCJy7oRy+tyePgxjXrUGEfUObZ+TbjdiZqMN/MfgJHN4z3mHQ 8EBQ== X-Gm-Message-State: AOAM5303pHzlEOXm2mrySjPjzLHS/E/NnOTLIKgQYTgJ7muXCfOQUYBm B42M6bDcGeSDYXFa4Gs8Mpq39x1vHQFctA== X-Google-Smtp-Source: ABdhPJy81iT+IhvPGK760JIWtXbkYe6hU50FGfcm3WMCByJqZ65d/SWeFsgRFkqg5+LVSiF0FXnOMg== X-Received: by 2002:adf:fbd2:: with SMTP id d18mr1103958wrs.222.1609875815476; Tue, 05 Jan 2021 11:43:35 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id s6sm151113wro.79.2021.01.05.11.43.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 11:43:34 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , "brian m . carlson" , Eric Sunshine , Johannes Schindelin , =?utf-8?q?SZEDER_G=C3=A1b?= =?utf-8?q?or?= , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v5 08/23] mktag tests: don't create "mytag" twice Date: Tue, 5 Jan 2021 20:42:37 +0100 Message-Id: <20210105194252.627-9-avarab@gmail.com> X-Mailer: git-send-email 2.29.2.222.g5d2a92d10f8 In-Reply-To: <20201223013606.7972-1-avarab@gmail.com> References: <20201223013606.7972-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Change a test added in e0aaf781f6 (mktag.c: improve verification of tagger field and tests, 2008-03-27) to not create "mytag", which should only be created and verified at the end in an earlier test added in 446c6faec6 (New tests and en-passant modifications to mktag., 2006-07-29). While we're at it let's prevent a similar logic error from creeping into the test by asserting that "mytag" doesn't exist before we create it. Let's do this by moving the test to use "update-ref", instead of our own homebrew ad-hoc refstore update. We're not really testing for anything yet by creating the tag at the end here. A subsequent commit will change that. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t3800-mktag.sh | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/t/t3800-mktag.sh b/t/t3800-mktag.sh index c542c3e1a8e..bb300d567db 100755 --- a/t/t3800-mktag.sh +++ b/t/t3800-mktag.sh @@ -222,7 +222,7 @@ EOF test_expect_success \ 'allow empty tag email' \ - 'git mktag .git/refs/tags/mytag' + 'git mktag 1206478233 -0500 EOF -test_expect_success \ - 'create valid tag' \ - 'git mktag .git/refs/tags/mytag' - -############################################################ -# 25. check mytag - -test_expect_success \ - 'check mytag' \ - 'git tag -l | grep mytag' - +test_expect_success 'create valid tag' ' + git mktag hash && + git update-ref refs/tags/mytag $(cat hash) $(test_oid zero) +' test_done From patchwork Tue Jan 5 19:42:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12000279 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D0F96C433E0 for ; Tue, 5 Jan 2021 19:44:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9288D22D6F for ; Tue, 5 Jan 2021 19:44:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730931AbhAEToy (ORCPT ); Tue, 5 Jan 2021 14:44:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730918AbhAETox (ORCPT ); Tue, 5 Jan 2021 14:44:53 -0500 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DEF03C0617A2 for ; Tue, 5 Jan 2021 11:43:37 -0800 (PST) Received: by mail-wr1-x42b.google.com with SMTP id r3so364451wrt.2 for ; Tue, 05 Jan 2021 11:43:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wBLe2w700Hho5dXh2nJ14muBzt5gSm+uefTx9cznLSg=; b=gphMtgyB5B9xRyTTcqZGPKuAqr0e0IuiaT7sl6trE9cc2dv7gmWwKoErSiT1bSjHhT J7YrdScGX7AQ9hn1rEy1Hhzer3liwgxsSypmMRFxCLRCKH/SGWycjv0qkT1eVa03Qyzp l3cYFvjCabaJialhB1LqfUpo+BdthKCb+XmHsQsclsBdRhHbxjQ1ZVgI+36cNOdTQ3VI ewmZjQkUJaEal7EoSoygn9zNhGtRmn+DVNDS+NctU5Jc4LKX6+xQ48pH5rVc1Ht60caO tmDiSfcnHUI/bQBy217EAjjTNs9ccwtOnL1y0rlxxi3xG00sR+stdyFV13Q9sKliPksq Ir6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wBLe2w700Hho5dXh2nJ14muBzt5gSm+uefTx9cznLSg=; b=tdjxhxTEzMnNEKhq+r/9LGrhynhexL651xkmO4jJ/byVXz0lgUb3+uzKPJWa3Q8J2k NjRSO6fbQWvN5wA+Q3I1HEZHhgeCQ7g3uS8MXNtHFOsPN0ATo22rQoyR3xQCAy71EFnk BjVqDnxBeU2pHQzvR6HvUvuRk6ta53dncucKdmgfrDTDKf9HQ/C3UrJlBoMPvSk9HYAr fS2y42bM3eo+wm1HXeUFNB6Tkhm1tawP/AxHRBZhWSSAZ+7m2zNCNgMPHPhnNUILcA/J FXIFmqM/hzVJeqT24i3Zhcrb6xCzjoAv6/uEoVTXkH4gSsTp8/eHm+tpdI/ZCOfmxmwa kULA== X-Gm-Message-State: AOAM533H3nEpy+ONUXQMSY8kf221ehKu+hck3uYkvOPCQTwXEMRMLOc4 +IG0FSCQ+glsidAcZBfmQgUdKAhjLMvgnQ== X-Google-Smtp-Source: ABdhPJxD36wd4d2o+12DPRH2YpPoDHvGw9qDTchf0ZOxNBucXTUNHZnIOZkjU1wASN5gIfE0syh0qg== X-Received: by 2002:adf:dc8b:: with SMTP id r11mr1077946wrj.131.1609875816442; Tue, 05 Jan 2021 11:43:36 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id s6sm151113wro.79.2021.01.05.11.43.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 11:43:35 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , "brian m . carlson" , Eric Sunshine , Johannes Schindelin , =?utf-8?q?SZEDER_G=C3=A1b?= =?utf-8?q?or?= , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v5 09/23] mktag tests: run "fsck" after creating "mytag" Date: Tue, 5 Jan 2021 20:42:38 +0100 Message-Id: <20210105194252.627-10-avarab@gmail.com> X-Mailer: git-send-email 2.29.2.222.g5d2a92d10f8 In-Reply-To: <20201223013606.7972-1-avarab@gmail.com> References: <20201223013606.7972-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Change the last test in the file to run an "fsck --strict" after creating the tag at the end. We're just doing this for good measure to check that fsck behaves as expected now that there's finally a reference for our valid tag. Other tests going to be checking this elsewhere, but it's nice to cover all the edge cases in this test to make it as self-contained as possible. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t3800-mktag.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/t/t3800-mktag.sh b/t/t3800-mktag.sh index bb300d567db..048000cda9a 100755 --- a/t/t3800-mktag.sh +++ b/t/t3800-mktag.sh @@ -350,7 +350,8 @@ EOF test_expect_success 'create valid tag' ' git mktag hash && - git update-ref refs/tags/mytag $(cat hash) $(test_oid zero) + git update-ref refs/tags/mytag $(cat hash) $(test_oid zero) && + git fsck --strict ' test_done From patchwork Tue Jan 5 19:42:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12000281 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 433FEC433DB for ; Tue, 5 Jan 2021 19:44:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 19B0F22D6F for ; Tue, 5 Jan 2021 19:44:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730928AbhAEToy (ORCPT ); Tue, 5 Jan 2021 14:44:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730920AbhAETox (ORCPT ); Tue, 5 Jan 2021 14:44:53 -0500 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0541AC0617A3 for ; Tue, 5 Jan 2021 11:43:39 -0800 (PST) Received: by mail-wr1-x42c.google.com with SMTP id r3so364492wrt.2 for ; Tue, 05 Jan 2021 11:43:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=m+NzCUShth1URyf9aQUS8a/Nhf71EApFnPiYFtU90s8=; b=rL+PPi28PskpRrO0NNLvJ4db5SR9EC+ooZfwcmbbCvBZ2Se1Sz/pJ/8zpL1vyKw283 szzB54L8IWUlC0/pIaUv2SsvPCGKEQ6RglQkNnWPKTE/qRtj7z7JWFQW3GFoAv8W29dt lI4aMXm/RYpVsEgJHHw2c7FBlh2NwAEcZ1jJJYaJeByLB/XrPemK7hFfPfbqwEvcj7CU YCxYosY0F9244Rbh5QrhmGkFuH1mkiXicP20ON6DtLjik7lbdCRb/w6P+4Zy44YYgKAh Ogp5jIWRlYf0KQbUq9i36bpGUxMQnlSdUreLR0Mxz8xE0VkTPJLhOGR0sWZcUq1XUWSF ZtDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=m+NzCUShth1URyf9aQUS8a/Nhf71EApFnPiYFtU90s8=; b=fp95tWUi5xDCWGWYcdSJ3pIEzAv+lWw1LmRoAPr3jH0DV0+ZMC2Wl1mdblPWOO0fOv a6deEUhV2To4NgMQvSnAXnO1aX3at4F1WYC3oTferuVx7wiMkyrs3kUuUlzDM+tq/6PO ds6hSTYzEwZAgBgWmER4SxJLsSk0VkF9afmDofuuYPDcvtRKPM/XIArpmKUInXSK7KlG 4YLSl666T7dGxBGRrrg/Zyx8zeyz37hJpWooRH/1L3cMtrAOudUM+HjEcfNyoSt+CgNx 0CFPKwHieb3r08UQs3cMmg3oC5bIK5yrDX+9fyPcdQtE4Vf41JUWooghuJhigl86/lBU cTyg== X-Gm-Message-State: AOAM53147DFMwwShb9Qi4xJN+2Dn26+3XRejvhZWnCLZNOlmZ1x8gUSr B2JuAOg0V1kGFr3cGnBwNsQa7o0QyV8D8A== X-Google-Smtp-Source: ABdhPJzlQMbdJZZ8NMvB6rNrErbnJQnwzaJ2VwP/tPr4N+lYtRuIV2HP+iHYbBXpod85FUV96TZClQ== X-Received: by 2002:a05:6000:11c1:: with SMTP id i1mr1107271wrx.16.1609875817564; Tue, 05 Jan 2021 11:43:37 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id s6sm151113wro.79.2021.01.05.11.43.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 11:43:36 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , "brian m . carlson" , Eric Sunshine , Johannes Schindelin , =?utf-8?q?SZEDER_G=C3=A1b?= =?utf-8?q?or?= , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v5 10/23] mktag tests: stress test whitespace handling Date: Tue, 5 Jan 2021 20:42:39 +0100 Message-Id: <20210105194252.627-11-avarab@gmail.com> X-Mailer: git-send-email 2.29.2.222.g5d2a92d10f8 In-Reply-To: <20201223013606.7972-1-avarab@gmail.com> References: <20201223013606.7972-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Add tests for a couple of whitespace edge cases around the header/body boundary. I consider the requirement for a blank line before the empty body a bug, it's a long-standing regression which goes against the command's documented behavior. This bug will be addressed in a follow-up change. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t3800-mktag.sh | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/t/t3800-mktag.sh b/t/t3800-mktag.sh index 048000cda9a..661b62f0912 100755 --- a/t/t3800-mktag.sh +++ b/t/t3800-mktag.sh @@ -337,6 +337,42 @@ EOF check_verify_failure 'detect invalid header entry' \ '^error: char.*: trailing garbage in tag header$' +cat >tag.sig < 1206478233 -0500 + + +this line comes after an extra newline +EOF + +test_expect_success 'allow extra newlines at start of body' ' + git mktag tag.sig < 1206478233 -0500 + +EOF + +test_expect_success 'require a blank line before an empty body (1)' ' + git mktag tag.sig < 1206478233 -0500 +EOF + +check_verify_failure 'require a blank line before an empty body (2)' \ + '^error: char.*: trailing garbage in tag header$' + ############################################################ # 24. create valid tag From patchwork Tue Jan 5 19:42:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12000273 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 906F6C433E0 for ; Tue, 5 Jan 2021 19:44:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 64CD322D6F for ; Tue, 5 Jan 2021 19:44:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730934AbhAEToz (ORCPT ); Tue, 5 Jan 2021 14:44:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730921AbhAETox (ORCPT ); Tue, 5 Jan 2021 14:44:53 -0500 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40010C0617A4 for ; Tue, 5 Jan 2021 11:43:40 -0800 (PST) Received: by mail-wr1-x42f.google.com with SMTP id d26so308537wrb.12 for ; Tue, 05 Jan 2021 11:43:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Lm7xPXJUT0TSQKgC++uSxgFf2YALDhEz263zAZuMUA4=; b=k1vnx4Yi5VUHuGfxjIO+GM26z86J/1nPE1FMKlyiP95qhHjtIymzqUseRtXeCciIjb TaUa9/6a75oBaE5ZNu3+9ciYO/6pXFxTEN9yiDQL27caE6aaJ5Jjl7JnzTehi626waDq enn+3P1JE//9Jc37x3L18sh5AWs+gW3Xl8sivB7qhCd5dU+gHpw37R/iKNtJG9qz+6Ce 9Ua32V8ZX7eS72CIMmQ1IdG5E3D5c+BLPNAbNL5G5d6Wuy01qBYTuyjw275kyY4yUnbq hnFVbCztlEziSKqDhJFQt2OUkR75YqWzm+qzP1sZQWGSfOginU+mkypGbzX/QxZgtLFD 8AkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Lm7xPXJUT0TSQKgC++uSxgFf2YALDhEz263zAZuMUA4=; b=emWeyeivEolNYjkMlL4inusgz9wvisSSmZw8fS+EDRs5G0AAfJqb5v0gOtTNJJ0fha RgVTSPiAOAcZAzn7cHmxsY4ScAKBIEf+8kTRZocxgMgyIbo8czVFRKtLNjIdRqIOWwUU IA2jYbk8/QE9rDXqSCE0C+2tmUBt2kR9KU8368ceV4rjjAWg4H0Kq2Dm2qOue0qdp3Qz TtQSoVkut78gz9kzZt7pVsrkpIn4B7igC4Iwk/Dw9ozOpBu5JMsTwacn8f3CcP02dX9t 3JWpnKVrmL32TTZdu+lEfIIMej/9vF4nTpRvi2xFiD2yOyMqtzMa0C+unvy+1ZOZrywx j2hA== X-Gm-Message-State: AOAM531QDsXDIj8JnjT6Hng66UWZdTd3ss1plOhiWhzEYic2A+zEmj9H T0r/PmHLec8TePUC65tffTiSgypLBASmbA== X-Google-Smtp-Source: ABdhPJy9p2GxHhB01YpLVdxTfxo/9sFpth8PR+muchp7SCGng18t3lXlQuj4aLNdqmxHBzz0poQ6iQ== X-Received: by 2002:adf:f3c8:: with SMTP id g8mr1018722wrp.405.1609875818718; Tue, 05 Jan 2021 11:43:38 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id s6sm151113wro.79.2021.01.05.11.43.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 11:43:37 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , "brian m . carlson" , Eric Sunshine , Johannes Schindelin , =?utf-8?q?SZEDER_G=C3=A1b?= =?utf-8?q?or?= , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v5 11/23] mktag tests: test "hash-object" compatibility Date: Tue, 5 Jan 2021 20:42:40 +0100 Message-Id: <20210105194252.627-12-avarab@gmail.com> X-Mailer: git-send-email 2.29.2.222.g5d2a92d10f8 In-Reply-To: <20201223013606.7972-1-avarab@gmail.com> References: <20201223013606.7972-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Change all the successful "mktag" tests to test that "hash-object" produces the same hash for the input, and that fsck passes for both. This tests e.g. that "mktag" doesn't trim its input or otherwise munge it in a way that "hash-object" doesn't. Since we're doing an "fsck --strict" here at the end let's incorporate the creation of the "mytag" name into this test, removing the special-case at the end of the file. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t3800-mktag.sh | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/t/t3800-mktag.sh b/t/t3800-mktag.sh index 661b62f0912..47380292223 100755 --- a/t/t3800-mktag.sh +++ b/t/t3800-mktag.sh @@ -19,6 +19,19 @@ check_verify_failure () { ' } +test_expect_mktag_success() { + test_expect_success "$1" ' + git hash-object -t tag -w --stdin expected && + git fsck --strict && + + git mktag hash && + test_cmp expected hash && + test_when_finished "git update-ref -d refs/tags/mytag $(cat hash)" && + git update-ref refs/tags/mytag $(cat hash) $(test_oid zero) && + git fsck --strict + ' +} + ########################################################### # first create a commit, so we have a valid object/type # for the tag. @@ -220,9 +233,7 @@ tagger T A Gger <> 0 +0000 EOF -test_expect_success \ - 'allow empty tag email' \ - 'git mktag 1206478233 -0500 this line comes after an extra newline EOF -test_expect_success 'allow extra newlines at start of body' ' - git mktag tag.sig < 1206478233 -0500 EOF -test_expect_success 'require a blank line before an empty body (1)' ' - git mktag tag.sig < 1206478233 -0500 EOF -test_expect_success 'create valid tag' ' - git mktag hash && - git update-ref refs/tags/mytag $(cat hash) $(test_oid zero) && - git fsck --strict -' +test_expect_mktag_success 'create valid tag object' test_done From patchwork Tue Jan 5 19:42:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12000277 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1BA28C433E9 for ; Tue, 5 Jan 2021 19:44:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DC92522D6F for ; Tue, 5 Jan 2021 19:44:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730937AbhAEToz (ORCPT ); Tue, 5 Jan 2021 14:44:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730922AbhAEToy (ORCPT ); Tue, 5 Jan 2021 14:44:54 -0500 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F391C0617A5 for ; Tue, 5 Jan 2021 11:43:41 -0800 (PST) Received: by mail-wr1-x42e.google.com with SMTP id 91so335882wrj.7 for ; Tue, 05 Jan 2021 11:43:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AM9uuCOItbCCbYBiK240RGRW4dpnMVLWiZV07hQ2LRM=; b=NqggQuIwcg9IqDw9NuPDjHQNoVdt2oMVvJgNXBV9yhLZbpu20B2UX+6TJd5dknlG9p qeax795czjeirmbIyHAnCre24I4X2Rbh2XjeLvvFzteiIZvobpZN+XceZsFtB4wSIA0a EE+KBV6WfCgpVNlwfAyITgs9mpZVzw6s6TdeV69IyBk21OI4z7eS/9U7TBQ4BbeiVNc6 K6YEF3Zc55Wz6tkiQlQwrSUNGxHbpftvKXpq7D7JQJpR6LydlKpmcNtlBtqkQPqTq8pj P9Y54pc70q6vUwzFlvCe82Loae3fJNAuaG7MUb4MArOPlN5+lJVwpg/1su2Sch2UX3rE CyNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AM9uuCOItbCCbYBiK240RGRW4dpnMVLWiZV07hQ2LRM=; b=CQnNCcSDyBl14xuxxTFCtxeIFwEvm+sgzl/5hYMy8Oyxu6R67/lJplzU4tpvB7JZkA PUcKUaIYbWb1kx1Sh3Q5hGEc4HfxYYnVrM7L9PTEuL2KcOCxsBxF2Yl6cuIC7OFUS8Oc 9oBRxZXNuGKed+7ZvxnHUslVjdUrKJKyDvkDtlxxGB1z1nzPqa9JZ4AtkAPxf0IlIxd7 eKf3x+Zf9VxX434vE9Gh9HEnMCGBgsg4IxRTOoxpOPGK0cs6Mh+GlSY6O9tx+iOmjJuW IYSVKgcN6O5aLo5+nf5C0n721K/ysrq33brNcZZMzk+c0fIQCyKT9wIowcckQktRZRdf C84g== X-Gm-Message-State: AOAM533xLh/JKIIcRvV4MOXgvqo7w02uFK3RtIElIo0DBonTnTbwXUnk JZjDGi9Ddud2Dh0jr/zkRc1xnl5xHJLWOg== X-Google-Smtp-Source: ABdhPJxEB/4xuryrz45dwHH+7xn9F910IHqjW9h7x+4ajC/gsbDdy2CYJZnwu+AYnxSjKBJej26m1g== X-Received: by 2002:a5d:498a:: with SMTP id r10mr1062461wrq.238.1609875820079; Tue, 05 Jan 2021 11:43:40 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id s6sm151113wro.79.2021.01.05.11.43.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 11:43:39 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , "brian m . carlson" , Eric Sunshine , Johannes Schindelin , =?utf-8?q?SZEDER_G=C3=A1b?= =?utf-8?q?or?= , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v5 12/23] mktag tests: improve verify_object() test coverage Date: Tue, 5 Jan 2021 20:42:41 +0100 Message-Id: <20210105194252.627-13-avarab@gmail.com> X-Mailer: git-send-email 2.29.2.222.g5d2a92d10f8 In-Reply-To: <20201223013606.7972-1-avarab@gmail.com> References: <20201223013606.7972-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The verify_object() function in "mktag.c" is tasked with ensuring that our tag refers to a valid object. The existing test for this might fail because it was also testing that "type taggg" didn't refer to a valid object type (it should be "type tag"), or because we referred to a valid object but got the type wrong. Let's split these tests up, so we're testing all combinations of a non-existing object and in invalid/wrong "type" lines. We need to provide GIT_TEST_GETTEXT_POISON=false here because the "invalid object type" error is emitted by parse_loose_header_extended(), which has that message already marked for translation. Another option would be to use test_i18ngrep, but I prefer always running the test, not skipping it under gettext poison testing. I'm not testing this in combination with "git replace". That'll be done in a subsequent commit. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t3800-mktag.sh | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/t/t3800-mktag.sh b/t/t3800-mktag.sh index 47380292223..ced540035d4 100755 --- a/t/t3800-mktag.sh +++ b/t/t3800-mktag.sh @@ -14,7 +14,8 @@ test_description='git mktag: tag object verify test' check_verify_failure () { expect="$2" test_expect_success "$1" ' - test_must_fail git mktag message && + test_must_fail env GIT_TEST_GETTEXT_POISON=false \ + git mktag message && grep "$expect" message ' } @@ -136,19 +137,52 @@ check_verify_failure '"type" line type-name length check' \ '^error: char.*: type too long$' ############################################################ -# 9. verify object (SHA1/type) check +# 9. verify object (hash/type) check cat >tag.sig < 0 +0000 + +EOF + +check_verify_failure 'verify object (hash/type) check -- correct type, nonexisting object' \ + '^error: char7: could not verify object.*$' + +cat >tag.sig < 0 +0000 EOF -check_verify_failure 'verify object (SHA1/type) check' \ +check_verify_failure 'verify object (hash/type) check -- made-up type, valid object' \ + '^fatal: invalid object type' + +cat >tag.sig < 0 +0000 + +EOF + +check_verify_failure 'verify object (hash/type) check -- made-up type, nonexisting object' \ '^error: char7: could not verify object.*$' +cat >tag.sig < 0 +0000 + +EOF + +check_verify_failure 'verify object (hash/type) check -- mismatched type, valid object' \ + '^error: char7: could not verify object' + ############################################################ # 10. verify tag-name check From patchwork Tue Jan 5 19:42:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12000275 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4B037C433DB for ; Tue, 5 Jan 2021 19:44:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1F76722D6F for ; Tue, 5 Jan 2021 19:44:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730940AbhAEToz (ORCPT ); Tue, 5 Jan 2021 14:44:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730926AbhAEToy (ORCPT ); Tue, 5 Jan 2021 14:44:54 -0500 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 894C8C0617A6 for ; Tue, 5 Jan 2021 11:43:42 -0800 (PST) Received: by mail-wm1-x330.google.com with SMTP id 190so608055wmz.0 for ; Tue, 05 Jan 2021 11:43:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Cmw+KtIkVva3phLPHPxZT2YEJYOfdGs2hrBDNqixXno=; b=Wk8TdAq/XnJgjJ8mleAcuYubFDJEuWA/Nv2kSkMFgxaYYUIgaTjY/ujfu/YB3utwun EZlfPa8SWQZ5Bc4fLrdreOygkyIbtKvCEltwdpHrrMXSvej+w/p/XTzlUW2zRts+5Rqp Im260AM/vR7A498CaqglxNniaB62YkCl+lT7rh8EdjfIIpb7d5lVlwee2M2gcs6vppSb XS6U+Jg4zThrHTAgjXZ/BPajSIMCWPL70THtrztNzbBVxJVyPvuspSa7ep4ZUB+FrV7Z y/bWfwO1mbuPo2o5QgBF5gA1tbKamqT2ssC3b/aWFTFcK0T0wBTEOinHxuBSMPtJ/6Ei 6ujA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Cmw+KtIkVva3phLPHPxZT2YEJYOfdGs2hrBDNqixXno=; b=EyDidKOGmA+FtVEo62jSEv6bfbtqbawG6OHKcfy3JXyY3Fhm97c/0yhXaeCpD7abGC P3AdjFY+w9ARYOTPL5WAT2fVfXIaH/t78Ulw7frXSpRoLIZPJLwdjkW1TfZV8mFcfMpl 6E6PWbm5CQVLpoji0oOxh8J3Nzct+Ha/mcnFUBlA1mgCeAVQSA9y6bM+X26nEIFazDEU TZjlolEiK+dVn1KRdp9IsqoutjMPZWWsDY5J6UlnZXYkh/PDl9vr/QuTUYO2E9CLI2fV 1cCZbuwCRuj2TTla+0rKWkgkqflTbEn7gqgK+SgG8Cq/SZi2rxo0RZVY68/DQ8Mg28Re /bIg== X-Gm-Message-State: AOAM531R0IYa1EEHQyJ7NCtZH7YTTpIcDp8EcILwgDdg0jUDL1wKEHf7 vDjDh81CnJYHxgDDQteEVn9LVylb77IxLQ== X-Google-Smtp-Source: ABdhPJxXih3PgtH8UEFIaVCBe52r/Fim/qAycOBSwbmO5b2eY5EOKZpRTu3LnBf/jZ2VZiEBDto9pg== X-Received: by 2002:a1c:4604:: with SMTP id t4mr595878wma.17.1609875821031; Tue, 05 Jan 2021 11:43:41 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id s6sm151113wro.79.2021.01.05.11.43.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 11:43:40 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , "brian m . carlson" , Eric Sunshine , Johannes Schindelin , =?utf-8?q?SZEDER_G=C3=A1b?= =?utf-8?q?or?= , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v5 13/23] mktag tests: test verify_object() with replaced objects Date: Tue, 5 Jan 2021 20:42:42 +0100 Message-Id: <20210105194252.627-14-avarab@gmail.com> X-Mailer: git-send-email 2.29.2.222.g5d2a92d10f8 In-Reply-To: <20201223013606.7972-1-avarab@gmail.com> References: <20201223013606.7972-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Add tests to demonstrate what "mktag" does in the face of replaced objects. There was an existing test for replaced objects fed to "mktag" added in cc400f50112 (mktag: call "check_sha1_signature" with the replacement sha1, 2009-01-23), but that one only tests a commit->commit mapping. Not a mapping to a different type as like we're also testing for here. We could remove the "mktag" test in t6050-replace.sh now if the created tag wasn't being used by a subsequent "fsck" test. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t3800-mktag.sh | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/t/t3800-mktag.sh b/t/t3800-mktag.sh index ced540035d4..fbaf648491f 100755 --- a/t/t3800-mktag.sh +++ b/t/t3800-mktag.sh @@ -38,7 +38,11 @@ test_expect_mktag_success() { # for the tag. test_expect_success 'setup' ' test_commit A && - head=$(git rev-parse --verify HEAD) + test_commit B && + head=$(git rev-parse --verify HEAD) && + head_parent=$(git rev-parse --verify HEAD~) && + tree=$(git rev-parse HEAD^{tree}) && + blob=$(git rev-parse --verify HEAD:B.t) ' ############################################################ @@ -180,6 +184,35 @@ tagger . <> 0 +0000 EOF +check_verify_failure 'verify object (hash/type) check -- mismatched type, valid object' \ + '^error: char7: could not verify object' + +############################################################ +# 9.5. verify object (hash/type) check -- replacement + +test_expect_success 'setup replacement of commit -> commit and tree -> blob' ' + git replace $head_parent $head && + git replace -f $tree $blob +' + +cat >tag.sig < 0 +0000 + +EOF + +test_expect_mktag_success 'tag to a commit replaced by another commit' + +cat >tag.sig < 0 +0000 + +EOF + check_verify_failure 'verify object (hash/type) check -- mismatched type, valid object' \ '^error: char7: could not verify object' From patchwork Tue Jan 5 19:42:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12000283 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DD31DC433E6 for ; Tue, 5 Jan 2021 19:44:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B746222D6F for ; Tue, 5 Jan 2021 19:44:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730942AbhAETo7 (ORCPT ); Tue, 5 Jan 2021 14:44:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730927AbhAEToy (ORCPT ); Tue, 5 Jan 2021 14:44:54 -0500 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F853C0617A7 for ; Tue, 5 Jan 2021 11:43:43 -0800 (PST) Received: by mail-wm1-x32d.google.com with SMTP id g185so623759wmf.3 for ; Tue, 05 Jan 2021 11:43:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lCKf2NBbDpDsTMTjqpZ3kMR5PrX6KPli2kTefNDk+II=; b=G0skBFnSUxbHBDSDKAOjkM9L4FgLqlP8usTaJqxyxIbDcFOgy0jSP0WqUmY10Z28rD Kv+wLZCsprmDZnDpLEjfVb6eXHeenlkqOhzUlrBaxkTqkzxUaHKjAlCYAuTJHZtfSCKS GpcNaUN8X50hQ9pgV9Ja9Vyem778phuaaHG/r/GirvaVZbO7H5Z5ypJdqg7cT3AQB/tM QKsTA3hd53I8Qf6yV7n0eMhNZVcYqlb/V/GN6U8JEY61YXdinHw7yfSmzVJpRD6RlbLX 1EzHfXy0OFDYZPxZ1XSEbGhkIzt/WzZqjMqe612/oIDo0n2etqW4T/bxdYLtzt7mLWmi Thrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lCKf2NBbDpDsTMTjqpZ3kMR5PrX6KPli2kTefNDk+II=; b=V9UyixFyD19RGaGigZ+IMkCDVUloi+iapqHiGTBJE/g3bfA+CVY8nV73ftIB2fivjb MHVsjuyPDxn9UsAs60RRkeMZ5zidT72WkKZ0aLHG3Zg+lkeooP5CcW2vwzvYrXsg4k2g o8RgM3KdMaY/fvQKZUKD3ltyyP9xW8ecA5gWXu7KuSvdWJGsDpEDHSKUa/CZ4Gmnscag lKGVwvNMIuhVOQ7NfYa7AlGe6sw+sUfPskhnSjcgit5Mr3yWu0xYvL9EbjwReyavBr8X ZdJBJr9cdgDwmBISfW6C0/r9VbMObEXtgZobOTMrwBOZXfpSbre9k2POn6p65gKW4KK1 zzwQ== X-Gm-Message-State: AOAM531StDggnwnHgkWjc2kbFgI6hmrWUESWXE2az5fT8AxLeLOHwpVi d7v8/4DTN7xKSh6rxy7rOX6LwaJ7UUElWg== X-Google-Smtp-Source: ABdhPJxsbC4jz7sms1poKgYLUzVDrnkpZFTfpeyrrySj862JLwZE2qWs3FY/brCKkCAY6orET2VuWg== X-Received: by 2002:a7b:c389:: with SMTP id s9mr576911wmj.159.1609875822011; Tue, 05 Jan 2021 11:43:42 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id s6sm151113wro.79.2021.01.05.11.43.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 11:43:41 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , "brian m . carlson" , Eric Sunshine , Johannes Schindelin , =?utf-8?q?SZEDER_G=C3=A1b?= =?utf-8?q?or?= , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v5 14/23] mktag: use default strbuf_read() hint Date: Tue, 5 Jan 2021 20:42:43 +0100 Message-Id: <20210105194252.627-15-avarab@gmail.com> X-Mailer: git-send-email 2.29.2.222.g5d2a92d10f8 In-Reply-To: <20201223013606.7972-1-avarab@gmail.com> References: <20201223013606.7972-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Change the hardcoded hint of 2^12 to 0. The default strbuf hint is perfectly fine here, and the only reason we were hardcoding it is because it survived migration from a pre-strbuf fixed-sized buffer. See fd17f5b5f77 (Replace all read_fd use with strbuf_read, and get rid of it., 2007-09-10) for that migration. Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/mktag.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/mktag.c b/builtin/mktag.c index 4982d3a93ef..ff7ac8e0e5d 100644 --- a/builtin/mktag.c +++ b/builtin/mktag.c @@ -161,7 +161,7 @@ int cmd_mktag(int argc, const char **argv, const char *prefix) if (argc != 1) usage("git mktag"); - if (strbuf_read(&buf, 0, 4096) < 0) { + if (strbuf_read(&buf, 0, 0) < 0) { die_errno("could not read from stdin"); } From patchwork Tue Jan 5 19:42:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12000285 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23AA4C433E0 for ; Tue, 5 Jan 2021 19:45:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EDB7B22D5A for ; Tue, 5 Jan 2021 19:45:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730964AbhAETpE (ORCPT ); Tue, 5 Jan 2021 14:45:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730957AbhAETpD (ORCPT ); Tue, 5 Jan 2021 14:45:03 -0500 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A637C0617A9 for ; Tue, 5 Jan 2021 11:43:44 -0800 (PST) Received: by mail-wr1-x430.google.com with SMTP id r3so364686wrt.2 for ; Tue, 05 Jan 2021 11:43:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=g0UJ+359V/LQdHfLW7yM0GtnBSIOEuMSuU1g6/NH5NI=; b=iuoi4WgnxQdKYbcZBPBqIR4e/0gAxulFdszI6Htp+B87TeLEz0VvflcOqMDhT2Hhq9 UqPvqDT/5sfpIom7xQYetBmumdiRcQEfJa/u5HoNg2jDtX5RFONEdhPcF1m4Bbq5e1Q/ FJ556asps3U7aGwXBn3JS2vfmaGhrzMjSyFonMKv5lasOwZn79KWhd2yi2uyZqa4uqDR BPYYOyGzfegQYy9OsGWCDt28ZdhsC0rgA7eF4zeYqnuXxg+9j5iq3+76NlAYnMN37LXd GwA/sl/L8GnAeZikOL1mwtol0HwPyoJD/vHxzqy2Ci62p+BhJjQkLNgct7AhLHd4CiFJ 02vQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=g0UJ+359V/LQdHfLW7yM0GtnBSIOEuMSuU1g6/NH5NI=; b=B8r+4UhwEre6CZmLZaGUnpPWb10ocRWTScZfhUpci6vdRAMGAG9RbZ9tMlBMB0YGBM KYeb7i8IphXAZ5qQDXk0F6M6PY5bwZihzDrZn7EdPew5EQ2PfaokKBZLlbJxUxUDdh2h G8jlZrbce/bcKiXA9qw+8+WWkDKz726JFSRhDHHhoOt4gr4YCaNSJLVhI+SIUDBoUL2e L6sQQIEurlFXqGa1LaD1Z98aVQY6IAIA0pmEU08qbEDqbH20JmyFcdnNzNRTj4C/sgLH hBPQp8MxsW2jQYJtX8HYC6U2kdSw3PynwVaTH291+dbOw9ion/lce2HaKShyk1GXw9GY xGsA== X-Gm-Message-State: AOAM533Dbgoh+e1LHUY2pPK1gHX9M8LoB0dbLYzYEfJbZaPr7U+cK6oE G0/E/vOdUG0l6PTKNZgmXLpdGV9qoit8Vw== X-Google-Smtp-Source: ABdhPJwJfC7g8CuYA8oCUV/n/LCuvTle6brQeFLEUY935ACyKrIXOYikG1tcMK0EST6vFS31ravSwA== X-Received: by 2002:adf:f401:: with SMTP id g1mr1078046wro.258.1609875822992; Tue, 05 Jan 2021 11:43:42 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id s6sm151113wro.79.2021.01.05.11.43.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 11:43:42 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , "brian m . carlson" , Eric Sunshine , Johannes Schindelin , =?utf-8?q?SZEDER_G=C3=A1b?= =?utf-8?q?or?= , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v5 15/23] mktag: remove redundant braces in one-line body "if" Date: Tue, 5 Jan 2021 20:42:44 +0100 Message-Id: <20210105194252.627-16-avarab@gmail.com> X-Mailer: git-send-email 2.29.2.222.g5d2a92d10f8 In-Reply-To: <20201223013606.7972-1-avarab@gmail.com> References: <20201223013606.7972-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org This minor stylistic churn is usually something we'd avoid, but if we don't do this then the file after changes in subsequent commits will only have this minor style inconsistency, so let's change this while we're at it. Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/mktag.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/builtin/mktag.c b/builtin/mktag.c index ff7ac8e0e5d..97ca5f28b1b 100644 --- a/builtin/mktag.c +++ b/builtin/mktag.c @@ -161,9 +161,8 @@ int cmd_mktag(int argc, const char **argv, const char *prefix) if (argc != 1) usage("git mktag"); - if (strbuf_read(&buf, 0, 0) < 0) { + if (strbuf_read(&buf, 0, 0) < 0) die_errno("could not read from stdin"); - } /* Verify it for some basic sanity: it needs to start with "object \ntype\ntagger " */ From patchwork Tue Jan 5 19:42:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12000287 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 40EE8C433DB for ; Tue, 5 Jan 2021 19:45:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1085622D72 for ; Tue, 5 Jan 2021 19:45:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730961AbhAETpE (ORCPT ); Tue, 5 Jan 2021 14:45:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730927AbhAETpD (ORCPT ); Tue, 5 Jan 2021 14:45:03 -0500 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7EFE1C0617AA for ; Tue, 5 Jan 2021 11:43:45 -0800 (PST) Received: by mail-wm1-x334.google.com with SMTP id g185so623828wmf.3 for ; Tue, 05 Jan 2021 11:43:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zKkRoTKMdXvXYan50w7uT55OsUoFQy+xWAnGaL50DuQ=; b=HpDCiNy73ifv5W5VXCEOWX9y89B+sS4HY3wN16pMYH06PaC7dDNrc63ogt2G6dbrNn s3ooDlVua/v7kMUTIWPqZ+rXllbu4MJEmQ3aC/edhXxhSFCVKw09rMLfOqj//qDCXjm4 y/8gsT0LUtFelumbTtmm7wBKRXm92GJgF2NR5eETAshL0tGOy0i4BQlMBaEjHe+lJvut mWriwyuyrapWuMh5YavvymoMT7RZUkoIWAaGITLVHx9IMa4OBee1w0nGjx0Q7sb7LJyj GE4mWe+lp8QIDHtSUMX86adbKlRM6gZ41/Dv75JB5T5yXdpntjEelOSTQsYMSzPHXVpn Sj7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zKkRoTKMdXvXYan50w7uT55OsUoFQy+xWAnGaL50DuQ=; b=gvgJCrTDA1L8ivAAEKxtBZaH6U5oDZpKRaASlU/DDUOOrPX3ZazEW56bCh7vy2NW9H F4J7DcR4w8fTLytoaxO9tTG55P0uuzizF1VLyyu3vXbKmERGcxFW1uv+Cn+KBaeNfJ+0 0vBMyRwM6RN4e/hPoMY5+s0zfrkS8BU0d7gJ5ExKyqcKPg/G5u9IvGhrfiB+uOJjjq9E vkhZADBbGJFd2nCTIX59icTZhHRGOP6qilR5+/aS+acrE6/r010QAswxyeyHtNg4ikZQ AVjQ/+s0GFaZ4lg1TjXbxeBU1qQLAIES71jsJcd7QIeLW4elByj0k25N/w6TO2W6d/I7 KV8A== X-Gm-Message-State: AOAM531vvlSEhNt7MOPzjkfCLwfmy3oz/9pnBmIB+ilyn+ChUJ1cJIeG diy6aDTRycOhJ5cA2IyuBdyGy92tZBLp5w== X-Google-Smtp-Source: ABdhPJwxlFvhrdd8v8di4CknXzw28n4cAQF9w3mIGe8h7iAnVlrQa56LlPBdaqVeiZ5GTiSGaJV9dg== X-Received: by 2002:a7b:c406:: with SMTP id k6mr643124wmi.90.1609875824080; Tue, 05 Jan 2021 11:43:44 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id s6sm151113wro.79.2021.01.05.11.43.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 11:43:43 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , "brian m . carlson" , Eric Sunshine , Johannes Schindelin , =?utf-8?q?SZEDER_G=C3=A1b?= =?utf-8?q?or?= , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v5 16/23] mktag: use puts(str) instead of printf("%s\n", str) Date: Tue, 5 Jan 2021 20:42:45 +0100 Message-Id: <20210105194252.627-17-avarab@gmail.com> X-Mailer: git-send-email 2.29.2.222.g5d2a92d10f8 In-Reply-To: <20201223013606.7972-1-avarab@gmail.com> References: <20201223013606.7972-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org This introduces no functional change, but refactors the print-out of the hash at the end to do the same thing with less code. Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/mktag.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/mktag.c b/builtin/mktag.c index 97ca5f28b1b..d89a3c201de 100644 --- a/builtin/mktag.c +++ b/builtin/mktag.c @@ -173,6 +173,6 @@ int cmd_mktag(int argc, const char **argv, const char *prefix) die("unable to write tag file"); strbuf_release(&buf); - printf("%s\n", oid_to_hex(&result)); + puts(oid_to_hex(&result)); return 0; } From patchwork Tue Jan 5 19:42:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12000299 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4764C4332B for ; Tue, 5 Jan 2021 19:45:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7455F22D6F for ; Tue, 5 Jan 2021 19:45:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730984AbhAETpa (ORCPT ); Tue, 5 Jan 2021 14:45:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730943AbhAETp2 (ORCPT ); Tue, 5 Jan 2021 14:45:28 -0500 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 264D3C0617AB for ; Tue, 5 Jan 2021 11:43:47 -0800 (PST) Received: by mail-wm1-x336.google.com with SMTP id e25so641007wme.0 for ; Tue, 05 Jan 2021 11:43:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cUPzq8AQxqHKZgHa3BfUS7f/v2bVXFzpXyULxhZFQ6Q=; b=TgnwUmOMH0leMncVr2/RBXqUaq+JW8p6J22NT4tj6fXtm30FFnwzbbJukKnJzSFPdH 76i5q3s+pmdN0KvusBZdi5HY031LZWYcNK3CHBPbtsgHqLIClUepR1Gx6vmL5Iwxv+1e /rlc15mDWhwkZMQJ/Oq+qrnm98s/aedn71UEccWfsWpZHU1Q4gpdUs8+cNS5ZxziuRcX RJf8BbEvyiQeXmmUniT0ME33sKQQldOTY6NImPlT5UVC5/Cl4vCEKXvQGALtd/4xIBmM kHYRdwjnIzEqr5VhIjWeiI2RxubZ4zWyJ5rsh1PS0UTgdw7QKVcDGEDQDiI3UjGeEDp8 9Ndw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cUPzq8AQxqHKZgHa3BfUS7f/v2bVXFzpXyULxhZFQ6Q=; b=sEpplKVWbdK/QcKeat74pSBv/oH+P+9OXbcQw1p1TJkcCD6bb+8ndyqEmIvSUml9v5 Yk+bUTI27eNhpG8QDvHTiRqero6EidLalXcsTLjzV+XDDoey5Nw7KDhEfrsGSBwulNnc Ou6mwHSzSF3XQdCIiuhwu3xTsgBW+z7FIfd42SqUXWfm+DGcxU9+E+5jvrbp8cfU+6rU Tafp3yG0bSUKcA+5IF+kgVokKln4sWNHg+04wUBvVI8l179nBNk2VL8MhoiHYsJLCIxp UvViBw0TvqN3y0GMNiZd27Am+95jRg5i+BPu4WRfSodoUkckJi9wLyhXW6WHrxj6lybl wf8g== X-Gm-Message-State: AOAM531CJWiNi0xN2g+yunXPzDX3sBRe3LKCfmWVM5zjC6afssjFx8aA DMnfTiBmIt+qpR+WCChVCk4Cg5lZAmnxGw== X-Google-Smtp-Source: ABdhPJz3TmT7KZo63izalSgIrH5dOUdcDmFcYIdGup1caU/vfgVGEHG36s+Nh0SONJIcFeKSvNEfyw== X-Received: by 2002:a05:600c:1483:: with SMTP id c3mr606204wmh.87.1609875825183; Tue, 05 Jan 2021 11:43:45 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id s6sm151113wro.79.2021.01.05.11.43.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 11:43:44 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , "brian m . carlson" , Eric Sunshine , Johannes Schindelin , =?utf-8?q?SZEDER_G=C3=A1b?= =?utf-8?q?or?= , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v5 17/23] mktag: use fsck instead of custom verify_tag() Date: Tue, 5 Jan 2021 20:42:46 +0100 Message-Id: <20210105194252.627-18-avarab@gmail.com> X-Mailer: git-send-email 2.29.2.222.g5d2a92d10f8 In-Reply-To: <20201223013606.7972-1-avarab@gmail.com> References: <20201223013606.7972-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Change the validation logic in "mktag" to use fsck's fsck_tag() instead of its own custom parser. Curiously the logic for both dates back to the same commit[1]. Let's unify them so we're not maintaining two sets functions to verify that a tag is OK. The behavior of fsck_tag() and the old "mktag" code being removed here is different in few aspects. I think it makes sense to remove some of those checks, namely: A. fsck only cares that the timezone matches [-+][0-9]{4}. The mktag code disallowed values larger than 1400. Yes there's currently no timezone with a greater offset[2], but since we allow any number of non-offical timezones (e.g. +1234) passing this through seems fine. Git also won't break in the future if e.g. French Polynesia decides it needs to outdo the Line Islands when it comes to timezone extravagance. B. fsck allows missing author names such as "tagger ", mktag wouldn't, but would allow e.g. "tagger [2 spaces] " (but not "tagger [1 space] "). Now we allow all of these. C. Like B, but "mktag" disallowed spaces in the part, fsck allows it. In some ways fsck_tag() is stricter than "mktag" was, namely: D. fsck disallows zero-padded dates, but mktag didn't care. So e.g. the timestamp "0000000000 +0000" produces an error now. A test in "t1006-cat-file.sh" relied on this, it's been changed to use "hash-object" (without fsck) instead. There was one check I deemed worth keeping by porting it over to fsck_tag(): E. "mktag" did not allow any custom headers, and by extension (as an empty commit is allowed) also forbade an extra stray trailing newline after the headers it knew about. Add a new check in the "ignore" category to fsck and use it. This somewhat abuses the facility added in efaba7cc77f (fsck: optionally ignore specific fsck issues completely, 2015-06-22). This is somewhat of hack, but probably the least invasive change we can make here. The fsck command will shuffle these categories around, e.g. under --strict the "info" becomes a "warn" and "warn" becomes "error". Existing users of fsck's (and others, e.g. index-pack) --strict option rely on this. So we need to put something into a category that'll be ignored by all existing users of the API. Pretending that fsck.extraHeaderEntry=error ("ignore" by default) was set serves to do this for us. 1. ec4465adb38 (Add "tag" objects that can be used to sign other objects., 2005-04-25) 2. https://en.wikipedia.org/wiki/List_of_UTC_time_offsets Signed-off-by: Ævar Arnfjörð Bjarmason --- Documentation/git-mktag.txt | 9 +- builtin/mktag.c | 196 +++++++++--------------------------- fsck.c | 32 +++++- fsck.h | 9 ++ t/t1006-cat-file.sh | 2 +- t/t3800-mktag.sh | 63 ++++++------ 6 files changed, 127 insertions(+), 184 deletions(-) diff --git a/Documentation/git-mktag.txt b/Documentation/git-mktag.txt index 20af1915e9e..fa070e21a0b 100644 --- a/Documentation/git-mktag.txt +++ b/Documentation/git-mktag.txt @@ -25,7 +25,14 @@ write a tag found in `my-tag`: git hash-object -t tag -w --stdin ` messages are promoted +from warnings to errors (so e.g. a missing "tagger" line is an error). + +Extra headers in the object are also an error under mktag, but ignored +by linkgit:git-fsck[1] Tag Format ---------- diff --git a/builtin/mktag.c b/builtin/mktag.c index d89a3c201de..4dd35bc79e2 100644 --- a/builtin/mktag.c +++ b/builtin/mktag.c @@ -2,160 +2,60 @@ #include "tag.h" #include "replace-object.h" #include "object-store.h" +#include "fsck.h" -/* - * A signature file has a very simple fixed format: four lines - * of "object " + "type " + "tag " + - * "tagger ", followed by a blank line, a free-form tag - * message and a signature block that git itself doesn't care about, - * but that can be verified with gpg or similar. - * - * The first four lines are guaranteed to be at least 83 bytes: - * "object \n" is 48 bytes, "type tag\n" at 9 bytes is the - * shortest possible type-line, "tag .\n" at 6 bytes is the shortest - * single-character-tag line, and "tagger . <> 0 +0000\n" at 20 bytes is - * the shortest possible tagger-line. - */ - -/* - * We refuse to tag something we can't verify. Just because. - */ -static int verify_object(const struct object_id *oid, const char *expected_type) +static int mktag_fsck_error_func(struct fsck_options *o, + const struct object_id *oid, + enum object_type object_type, + int msg_type, const char *message) { - int ret = -1; - enum object_type type; - unsigned long size; - void *buffer = read_object_file(oid, &type, &size); - const struct object_id *repl = lookup_replace_object(the_repository, oid); - - if (buffer) { - if (type == type_from_string(expected_type)) { - ret = check_object_signature(the_repository, repl, - buffer, size, - expected_type); - } - free(buffer); + switch (msg_type) { + case FSCK_WARN: + case FSCK_ERROR: + /* + * We treat both warnings and errors as errors, things + * like missing "tagger" lines are "only" warnings + * under fsck, we've always considered them an error. + */ + fprintf_ln(stderr, "error: tag input does not pass fsck: %s", message); + return 1; + default: + BUG("%d (FSCK_IGNORE?) should never trigger this callback", + msg_type); } - return ret; } -static int verify_tag(char *buffer, unsigned long size) +static int verify_object_in_tag(struct object_id *tagged_oid, int *tagged_type) { - int typelen; - char type[20]; - struct object_id oid; - const char *object, *type_line, *tag_line, *tagger_line, *lb, *rb, *p; - size_t len; - - if (size < 84) - return error("wanna fool me ? you obviously got the size wrong !"); - - buffer[size] = 0; - - /* Verify object line */ - object = buffer; - if (memcmp(object, "object ", 7)) - return error("char%d: does not start with \"object \"", 0); - - if (parse_oid_hex(object + 7, &oid, &p)) - return error("char%d: could not get SHA1 hash", 7); - - /* Verify type line */ - type_line = p + 1; - if (memcmp(type_line - 1, "\ntype ", 6)) - return error("char%d: could not find \"\\ntype \"", 47); - - /* Verify tag-line */ - tag_line = strchr(type_line, '\n'); - if (!tag_line) - return error("char%"PRIuMAX": could not find next \"\\n\"", - (uintmax_t) (type_line - buffer)); - tag_line++; - if (memcmp(tag_line, "tag ", 4) || tag_line[4] == '\n') - return error("char%"PRIuMAX": no \"tag \" found", - (uintmax_t) (tag_line - buffer)); - - /* Get the actual type */ - typelen = tag_line - type_line - strlen("type \n"); - if (typelen >= sizeof(type)) - return error("char%"PRIuMAX": type too long", - (uintmax_t) (type_line+5 - buffer)); - - memcpy(type, type_line+5, typelen); - type[typelen] = 0; - - /* Verify that the object matches */ - if (verify_object(&oid, type)) - return error("char%d: could not verify object %s", 7, oid_to_hex(&oid)); - - /* Verify the tag-name: we don't allow control characters or spaces in it */ - tag_line += 4; - for (;;) { - unsigned char c = *tag_line++; - if (c == '\n') - break; - if (c > ' ') - continue; - return error("char%"PRIuMAX": could not verify tag name", - (uintmax_t) (tag_line - buffer)); - } - - /* Verify the tagger line */ - tagger_line = tag_line; - - if (memcmp(tagger_line, "tagger ", 7)) - return error("char%"PRIuMAX": could not find \"tagger \"", - (uintmax_t) (tagger_line - buffer)); - - /* - * Check for correct form for name and email - * i.e. " <" followed by "> " on _this_ line - * No angle brackets within the name or email address fields. - * No spaces within the email address field. - */ - tagger_line += 7; - if (!(lb = strstr(tagger_line, " <")) || !(rb = strstr(lb+2, "> ")) || - strpbrk(tagger_line, "<>\n") != lb+1 || - strpbrk(lb+2, "><\n ") != rb) - return error("char%"PRIuMAX": malformed tagger field", - (uintmax_t) (tagger_line - buffer)); - - /* Check for author name, at least one character, space is acceptable */ - if (lb == tagger_line) - return error("char%"PRIuMAX": missing tagger name", - (uintmax_t) (tagger_line - buffer)); - - /* timestamp, 1 or more digits followed by space */ - tagger_line = rb + 2; - if (!(len = strspn(tagger_line, "0123456789"))) - return error("char%"PRIuMAX": missing tag timestamp", - (uintmax_t) (tagger_line - buffer)); - tagger_line += len; - if (*tagger_line != ' ') - return error("char%"PRIuMAX": malformed tag timestamp", - (uintmax_t) (tagger_line - buffer)); - tagger_line++; - - /* timezone, 5 digits [+-]hhmm, max. 1400 */ - if (!((tagger_line[0] == '+' || tagger_line[0] == '-') && - strspn(tagger_line+1, "0123456789") == 4 && - tagger_line[5] == '\n' && atoi(tagger_line+1) <= 1400)) - return error("char%"PRIuMAX": malformed tag timezone", - (uintmax_t) (tagger_line - buffer)); - tagger_line += 6; - - /* Verify the blank line separating the header from the body */ - if (*tagger_line != '\n') - return error("char%"PRIuMAX": trailing garbage in tag header", - (uintmax_t) (tagger_line - buffer)); + int ret; + enum object_type type; + unsigned long size; + void *buffer; + const struct object_id *repl; + + buffer = read_object_file(tagged_oid, &type, &size); + if (!buffer) + die("could not read tagged object '%s'", + oid_to_hex(tagged_oid)); + if (type != *tagged_type) + die("object '%s' tagged as '%s', but is a '%s' type", + oid_to_hex(tagged_oid), + type_name(*tagged_type), type_name(type)); + + repl = lookup_replace_object(the_repository, tagged_oid); + ret = check_object_signature(the_repository, repl, + buffer, size, type_name(*tagged_type)); + free(buffer); - /* The actual stuff afterwards we don't care about.. */ - return 0; + return ret; } int cmd_mktag(int argc, const char **argv, const char *prefix) { struct strbuf buf = STRBUF_INIT; + struct fsck_options fsck_options = FSCK_OPTIONS_STRICT; + struct object_id tagged_oid; + int tagged_type; struct object_id result; if (argc != 1) @@ -164,10 +64,14 @@ int cmd_mktag(int argc, const char **argv, const char *prefix) if (strbuf_read(&buf, 0, 0) < 0) die_errno("could not read from stdin"); - /* Verify it for some basic sanity: it needs to start with - "object \ntype\ntagger " */ - if (verify_tag(buf.buf, buf.len) < 0) - die("invalid tag signature file"); + fsck_options.error_func = mktag_fsck_error_func; + fsck_set_msg_type(&fsck_options, "extraheaderentry", "warn"); + if (fsck_tag_standalone(NULL, buf.buf, buf.len, &fsck_options, + &tagged_oid, &tagged_type)) + die("tag on stdin did not pass our strict fsck check"); + + if (verify_object_in_tag(&tagged_oid, &tagged_type)) + die("tag on stdin did not refer to a valid object"); if (write_object_file(buf.buf, buf.len, tag_type, &result) < 0) die("unable to write tag file"); diff --git a/fsck.c b/fsck.c index f82e2fe9e30..bed5e20e03b 100644 --- a/fsck.c +++ b/fsck.c @@ -80,7 +80,9 @@ static struct oidset gitmodules_done = OIDSET_INIT; /* infos (reported as warnings, but ignored by default) */ \ FUNC(GITMODULES_PARSE, INFO) \ FUNC(BAD_TAG_NAME, INFO) \ - FUNC(MISSING_TAGGER_ENTRY, INFO) + FUNC(MISSING_TAGGER_ENTRY, INFO) \ + /* ignored (elevated when requested) */ \ + FUNC(EXTRA_HEADER_ENTRY, IGNORE) #define MSG_ID(id, msg_type) FSCK_MSG_##id, enum fsck_msg_id { @@ -911,6 +913,16 @@ static int fsck_tag(const struct object_id *oid, const char *buffer, unsigned long size, struct fsck_options *options) { struct object_id tagged_oid; + int tagged_type; + return fsck_tag_standalone(oid, buffer, size, options, &tagged_oid, + &tagged_type); +} + +int fsck_tag_standalone(const struct object_id *oid, const char *buffer, + unsigned long size, struct fsck_options *options, + struct object_id *tagged_oid, + int *tagged_type) +{ int ret = 0; char *eol; struct strbuf sb = STRBUF_INIT; @@ -924,7 +936,7 @@ static int fsck_tag(const struct object_id *oid, const char *buffer, ret = report(options, oid, OBJ_TAG, FSCK_MSG_MISSING_OBJECT, "invalid format - expected 'object' line"); goto done; } - if (parse_oid_hex(buffer, &tagged_oid, &p) || *p != '\n') { + if (parse_oid_hex(buffer, tagged_oid, &p) || *p != '\n') { ret = report(options, oid, OBJ_TAG, FSCK_MSG_BAD_OBJECT_SHA1, "invalid 'object' line format - bad sha1"); if (ret) goto done; @@ -940,7 +952,8 @@ static int fsck_tag(const struct object_id *oid, const char *buffer, ret = report(options, oid, OBJ_TAG, FSCK_MSG_MISSING_TYPE, "invalid format - unexpected end after 'type' line"); goto done; } - if (type_from_string_gently(buffer, eol - buffer, 1) < 0) + *tagged_type = type_from_string_gently(buffer, eol - buffer, 1); + if (*tagged_type < 0) ret = report(options, oid, OBJ_TAG, FSCK_MSG_BAD_TYPE, "invalid 'type' value"); if (ret) goto done; @@ -975,6 +988,19 @@ static int fsck_tag(const struct object_id *oid, const char *buffer, else ret = fsck_ident(&buffer, oid, OBJ_TAG, options); + if (!starts_with(buffer, "\n")) { + /* + * The verify_headers() check will allow + * e.g. "[...]tagger \nsome + * garbage\n\nmessage" to pass, thinking "some + * garbage" could be a custom header. E.g. "mktag" + * doesn't want any unknown headers. + */ + ret = report(options, oid, OBJ_TAG, FSCK_MSG_EXTRA_HEADER_ENTRY, "invalid format - extra header(s) after 'tagger'"); + if (ret) + goto done; + } + done: strbuf_release(&sb); return ret; diff --git a/fsck.h b/fsck.h index 69cf715e798..29ee4c45e87 100644 --- a/fsck.h +++ b/fsck.h @@ -62,6 +62,15 @@ int fsck_walk(struct object *obj, void *data, struct fsck_options *options); int fsck_object(struct object *obj, void *data, unsigned long size, struct fsck_options *options); +/* + * fsck a tag, and pass info about it back to the caller. This is + * exposed fsck_object() internals for git-mktag(1). + */ +int fsck_tag_standalone(const struct object_id *oid, const char *buffer, + unsigned long size, struct fsck_options *options, + struct object_id *tagged_oid, + int *tag_type); + /* * Some fsck checks are context-dependent, and may end up queued; run this * after completing all fsck_object() calls in order to resolve any remaining diff --git a/t/t1006-cat-file.sh b/t/t1006-cat-file.sh index 2f501d2dc94..5d2dc99b74a 100755 --- a/t/t1006-cat-file.sh +++ b/t/t1006-cat-file.sh @@ -166,7 +166,7 @@ tag_content="$tag_header_without_timestamp 0000000000 +0000 $tag_description" -tag_sha1=$(echo_without_newline "$tag_content" | git mktag) +tag_sha1=$(echo_without_newline "$tag_content" | git hash-object -t tag --stdin -w) tag_size=$(strlen "$tag_content") run_tests 'tag' $tag_sha1 $tag_size "$tag_content" "$tag_content" 1 diff --git a/t/t3800-mktag.sh b/t/t3800-mktag.sh index fbaf648491f..0e2a9a883ba 100755 --- a/t/t3800-mktag.sh +++ b/t/t3800-mktag.sh @@ -53,7 +53,7 @@ too short for a tag EOF check_verify_failure 'Tag object length check' \ - '^error: .*size wrong.*$' + '^error:.* missingObject:' ############################################################ # 2. object line label check @@ -66,7 +66,7 @@ tagger . <> 0 +0000 EOF -check_verify_failure '"object" line label check' '^error: char0: .*"object "$' +check_verify_failure '"object" line label check' '^error:.* missingObject:' ############################################################ # 3. object line hash check @@ -79,7 +79,7 @@ tagger . <> 0 +0000 EOF -check_verify_failure '"object" line SHA1 check' '^error: char7: .*SHA1 hash$' +check_verify_failure '"object" line check' '^error:.* badObjectSha1:' ############################################################ # 4. type line label check @@ -92,7 +92,7 @@ tagger . <> 0 +0000 EOF -check_verify_failure '"type" line label check' '^error: char.*: .*"\\ntype "$' +check_verify_failure '"type" line label check' '^error:.* missingTypeEntry:' ############################################################ # 5. type line eol check @@ -100,7 +100,7 @@ check_verify_failure '"type" line label check' '^error: char.*: .*"\\ntype "$' echo "object $head" >tag.sig printf "type tagsssssssssssssssssssssssssssssss" >>tag.sig -check_verify_failure '"type" line eol check' '^error: char.*: .*"\\n"$' +check_verify_failure '"type" line eol check' '^error:.* unterminatedHeader:' ############################################################ # 6. tag line label check #1 @@ -114,7 +114,7 @@ tagger . <> 0 +0000 EOF check_verify_failure '"tag" line label check #1' \ - '^error: char.*: no "tag " found$' + '^error:.* missingTagEntry:' ############################################################ # 7. tag line label check #2 @@ -126,7 +126,7 @@ tag EOF check_verify_failure '"tag" line label check #2' \ - '^error: char.*: no "tag " found$' + '^error:.* badType:' ############################################################ # 8. type line type-name length check @@ -138,7 +138,7 @@ tag mytag EOF check_verify_failure '"type" line type-name length check' \ - '^error: char.*: type too long$' + '^error:.* badType:' ############################################################ # 9. verify object (hash/type) check @@ -152,7 +152,7 @@ tagger . <> 0 +0000 EOF check_verify_failure 'verify object (hash/type) check -- correct type, nonexisting object' \ - '^error: char7: could not verify object.*$' + '^fatal: could not read tagged object' cat >tag.sig < 0 +0000 EOF check_verify_failure 'verify object (hash/type) check -- made-up type, valid object' \ - '^fatal: invalid object type' + '^error:.* badType:' cat >tag.sig < 0 +0000 EOF check_verify_failure 'verify object (hash/type) check -- made-up type, nonexisting object' \ - '^error: char7: could not verify object.*$' + '^error:.* badType:' cat >tag.sig < 0 +0000 EOF check_verify_failure 'verify object (hash/type) check -- mismatched type, valid object' \ - '^error: char7: could not verify object' + '^fatal: object.*tagged as.*tree.*but is.*commit' ############################################################ # 9.5. verify object (hash/type) check -- replacement @@ -214,7 +214,7 @@ tagger . <> 0 +0000 EOF check_verify_failure 'verify object (hash/type) check -- mismatched type, valid object' \ - '^error: char7: could not verify object' + '^fatal: object.*tagged as.*tree.*but is.*blob' ############################################################ # 10. verify tag-name check @@ -228,7 +228,7 @@ tagger . <> 0 +0000 EOF check_verify_failure 'verify tag-name check' \ - '^error: char.*: could not verify tag name$' + '^error:.* badTagName:' ############################################################ # 11. tagger line label check #1 @@ -242,7 +242,7 @@ This is filler EOF check_verify_failure '"tagger" line label check #1' \ - '^error: char.*: could not find "tagger "$' + '^error:.* missingTaggerEntry:' ############################################################ # 12. tagger line label check #2 @@ -257,10 +257,10 @@ This is filler EOF check_verify_failure '"tagger" line label check #2' \ - '^error: char.*: could not find "tagger "$' + '^error:.* missingTaggerEntry:' ############################################################ -# 13. disallow missing tag author name +# 13. allow missing tag author name like fsck cat >tag.sig < 0 +0000 This is filler EOF -check_verify_failure 'disallow missing tag author name' \ - '^error: char.*: missing tagger name$' +test_expect_mktag_success 'allow missing tag author name' ############################################################ # 14. disallow missing tag author name @@ -287,7 +286,7 @@ tagger T A Gger < EOF check_verify_failure 'disallow malformed tagger' \ - '^error: char.*: malformed tagger field$' + '^error:.* badEmail:' ############################################################ # 15. allow empty tag email @@ -303,7 +302,7 @@ EOF test_expect_mktag_success 'allow empty tag email' ############################################################ -# 16. disallow spaces in tag email +# 16. allow spaces in tag email like fsck cat >tag.sig < 0 +0000 EOF -check_verify_failure 'disallow spaces in tag email' \ - '^error: char.*: malformed tagger field$' +test_expect_mktag_success 'allow spaces in tag email like fsck' ############################################################ # 17. disallow missing tag timestamp @@ -328,7 +326,7 @@ tagger T A Gger __ EOF check_verify_failure 'disallow missing tag timestamp' \ - '^error: char.*: missing tag timestamp$' + '^error:.* badDate:' ############################################################ # 18. detect invalid tag timestamp1 @@ -342,7 +340,7 @@ tagger T A Gger Tue Mar 25 15:47:44 2008 EOF check_verify_failure 'detect invalid tag timestamp1' \ - '^error: char.*: missing tag timestamp$' + '^error:.* badDate:' ############################################################ # 19. detect invalid tag timestamp2 @@ -356,7 +354,7 @@ tagger T A Gger 2008-03-31T12:20:15-0500 EOF check_verify_failure 'detect invalid tag timestamp2' \ - '^error: char.*: malformed tag timestamp$' + '^error:.* badDate:' ############################################################ # 20. detect invalid tag timezone1 @@ -370,7 +368,7 @@ tagger T A Gger 1206478233 GMT EOF check_verify_failure 'detect invalid tag timezone1' \ - '^error: char.*: malformed tag timezone$' + '^error:.* badTimezone:' ############################################################ # 21. detect invalid tag timezone2 @@ -384,10 +382,10 @@ tagger T A Gger 1206478233 + 30 EOF check_verify_failure 'detect invalid tag timezone2' \ - '^error: char.*: malformed tag timezone$' + '^error:.* badTimezone:' ############################################################ -# 22. detect invalid tag timezone3 +# 22. allow invalid tag timezone3 (the maximum is -1200/+1400) cat >tag.sig < 1206478233 -1430 EOF -check_verify_failure 'detect invalid tag timezone3' \ - '^error: char.*: malformed tag timezone$' +test_expect_mktag_success 'allow invalid tag timezone' ############################################################ # 23. detect invalid header entry @@ -413,7 +410,7 @@ this line should not be here EOF check_verify_failure 'detect invalid header entry' \ - '^error: char.*: trailing garbage in tag header$' + '^error:.* extraHeaderEntry:' cat >tag.sig < 1206478233 -0500 EOF check_verify_failure 'require a blank line before an empty body (2)' \ - '^error: char.*: trailing garbage in tag header$' + '^error:.* extraHeaderEntry:' ############################################################ # 24. create valid tag From patchwork Tue Jan 5 19:42:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12000301 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B729DC4332D for ; Tue, 5 Jan 2021 19:45:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 92E7822DCC for ; Tue, 5 Jan 2021 19:45:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730981AbhAETp3 (ORCPT ); Tue, 5 Jan 2021 14:45:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730976AbhAETp3 (ORCPT ); Tue, 5 Jan 2021 14:45:29 -0500 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91445C0617B0 for ; Tue, 5 Jan 2021 11:43:47 -0800 (PST) Received: by mail-wr1-x42a.google.com with SMTP id d13so302067wrc.13 for ; Tue, 05 Jan 2021 11:43:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kb74uT4iBhesBQhjLaQ7t4/yZcNCQYxHO6w0RWtzxOA=; b=InhAeZIFaon2MSSA+MAVmxs9+DfXcRQM/CHV65R7sXdErLqrsMaI5S9DEcEP76IVlZ 8/XaHtauPKSd7yNWFfWMJefVudiM+28G8p8a2T0U1+xLjvvuZiLKo+xVbOqsvR+pRaBU 0fgGIDK4X8XUw+3IhJoPvE+iScmHjAKB1r6eNPzqoWuCSoJM7HWDXBEjQZnlbY+POCyg q/tduGhwbNuiuePxA2eTCi/bWmGzTFuGsf0lMJCfZmJaqJJ9HEXNuxJDcqNxB/NIlVmt F9kZZNcsydSLqvvDQBStalgWMSdYMmzf7sgTGWDlpw+PEwduyZXxaiIAO8vjzUfmsUo6 qRyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kb74uT4iBhesBQhjLaQ7t4/yZcNCQYxHO6w0RWtzxOA=; b=UGlXAAwOS/b9I/Oio7VUH/E0wcueM8pf/eAxnluDN6X0NOmgVK0v5mB6FXKk70/X3I mMgHv+ETpTfPVkqkGWk6CdNGz3xlZxJz+lXw/H4KhkFJLVCoCfEK3bS1boNGk5GerOHV HlKT3lif200nuERXvrYGllOU/UohYLzHXcWgcgq/ApGpzy1EN0X8pW4RqHueDfxursQU TkFYAT5elx+nHMZNXeTRXy1EDLjvw/yYb2m9ve3+GdTCSE1VC8/U8hhSLR/YN+PhKfJe wCT7g02bzFLTlri+zL1cw7N3sMm6W21IuTGrXi9ECaVFP8AgfdgpxC3JRrNyVzoSt241 Zpug== X-Gm-Message-State: AOAM533pL3zOEs9x5y6/5ZeH7G1AG6ZFgQA4/dSE/3Qj3PwQOn9QnEWR ABOyMW4J5v1Y2ZYY7sYsQZ5FuBVYJAeldQ== X-Google-Smtp-Source: ABdhPJzPgdKwM/tqN98wf8Z2T8ajpH/UTiYk4YvxHpPeXlUAw2n9RVEuW80fAdDskwLbXQKKS/rXvw== X-Received: by 2002:a05:6000:1d0:: with SMTP id t16mr1052000wrx.203.1609875826040; Tue, 05 Jan 2021 11:43:46 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id s6sm151113wro.79.2021.01.05.11.43.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 11:43:45 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , "brian m . carlson" , Eric Sunshine , Johannes Schindelin , =?utf-8?q?SZEDER_G=C3=A1b?= =?utf-8?q?or?= , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v5 18/23] fsck: make fsck_config() re-usable Date: Tue, 5 Jan 2021 20:42:47 +0100 Message-Id: <20210105194252.627-19-avarab@gmail.com> X-Mailer: git-send-email 2.29.2.222.g5d2a92d10f8 In-Reply-To: <20201223013606.7972-1-avarab@gmail.com> References: <20201223013606.7972-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Move the fsck_config() function from builtin/fsck.c to fsck.[ch]. This allows for re-using it in other tools that expose fsck logic and want to support its configuration variables. A logical continuation of this change would be to use a common function for all of {fetch,receive}.fsck.* and fsck.*. See 5d477a334a6 (fsck (receive-pack): allow demoting errors to warnings, 2015-06-22) and my own 1362df0d413 (fetch: implement fetch.fsck.*, 2018-07-27) for the relevant code. However, those routines want to not parse the fsck.skipList into OIDs, but rather pass them along with the --strict option to another process. It would be possible to refactor that whole thing so we support e.g. a "fetch." prefix, then just keep track of the skiplist as a filename instead of parsing it, and learn to spew that all out from our internal structures into something we can append to the --strict option. But instead I'm planning to re-use this in "mktag", which'll just re-use these "fsck.*" variables as-is. Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/fsck.c | 20 +------------------- fsck.c | 25 +++++++++++++++++++++++++ fsck.h | 7 +++++++ 3 files changed, 33 insertions(+), 19 deletions(-) diff --git a/builtin/fsck.c b/builtin/fsck.c index fbf26cafcfd..821e7798c70 100644 --- a/builtin/fsck.c +++ b/builtin/fsck.c @@ -73,25 +73,7 @@ static const char *printable_type(const struct object_id *oid, static int fsck_config(const char *var, const char *value, void *cb) { - if (strcmp(var, "fsck.skiplist") == 0) { - const char *path; - struct strbuf sb = STRBUF_INIT; - - if (git_config_pathname(&path, var, value)) - return 1; - strbuf_addf(&sb, "skiplist=%s", path); - free((char *)path); - fsck_set_msg_types(&fsck_obj_options, sb.buf); - strbuf_release(&sb); - return 0; - } - - if (skip_prefix(var, "fsck.", &var)) { - fsck_set_msg_type(&fsck_obj_options, var, value); - return 0; - } - - return git_default_config(var, value, cb); + return fsck_config_internal(var, value, cb, &fsck_obj_options); } static int objerror(struct object *obj, const char *err) diff --git a/fsck.c b/fsck.c index bed5e20e03b..9067a290a2e 100644 --- a/fsck.c +++ b/fsck.c @@ -1310,3 +1310,28 @@ int fsck_finish(struct fsck_options *options) oidset_clear(&gitmodules_done); return ret; } + +int fsck_config_internal(const char *var, const char *value, void *cb, + struct fsck_options *options) +{ + if (strcmp(var, "fsck.skiplist") == 0) { + const char *path; + struct strbuf sb = STRBUF_INIT; + + if (git_config_pathname(&path, var, value)) + return 1; + strbuf_addf(&sb, "skiplist=%s", path); + free((char *)path); + fsck_set_msg_types(options, sb.buf); + strbuf_release(&sb); + return 0; + } + + if (skip_prefix(var, "fsck.", &var)) { + fsck_set_msg_type(options, var, value); + return 0; + } + + return git_default_config(var, value, cb); +} + diff --git a/fsck.h b/fsck.h index 29ee4c45e87..423c467feb7 100644 --- a/fsck.h +++ b/fsck.h @@ -103,4 +103,11 @@ void fsck_put_object_name(struct fsck_options *options, const char *fsck_describe_object(struct fsck_options *options, const struct object_id *oid); +/* + * git_config() callback for use by fsck-y tools that want to support + * fsck. fsck.skipList etc. + */ +int fsck_config_internal(const char *var, const char *value, void *cb, + struct fsck_options *options); + #endif From patchwork Tue Jan 5 19:42:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12000291 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 50D04C433E9 for ; Tue, 5 Jan 2021 19:45:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2AE6A22DCC for ; Tue, 5 Jan 2021 19:45:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730970AbhAETpG (ORCPT ); Tue, 5 Jan 2021 14:45:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730966AbhAETpF (ORCPT ); Tue, 5 Jan 2021 14:45:05 -0500 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C842FC0617B1 for ; Tue, 5 Jan 2021 11:43:48 -0800 (PST) Received: by mail-wr1-x436.google.com with SMTP id m5so328248wrx.9 for ; Tue, 05 Jan 2021 11:43:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FKEzxXyKX4o3YbLhdB1nnTXUORXSqXtuMODL749Iuz0=; b=gAv20sfk4PGx6SvS8/qhYrqALDCH9tlUe6wE+z9nDNMvVjjChlmbuUK4eSpiMBxCnq bsuI9xc+5sFrRsSi4Twa6w8Lyinfld5Yw/C9OWVjTUDcvqb54yardEoPGez+cVKTYnqZ ilkRNyOs/pMBjSmvnOMSSfVqXJcH12wL+EKKwcYDbrsz54ad37KSpN5H9wTucCKEd2wv PcOXiUPRb9vv4X64YXfVI7DWapKplOcstple+GP/Y0MsKhga8n/EOd65oom6psLXCr/v 3ZUktYPWBlg/h513N40us8gUkqfFa6NI5ClpiNaDPaTyz27rKzlSFQ89NlykcMBF8wYq fbcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FKEzxXyKX4o3YbLhdB1nnTXUORXSqXtuMODL749Iuz0=; b=H9VLVwoSx36Va4STUwrKQFb9cSs3K7VXuxJ2BfZsEaJevI/HXc2df2MDXvPUeYWJRl UbN+q5Nvb35s5QLLmj9NgsppVaLJiwmZQSovHEhHfDR1jEZKNPd2EuJlk2P6+F8d/KEX wbGRfbuss92IiOUbcFIqZE4qT4SOTt9RApz1KATzGf4MoU/+gR69LnE5D8/+f6pcToSS XGYeQu311AepNUjonn3kTEq4WsRhyUIWkfpy+TQk6gwiYHOanbCfqV36cSq+CVU5GHdm 6Wi2+oL6gKr8jdIwbJ8sXz1pceL4oiDdPBhkSH6nWmfknNVNdYjF12LxzNWXvre4s5ef QnuQ== X-Gm-Message-State: AOAM5300ifckK3hcIY5CvxxqN1ERW0UXnBU/7UHYq+NRti5Pim51yR3A BpdxKEamo3wP57+jRgLoynAqNhyh4E18vw== X-Google-Smtp-Source: ABdhPJylmeP8wss6L0oPDLyVvWo3aSWug3u1XzG0rc5byOy54yXVj6/k66OZ9o6h8tdd+vhTW7vdJA== X-Received: by 2002:adf:fe05:: with SMTP id n5mr1079195wrr.9.1609875827242; Tue, 05 Jan 2021 11:43:47 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id s6sm151113wro.79.2021.01.05.11.43.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 11:43:46 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , "brian m . carlson" , Eric Sunshine , Johannes Schindelin , =?utf-8?q?SZEDER_G=C3=A1b?= =?utf-8?q?or?= , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v5 19/23] mktag: allow turning off fsck.extraHeaderEntry Date: Tue, 5 Jan 2021 20:42:48 +0100 Message-Id: <20210105194252.627-20-avarab@gmail.com> X-Mailer: git-send-email 2.29.2.222.g5d2a92d10f8 In-Reply-To: <20201223013606.7972-1-avarab@gmail.com> References: <20201223013606.7972-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org In earlier commits mktag learned to use the fsck machinery, at which point we needed to add fsck.extraHeaderEntry so it could be as strict about extra headers as it's been ever since it was implemented. But it's not nice to need to switch away from "mktag" to "hash-object" + manual "fsck" just because you'd like to have an extra header. So let's support turning it off by getting "fsck.*" variables from the config. Pedantically speaking it's still not possible to make "mktag" behave just like "hash-object -t tag" does, since we're unconditionally going to check the referenced object in verify_object_in_tag(), which is our own check, and not one that exists in fsck.c. But the spirit of "this works like fsck" is preserved, in that if you created such a tag with "hash-object" and did a full "fsck" on the repository it would also error out about that invalid object, it just wouldn't emit the same message as fsck does. Signed-off-by: Ævar Arnfjörð Bjarmason --- Documentation/git-mktag.txt | 5 ++++- builtin/mktag.c | 11 ++++++++++- t/t3800-mktag.sh | 14 ++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/Documentation/git-mktag.txt b/Documentation/git-mktag.txt index fa070e21a0b..79813ff8df0 100644 --- a/Documentation/git-mktag.txt +++ b/Documentation/git-mktag.txt @@ -32,7 +32,10 @@ would run by default in that all `fsck.` messages are promoted from warnings to errors (so e.g. a missing "tagger" line is an error). Extra headers in the object are also an error under mktag, but ignored -by linkgit:git-fsck[1] +by linkgit:git-fsck[1]. This extra check can be turned off by setting +the appropriate `fsck.` varible: + + git -c fsck.extraHeaderEntry=ignore mktag err && + grep "warning .*extraHeaderEntry:" err && + test_must_fail env GIT_TEST_GETTEXT_POISON=false \ + git -c fsck.extraHeaderEntry=error 2>err fsck && + grep "error .* extraHeaderEntry:" err +' + cat >tag.sig < X-Patchwork-Id: 12000297 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BD9CFC43331 for ; Tue, 5 Jan 2021 19:45:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A7D3C22D5A for ; Tue, 5 Jan 2021 19:45:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730990AbhAETpb (ORCPT ); Tue, 5 Jan 2021 14:45:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730943AbhAETpa (ORCPT ); Tue, 5 Jan 2021 14:45:30 -0500 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C43FC0617B9 for ; Tue, 5 Jan 2021 11:43:50 -0800 (PST) Received: by mail-wm1-x32f.google.com with SMTP id c133so587706wme.4 for ; Tue, 05 Jan 2021 11:43:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dZPPyLUhLb4dEp71bYMU5YEk5p1+ypy+0G9pkGPzcio=; b=DAzKG+Cos2h9uX9VTBOS7AA4d413lpe8ovgMFlDbV7Pk4yBbbPVwHi5tHn/jKpT5Wq PV8yI/XYeHgZVvlKFvHN7brdpjbnTg/GfBt1arEJGyxwaP/+76dTp0unf63LM2OWG51t z+19xAhrlytkp9CGl5v2K55WstOXbOVYP5dF4saNuY1p5tsoIHeV3unAZ1UGxx/m/+p4 yNziwN9XZVTL2wFwzsRWS9q8JEilEdM2B/i5xzjjpZIGR4FM9ln9fZ9WS4EwSqYzNqJN b6fmCM9i9iGOG89mNQxfhxQ/Cg1/+6oXdjLcXJNozNmTc77DzGMwyIREi/qFQbjHnpBf sM9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dZPPyLUhLb4dEp71bYMU5YEk5p1+ypy+0G9pkGPzcio=; b=Sxgr405YA7/1RnKIK2bCmTRFXPF2ZkmoZd6EtGkH8B3myES8FbWC5txbbpRttbONO1 Gpa7NNPdl5LUIhRgcBDpX4w+xGEhLTpsdwUlPKjbAgx4V0qulejdK66t/d4J7BJef5R8 +aiUMvfA4vaqqhCPJwOVnaAiAI243GFgOaP3e2+NP0SUzBdqzaAezUAhIWZHdcWE8Vuc dEdO+ekISNzZPjMvmBJNeT8FEWGKUtvRKD35+MBgzBD7GzcnVR1USr1ykwDB7uAsAJix QRuzIq9emr6hGJm35S0ol6z8ZTgei98UieYvcjiftJCzgHfWlidF2tcCnFw5i1kLcXRz DBvw== X-Gm-Message-State: AOAM533Sglnkq6F1TzUmi3QAjbDRCZCc5YZp3GUyMgW7PSCQlKg7tHLu 7qYyXfW7OtRTAnJzG3qcCFMOL0QJnAWEuA== X-Google-Smtp-Source: ABdhPJxc77HaW1ey9Cgf+5NuxcBKwAl/1zlwOtoDLmOJVtEoi6al5WknXj+6YVFCVR5DzhJ3hlkrTg== X-Received: by 2002:a1c:e3c4:: with SMTP id a187mr645624wmh.58.1609875828543; Tue, 05 Jan 2021 11:43:48 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id s6sm151113wro.79.2021.01.05.11.43.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 11:43:47 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , "brian m . carlson" , Eric Sunshine , Johannes Schindelin , =?utf-8?q?SZEDER_G=C3=A1b?= =?utf-8?q?or?= , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v5 20/23] mktag: allow omitting the header/body \n separator Date: Tue, 5 Jan 2021 20:42:49 +0100 Message-Id: <20210105194252.627-21-avarab@gmail.com> X-Mailer: git-send-email 2.29.2.222.g5d2a92d10f8 In-Reply-To: <20201223013606.7972-1-avarab@gmail.com> References: <20201223013606.7972-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Change mktag's acceptance rules to accept an empty body without an empty line after the header again. This fixes an ancient unintended dregression in "mktag". When "mktag" was introduced in ec4465adb3 (Add "tag" objects that can be used to sign other objects., 2005-04-25) the input checks were much looser. When it was documented it 6cfec03680 (mktag: minimally update the description., 2007-06-10) it was clearly intended for this \n to be optional: The message, when [it] exists, is separated by a blank line from the header. But then in e0aaf781f6 (mktag.c: improve verification of tagger field and tests, 2008-03-27) this was made an error, seemingly by accident. It was just a result of the general header checks, and all the tests after that patch have a trailing empty line (but did not before). Let's allow this again, and tweak the test semantics changed in e0aaf781f6 to remove the redundant empty line. New tests added in previous commits of mine already added an explicit test for allowing the empty line between header and body. Signed-off-by: Ævar Arnfjörð Bjarmason --- fsck.c | 2 ++ t/t3800-mktag.sh | 6 ++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fsck.c b/fsck.c index 9067a290a2e..29c1eaca4cf 100644 --- a/fsck.c +++ b/fsck.c @@ -987,6 +987,8 @@ int fsck_tag_standalone(const struct object_id *oid, const char *buffer, } else ret = fsck_ident(&buffer, oid, OBJ_TAG, options); + if (!*buffer) + goto done; if (!starts_with(buffer, "\n")) { /* diff --git a/t/t3800-mktag.sh b/t/t3800-mktag.sh index dccf4503235..601b064e97a 100755 --- a/t/t3800-mktag.sh +++ b/t/t3800-mktag.sh @@ -446,7 +446,7 @@ tagger T A Gger 1206478233 -0500 EOF -test_expect_mktag_success 'require a blank line before an empty body (1)' +test_expect_mktag_success 'allow a blank line before an empty body (1)' cat >tag.sig < 1206478233 -0500 EOF -check_verify_failure 'require a blank line before an empty body (2)' \ - '^error:.* extraHeaderEntry:' +test_expect_mktag_success 'allow no blank line before an empty body (2)' ############################################################ # 24. create valid tag @@ -466,7 +465,6 @@ object $head type commit tag mytag tagger T A Gger 1206478233 -0500 - EOF test_expect_mktag_success 'create valid tag object' From patchwork Tue Jan 5 19:42:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12000289 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 671A6C433E6 for ; Tue, 5 Jan 2021 19:45:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3F22822D6F for ; Tue, 5 Jan 2021 19:45:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730971AbhAETpI (ORCPT ); Tue, 5 Jan 2021 14:45:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730966AbhAETpG (ORCPT ); Tue, 5 Jan 2021 14:45:06 -0500 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06162C0617BA for ; Tue, 5 Jan 2021 11:43:51 -0800 (PST) Received: by mail-wm1-x336.google.com with SMTP id q75so630529wme.2 for ; Tue, 05 Jan 2021 11:43:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FZAM0KXjAA17LKrIbopXlrJ6gpa4ing+EDYZdBFBToM=; b=pA2Iv/7YKgXSaLZop9RS3aYM7rnjdzR5YnaTYa7Hlwknl29nbZMbOCcqbTBrbSrTo8 mIqWBdKttBzuXB3qZJ+0nlxSXjyCfxYcu/o3xEbp339pLDamb5AtTn6ANs1/4UELF3k5 QIwwt+ZSuhnOsMtmAcSkhIzG479aGIr1V9n/4hmY3H1kR561iAthlBlFFZfUY4ADk8jx DDnp9qetkTqvjqUmHebyP0q+15/Y88O8ZHJlufHwTit/sJFCrBWh4RoL0Luu6vft79oU FLu6LoMXno+dzdMVonAv73SYw/O06P4f14+2aQpnPia8bApqO0CAf+dmf0QAUnZ+1qbj j6ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FZAM0KXjAA17LKrIbopXlrJ6gpa4ing+EDYZdBFBToM=; b=qqbdNj1zaeQ1e6i/DFeMIkCC4tfS76HQsAL1t79eKWc7crAgEpDjGeSKKbCfL6v/gQ lpBHF9evSKy+lgTfebRLTi4t5u90V6Wsgxqgg2jqJ7Gc4Q+KOlR5thHavKJ4rug/pJzC qmN0DeLSVh66quqVnAEjEggKtWvo1+AEUg6pxFLLZmy8bovu1ipnZE+ojhPHQcMccEPJ vfsjB8EUe2jZx84OrluGlO67U9YLuhFAoHTUZSBVeJl1C7xnz5hl/S58wQJUEeCN/rR5 HezEHhjroMA+rG7pKixsNBu3hv9TUFLYFnp9wT+Uyauh0VthyR1Fjcfs+V+Re6bJ9sIp 9Gqw== X-Gm-Message-State: AOAM530VkUqbVrnMKNsj7/9Vbls+vrRXi3a74gQtvbAHRQt5wC+H8W8f NHW9sDNT49YiIhV6UHq16TYa6X9U2jVwhQ== X-Google-Smtp-Source: ABdhPJy1obOzVJGdxUKymREzOS+vE6as0MI98MvCY+vr1lkfXlG8bSol2Bnw5k0lINzU+0RQ8bUz1g== X-Received: by 2002:a1c:3b02:: with SMTP id i2mr583086wma.141.1609875829496; Tue, 05 Jan 2021 11:43:49 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id s6sm151113wro.79.2021.01.05.11.43.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 11:43:48 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , "brian m . carlson" , Eric Sunshine , Johannes Schindelin , =?utf-8?q?SZEDER_G=C3=A1b?= =?utf-8?q?or?= , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v5 21/23] mktag: convert to parse-options Date: Tue, 5 Jan 2021 20:42:50 +0100 Message-Id: <20210105194252.627-22-avarab@gmail.com> X-Mailer: git-send-email 2.29.2.222.g5d2a92d10f8 In-Reply-To: <20201223013606.7972-1-avarab@gmail.com> References: <20201223013606.7972-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Convert the "mktag" command to use parse-options.h instead of its own ad-hoc argc handling. This doesn't matter much in practice since it doesn't support any options, but removes another special-case in our codebase, and makes it easier to add options to it in the future. It does marginally improve the situation for programs that want to execute git commands in a consistent manner and e.g. always use --end-of-options. E.g. "gitaly" does that, and has a blacklist of built-ins that don't support --end-of-options. This is one less special case for it and other similar programs to support. Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/mktag.c | 14 ++++++++++++-- t/t3800-mktag.sh | 12 ++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/builtin/mktag.c b/builtin/mktag.c index 373926d7e0c..18b8492f4d4 100644 --- a/builtin/mktag.c +++ b/builtin/mktag.c @@ -1,10 +1,16 @@ #include "builtin.h" +#include "parse-options.h" #include "tag.h" #include "replace-object.h" #include "object-store.h" #include "fsck.h" #include "config.h" +static char const * const builtin_mktag_usage[] = { + N_("git mktag"), + NULL +}; + static struct fsck_options fsck_options = FSCK_OPTIONS_STRICT; static int mktag_config(const char *var, const char *value, void *cb) @@ -60,13 +66,17 @@ static int verify_object_in_tag(struct object_id *tagged_oid, int *tagged_type) int cmd_mktag(int argc, const char **argv, const char *prefix) { + static struct option builtin_mktag_options[] = { + OPT_END(), + }; struct strbuf buf = STRBUF_INIT; struct object_id tagged_oid; int tagged_type; struct object_id result; - if (argc != 1) - usage("git mktag"); + argc = parse_options(argc, argv, NULL, + builtin_mktag_options, + builtin_mktag_usage, 0); if (strbuf_read(&buf, 0, 0) < 0) die_errno("could not read from stdin"); diff --git a/t/t3800-mktag.sh b/t/t3800-mktag.sh index 601b064e97a..0ddd0f01cc7 100755 --- a/t/t3800-mktag.sh +++ b/t/t3800-mktag.sh @@ -45,6 +45,18 @@ test_expect_success 'setup' ' blob=$(git rev-parse --verify HEAD:B.t) ' +test_expect_success 'basic usage' ' + cat >tag.sig <<-EOF && + object $head + type commit + tag mytag + tagger T A Gger 1206478233 -0500 + EOF + git mktag X-Patchwork-Id: 12000295 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4585C4332E for ; Tue, 5 Jan 2021 19:45:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BD60F22D72 for ; Tue, 5 Jan 2021 19:45:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730994AbhAETpd (ORCPT ); Tue, 5 Jan 2021 14:45:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730989AbhAETpb (ORCPT ); Tue, 5 Jan 2021 14:45:31 -0500 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C0BDC0617BB for ; Tue, 5 Jan 2021 11:43:52 -0800 (PST) Received: by mail-wm1-x32b.google.com with SMTP id q75so630559wme.2 for ; Tue, 05 Jan 2021 11:43:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WuEfYMYzgANieS8+MDhbaNf0sYlKqmE2/d3/ONfyi0M=; b=DUJlVr3EgqBeVpz8oyPj2GY76HpIxuWXwlkKsnjhkQzcrWy6iYLb0KG2Wz12ICPTRD i/l/M7okHh+jbCJE92Saox4aDTrNPZJyJwQvkVyBr1W0wv/AlqETcyqxln9pqIr/hWXY HaGF0dVQwA5dBL/oP4Dq/M75J+IGzY/x5pi9wRVOFPDUOl2HBXXDE4zG7S1Slno2TZa2 gwN+RQcx8/npbp5t7wbSmKZ5OdmXLbv/rmWRj0UcRN4wof7kzlPtMMjQtAezz/NwMJyP cDjxrIq9bMsEeRqVzGf9Nfq82UZ+odK5pnj9cZ/aTK+dwHckKzdHyGvwUMce0wco8Tu+ oVSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WuEfYMYzgANieS8+MDhbaNf0sYlKqmE2/d3/ONfyi0M=; b=qyT3e3L+SVgz0L/OjAJzKKzLPZ+nG52+5e2Qo7oBC1NM1BWHKYHgDsYVefBVcc8f5Y UxbgkrAH39DwzC6BUm3V6K4mGTiIEbXuBVeRm4EH1WbkQO+WMPs288aGHcd4vfqSyMsr LNnHLFsTvrDOoWgvCJE66yPAtOmnYM2Sj0hDLW4OCPOiIuNERbaF9VuSRk+36U2hrrfE bXZF8IxW+QkaZxZYQKCC9gDkD+i6+VR6TKnH/TEYKVhbPrpE8t/LONXZ9dKRZfGvjvwF jopBwZ/6DEY+iqeYWHEoI6PLHdju7fzIzAAe+YCR1p6/4RmR2/AtTMFAxVGaxVCShgr1 9bAg== X-Gm-Message-State: AOAM5323/tDmBQEQZ8XQgkJtkyaJ60crqRCn7uTBwaeDDb8I165sun3S jLPyyi0ksn90xJZ8kXeU+xTeK/rdwbVQ2Q== X-Google-Smtp-Source: ABdhPJzV8Un3ZyxWCuLXu7/B7cyl2P8cvPkewtRzPjsbHe9ExI+3hFw+ZXoyo2E6IDG/N1gRS1JXvw== X-Received: by 2002:a05:600c:2903:: with SMTP id i3mr608947wmd.41.1609875830535; Tue, 05 Jan 2021 11:43:50 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id s6sm151113wro.79.2021.01.05.11.43.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 11:43:49 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , "brian m . carlson" , Eric Sunshine , Johannes Schindelin , =?utf-8?q?SZEDER_G=C3=A1b?= =?utf-8?q?or?= , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v5 22/23] mktag: mark strings for translation Date: Tue, 5 Jan 2021 20:42:51 +0100 Message-Id: <20210105194252.627-23-avarab@gmail.com> X-Mailer: git-send-email 2.29.2.222.g5d2a92d10f8 In-Reply-To: <20201223013606.7972-1-avarab@gmail.com> References: <20201223013606.7972-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Mark the errors mktag might emit for translation. This is a plumbing command, but the errors it emits are intended to be human-readable. Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/mktag.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/builtin/mktag.c b/builtin/mktag.c index 18b8492f4d4..9b04b61c2bb 100644 --- a/builtin/mktag.c +++ b/builtin/mktag.c @@ -31,10 +31,10 @@ static int mktag_fsck_error_func(struct fsck_options *o, * like missing "tagger" lines are "only" warnings * under fsck, we've always considered them an error. */ - fprintf_ln(stderr, "error: tag input does not pass fsck: %s", message); + fprintf_ln(stderr, _("error: tag input does not pass fsck: %s"), message); return 1; default: - BUG("%d (FSCK_IGNORE?) should never trigger this callback", + BUG(_("%d (FSCK_IGNORE?) should never trigger this callback"), msg_type); } } @@ -49,10 +49,10 @@ static int verify_object_in_tag(struct object_id *tagged_oid, int *tagged_type) buffer = read_object_file(tagged_oid, &type, &size); if (!buffer) - die("could not read tagged object '%s'", + die(_("could not read tagged object '%s'"), oid_to_hex(tagged_oid)); if (type != *tagged_type) - die("object '%s' tagged as '%s', but is a '%s' type", + die(_("object '%s' tagged as '%s', but is a '%s' type"), oid_to_hex(tagged_oid), type_name(*tagged_type), type_name(type)); @@ -79,7 +79,7 @@ int cmd_mktag(int argc, const char **argv, const char *prefix) builtin_mktag_usage, 0); if (strbuf_read(&buf, 0, 0) < 0) - die_errno("could not read from stdin"); + die_errno(_("could not read from stdin")); fsck_options.error_func = mktag_fsck_error_func; fsck_set_msg_type(&fsck_options, "extraheaderentry", "warn"); @@ -87,13 +87,13 @@ int cmd_mktag(int argc, const char **argv, const char *prefix) git_config(mktag_config, NULL); if (fsck_tag_standalone(NULL, buf.buf, buf.len, &fsck_options, &tagged_oid, &tagged_type)) - die("tag on stdin did not pass our strict fsck check"); + die(_("tag on stdin did not pass our strict fsck check")); if (verify_object_in_tag(&tagged_oid, &tagged_type)) - die("tag on stdin did not refer to a valid object"); + die(_("tag on stdin did not refer to a valid object")); if (write_object_file(buf.buf, buf.len, tag_type, &result) < 0) - die("unable to write tag file"); + die(_("unable to write tag file")); strbuf_release(&buf); puts(oid_to_hex(&result)); From patchwork Tue Jan 5 19:42:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12000293 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 76943C43381 for ; Tue, 5 Jan 2021 19:45:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5F10422D5A for ; Tue, 5 Jan 2021 19:45:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730975AbhAETpJ (ORCPT ); Tue, 5 Jan 2021 14:45:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730977AbhAETpJ (ORCPT ); Tue, 5 Jan 2021 14:45:09 -0500 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06F89C0617BC for ; Tue, 5 Jan 2021 11:43:53 -0800 (PST) Received: by mail-wr1-x436.google.com with SMTP id t30so376707wrb.0 for ; Tue, 05 Jan 2021 11:43:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=C9zO8W7ov/B2Omd/+XOSb1HaK2iItwuXV7V8QHTw3ZE=; b=Z2OHJgF3D+XWiWXXk1qWfFwXoO8OdOrhv7mRXDxknhip0WMN/QYB2+t97RMRlPvvq3 P0YDw1R8K8pmJCjvAeq8hwiqbpyeYb0Ix2Zo27nL61+bRXKPLbI4yi/NEnrFPhxKv0E5 hJVVVvcN9txAUiZXZ6Vz9d7pVb/zWuhrE58RxrUyaFqHcromaqPVQ34rYu4O+ya4X1el 5AQJMQFnkt4PK8yScAMPft7TgQnQwgUdBUxYRXXEr7oFmm37h+xo02BoaJE8p9guIrWs Ak2ijStondiWCL8MxOTDrCvisHepcMRiu820qVQDmWkeEIMMtRiktykNoXQqBk7t2Cwi K7Uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=C9zO8W7ov/B2Omd/+XOSb1HaK2iItwuXV7V8QHTw3ZE=; b=oyp+UpbaZHiaJxqlTXyct6X0egoSLppuGsAgCIyio4Gmi1fdtZhMq/YwYD5m8thBWo ka2+omWseWgNCsp7XQbCMqbfPFlwgXGqH06Tm0NdiPcpnmi7ue7x3J+vvszi0zA7pcJK Ugx7J7OmXSsDFQonwBzp99WLBkygNJSwFK7bQF4xqev3+y3A9YGWNGo7VG6ygeY8ZAeW nNrR2bvfhIU4aw4DCpFJPtLs8ukb5c86V8bQw6Wl7rbIEt7iKjy+htiEL0fP4/SO29TQ eHugk7zre9tzEhJkLhx29gb6GfkV9xnOPaxerThoRm6L85kxWQelNi+jAAb7uDNLuR7Q rO0w== X-Gm-Message-State: AOAM531b4tUGF7UiyDKASB3eGjkruwDae/9WXAqBvIIzFL964tvPdhfN ghC6W29/r5O4UL93umRUcj0zAMIUrmgwaQ== X-Google-Smtp-Source: ABdhPJxOte+48xrRcIoEQ1k4dvakJ8KI4FfdpDWf3kabCM2x+pcsX/FOYCLilOti/5ZdFj7vl1ibIQ== X-Received: by 2002:a5d:4dcd:: with SMTP id f13mr1095675wru.10.1609875831488; Tue, 05 Jan 2021 11:43:51 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id s6sm151113wro.79.2021.01.05.11.43.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 11:43:50 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , "brian m . carlson" , Eric Sunshine , Johannes Schindelin , =?utf-8?q?SZEDER_G=C3=A1b?= =?utf-8?q?or?= , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v5 23/23] mktag: add a --no-strict option Date: Tue, 5 Jan 2021 20:42:52 +0100 Message-Id: <20210105194252.627-24-avarab@gmail.com> X-Mailer: git-send-email 2.29.2.222.g5d2a92d10f8 In-Reply-To: <20201223013606.7972-1-avarab@gmail.com> References: <20201223013606.7972-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Now that mktag has been migrated to use the fsck machinery to check its input, it makes sense to teach it to run in the equivalent of "git fsck"'s default mode, instead of hardcoding "git fsck --strict". Let's do that and support the "--no-strict" option. Since this is a new option we don't need to cater to parse-option.c's default of automatically supporting --strict. So let's use PARSE_OPT_NONEG, using a new trivial helper macro. Signed-off-by: Ævar Arnfjörð Bjarmason --- Documentation/git-mktag.txt | 8 ++++++++ builtin/mktag.c | 9 +++++++++ t/t3800-mktag.sh | 33 +++++++++++++++++++++++---------- 3 files changed, 40 insertions(+), 10 deletions(-) diff --git a/Documentation/git-mktag.txt b/Documentation/git-mktag.txt index 79813ff8df0..17a2603a600 100644 --- a/Documentation/git-mktag.txt +++ b/Documentation/git-mktag.txt @@ -11,6 +11,14 @@ SYNOPSIS [verse] 'git mktag' +OPTIONS +------- + +--strict:: + By default mktag turns on the equivalent of + linkgit:git-fsck[1] `--strict` mode. Use `--no-strict` to + disable it. + DESCRIPTION ----------- diff --git a/builtin/mktag.c b/builtin/mktag.c index 9b04b61c2bb..41a399a69e4 100644 --- a/builtin/mktag.c +++ b/builtin/mktag.c @@ -10,6 +10,7 @@ static char const * const builtin_mktag_usage[] = { N_("git mktag"), NULL }; +static int option_strict = 1; static struct fsck_options fsck_options = FSCK_OPTIONS_STRICT; @@ -25,6 +26,12 @@ static int mktag_fsck_error_func(struct fsck_options *o, { switch (msg_type) { case FSCK_WARN: + if (!option_strict) { + fprintf_ln(stderr, _("warning: tag input does not pass fsck: %s"), message); + return 0; + + } + /* fallthrough */ case FSCK_ERROR: /* * We treat both warnings and errors as errors, things @@ -67,6 +74,8 @@ static int verify_object_in_tag(struct object_id *tagged_oid, int *tagged_type) int cmd_mktag(int argc, const char **argv, const char *prefix) { static struct option builtin_mktag_options[] = { + OPT_BOOL(0, "strict", &option_strict, + N_("enable more strict checking")), OPT_END(), }; struct strbuf buf = STRBUF_INIT; diff --git a/t/t3800-mktag.sh b/t/t3800-mktag.sh index 0ddd0f01cc7..4d76ccbbc19 100755 --- a/t/t3800-mktag.sh +++ b/t/t3800-mktag.sh @@ -12,12 +12,17 @@ test_description='git mktag: tag object verify test' # given in the expect.pat file. check_verify_failure () { - expect="$2" - test_expect_success "$1" ' + test_expect_success "$1" " test_must_fail env GIT_TEST_GETTEXT_POISON=false \ git mktag message && - grep "$expect" message - ' + grep '$2' message && + if test '$3' != '--no-strict' + then + test_must_fail env GIT_TEST_GETTEXT_POISON=false \ + git mktag --no-strict message.no-strict && + grep '$2' message.no-strict + fi + " } test_expect_mktag_success() { @@ -65,7 +70,7 @@ too short for a tag EOF check_verify_failure 'Tag object length check' \ - '^error:.* missingObject:' + '^error:.* missingObject:' 'strict' ############################################################ # 2. object line label check @@ -240,7 +245,7 @@ tagger . <> 0 +0000 EOF check_verify_failure 'verify tag-name check' \ - '^error:.* badTagName:' + '^error:.* badTagName:' '--no-strict' ############################################################ # 11. tagger line label check #1 @@ -254,7 +259,7 @@ This is filler EOF check_verify_failure '"tagger" line label check #1' \ - '^error:.* missingTaggerEntry:' + '^error:.* missingTaggerEntry:' '--no-strict' ############################################################ # 12. tagger line label check #2 @@ -269,7 +274,7 @@ This is filler EOF check_verify_failure '"tagger" line label check #2' \ - '^error:.* missingTaggerEntry:' + '^error:.* missingTaggerEntry:' '--no-strict' ############################################################ # 13. allow missing tag author name like fsck @@ -298,7 +303,7 @@ tagger T A Gger < EOF check_verify_failure 'disallow malformed tagger' \ - '^error:.* badEmail:' + '^error:.* badEmail:' '--no-strict' ############################################################ # 15. allow empty tag email @@ -422,13 +427,21 @@ this line should not be here EOF check_verify_failure 'detect invalid header entry' \ - '^error:.* extraHeaderEntry:' + '^error:.* extraHeaderEntry:' '--no-strict' test_expect_success 'invalid header entry config & fsck' ' test_must_fail git mktag err &&