From patchwork Thu Nov 26 01:28:43 2020 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: 11932431 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 7BB6CC56201 for ; Thu, 26 Nov 2020 01:29:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 12473216C4 for ; Thu, 26 Nov 2020 01:29:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kFcb4j8x" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731643AbgKZB3D (ORCPT ); Wed, 25 Nov 2020 20:29:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730060AbgKZB3D (ORCPT ); Wed, 25 Nov 2020 20:29:03 -0500 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E682C061A55 for ; Wed, 25 Nov 2020 17:29:01 -0800 (PST) Received: by mail-wr1-x444.google.com with SMTP id l1so329964wrb.9 for ; Wed, 25 Nov 2020 17:29:01 -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=nrf1B/mjDuKVtAiooF3Zhliy60HVigqM1yyq2cZrlwo=; b=kFcb4j8xMf8gF8bBGKA9zSpBXC+q92Yxo/NLGhAQU1Vebn/z3mHh2ZWxij8gPKX+S+ d5F5lz0Kym1v7h1/DkPW+sHYt7sxukcyva1vfsx5ecovp/CmIZZzsNOroEIryb4BEczj jr051l3gqGbq9MSEVcR/gnF9mJKL7XgWD6btmsR/MNvHcUfnoH/xz+JedriD1lWydG23 L+qxKqZ8SOUvOBj5NB8iP0rocVBLihv5Qwj22TU5hEVH+K36LM3ynvgIuMmJ7pW5JE5R dslLICmy3IF2zsMTiohP1uBTsyoZIwk5Xig9wi9ceAr8qqePYNcDMN0sdpPqfBjbpcN8 zKxg== 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=nrf1B/mjDuKVtAiooF3Zhliy60HVigqM1yyq2cZrlwo=; b=shISa2+Ygro7cmiQIlBZxLpno568rztd18H8tReLFWamiWFji4PwmgOHL59DaNIDIq WS2mdbsGTmRlpQrs8PJck4gKnZavyNkdTcjfiEzvL3xv6dPk6YAwEnug5vx1kD2X9jw2 PBf9pcyctkP3XDz0fKJnkRpVUOvKwiHHN6BSTubwMM+V0rjP2/i4waf3S8TOxZjrYG8x 7DmS6/qRijD12cDA0YhQJdiNCuNw7eAfat63k0aAviQ9AShElQL2YK77hMHxyrpOv5tj C0QW+8hBHE3MuTwps3lvTv7pcMVAdbsIbUA6svGjV5V6chnC7dargk0YGkQIse7/YtHp D21g== X-Gm-Message-State: AOAM5303+ngUubnin0CDCZ1TPMP682b7+b4qdEzPhxjRfL71pPVmG+Y7 0myv+Qk0AN+Zf62qxJO6gltXLi7jKQ1tig== X-Google-Smtp-Source: ABdhPJxV5ZyaaOO7bAFcPcXRErHJcOSwz8kzGw9A3yhrLuHRicP8HKSC8wSnWbHaM+vs9i5G98Gc/g== X-Received: by 2002:a5d:474b:: with SMTP id o11mr715812wrs.235.1606354139974; Wed, 25 Nov 2020 17:28:59 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id q12sm6402523wmc.45.2020.11.25.17.28.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Nov 2020 17:28:59 -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?b?w4Z2YXIgQXJu?= =?utf-8?b?ZmrDtnLDsCBCamFybWFzb24=?= Subject: [RFC/PATCH 01/12] mktag: use default strbuf_read() hint Date: Thu, 26 Nov 2020 02:28:43 +0100 Message-Id: <20201126012854.399-2-avarab@gmail.com> X-Mailer: git-send-email 2.29.2.222.g5d2a92d10f8 In-Reply-To: References: 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 4982d3a93e..ff7ac8e0e5 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 Thu Nov 26 01:28:44 2020 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: 11932437 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 B884AC63798 for ; Thu, 26 Nov 2020 01:29:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 536CF21534 for ; Thu, 26 Nov 2020 01:29:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="klu1faWJ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731675AbgKZB3E (ORCPT ); Wed, 25 Nov 2020 20:29:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730060AbgKZB3D (ORCPT ); Wed, 25 Nov 2020 20:29: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 5DCA6C061A55 for ; Wed, 25 Nov 2020 17:29:03 -0800 (PST) Received: by mail-wm1-x334.google.com with SMTP id a65so561285wme.1 for ; Wed, 25 Nov 2020 17:29:03 -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=0+Oer4GSRchoXVNYtlL5I1oxz4Ket+on6CG5jj0l5gg=; b=klu1faWJaj60BWzwksk5Yl1SCnoRQYUwdWSennGDWBGUfiu5q7HuH8cOs44JHUlw73 ipxzOZ5mtF+9Uex9x1nqM/tNwZ9oTVUMuJ89ZP3ycmU6ZAuP1ZWDxfJ00Ad13f0RpbZ3 vPSyDwbeDVz5oRxfW+IHKNFaKgeR/jlrOIQYn6/aw5y8R0f39CMhE6mNJghDDubRDRsd yhK5xULDJx2gMw/vnQm6f3Du0qe+qy5Z6WkW/0pQXgIxVXEtHP6+QlVnG9j6iHBZt5Rg xOROJw1xINpU8AqJ+PCVzu3tlphUb33VEOCF9bz6UROfDyBMq+UlqJCLjJfqNR9CdEnB GvXQ== 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=0+Oer4GSRchoXVNYtlL5I1oxz4Ket+on6CG5jj0l5gg=; b=jxKia+jYPdUma/T+kDQWvDYeB3c7HXgad4BP8nCmQshwRbItkjZMsNquFHDBCfV008 GYP5OVay8j6yGXD9Q9M1uhXMKNAAne5sptbbULJH4in14ZIuPq93PPsKeGq2p+gApXkL yQZJxb0UAQqQy1H8U/hxBj2pisXNFAucss4oqC38q5q3oiot0qml70/tLgp0YdDv94ic xrWA7SzEPtvYlZDhN8pUcK3Gba9GP7BlhXbWlZQmcIA7FA8LZaDsfmpVpvxfM/10QQLA W8mUXRRNvxo73bznsJxuPBrpptu6K3e+T8GR9z7CCDTJm46OCQJxovJDa6gOnM61wiYb h9iA== X-Gm-Message-State: AOAM532FNwG0l8Bg7R74JBnJpUMYKVlCPkmcWybmzFA23XVNCidtp8HQ 5xEf0aiKRZXMy3LEgrao0OPfqQlxa27jTA== X-Google-Smtp-Source: ABdhPJz6Y0k4QPd9wNehiquukZkZbC4m+0Hr4joy6zsUFsvDcRQ4WMqK9lb8CeVXoDpsRVvLQ5SlMg== X-Received: by 2002:a1c:ded4:: with SMTP id v203mr443162wmg.93.1606354141907; Wed, 25 Nov 2020 17:29:01 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id q12sm6402523wmc.45.2020.11.25.17.29.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Nov 2020 17:29:01 -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?b?w4Z2YXIgQXJu?= =?utf-8?b?ZmrDtnLDsCBCamFybWFzb24=?= Subject: [RFC/PATCH 02/12] mktag: reword write_object_file() error Date: Thu, 26 Nov 2020 02:28:44 +0100 Message-Id: <20201126012854.399-3-avarab@gmail.com> X-Mailer: git-send-email 2.29.2.222.g5d2a92d10f8 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Change the error message emitted when write_object_file() fails to make more sense. At this point we're not writing a "tag file" (which as an aside we never do, we just write to stdout). We are writing an annotated tag object, let's say that instead. 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 ff7ac8e0e5..603b55aca0 100644 --- a/builtin/mktag.c +++ b/builtin/mktag.c @@ -171,7 +171,7 @@ int cmd_mktag(int argc, const char **argv, const char *prefix) die("invalid tag signature file"); if (write_object_file(buf.buf, buf.len, tag_type, &result) < 0) - die("unable to write tag file"); + die("unable to write annotated tag object"); strbuf_release(&buf); printf("%s\n", oid_to_hex(&result)); From patchwork Thu Nov 26 01:28:45 2020 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: 11932435 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 08E49C64E75 for ; Thu, 26 Nov 2020 01:29:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 894282168B for ; Thu, 26 Nov 2020 01:29:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="rK/oKdbr" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731698AbgKZB3F (ORCPT ); Wed, 25 Nov 2020 20:29:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730060AbgKZB3F (ORCPT ); Wed, 25 Nov 2020 20:29:05 -0500 Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2599C061A55 for ; Wed, 25 Nov 2020 17:29:04 -0800 (PST) Received: by mail-wm1-x344.google.com with SMTP id p22so486611wmg.3 for ; Wed, 25 Nov 2020 17:29:04 -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=e7DqChdgkDIOcmUV2R1ooVv5JMni3yZPaAeRb7uAV4k=; b=rK/oKdbrbshMbHXSCR5fFjg7ob9NNSnYAwVVhnmywbjYaR9ehWZoeBYDF/7sVlSpkF 3c/KytptYb8pL3M0C2h7BB6SEPADzuctzkUGVZlsCKkzC4EAqtVRXVG+BGavhiC+v4Ii VAJ+M/lq+9/p2ACwB+K9BeoK6s8ew7yZHgbc6vVWnDXwHefeF5PIEb8bD7tPjny4g5TK ywnb03Q2FlcUw9L1YwemDhjqK4IQd9cLDNQAUPy+lNS0MgyTCBJnXltASie3YXErCXAM 1Bngs3M6gwwYSVODqPcNEkDBLnTDFe0Ofhbm/Fk6pM7L6OWL9LL3JU6977qs3w8L2lQa qkyg== 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=e7DqChdgkDIOcmUV2R1ooVv5JMni3yZPaAeRb7uAV4k=; b=MeNh5oFsfPwp18YqPq5SZWjdZsoDwGdRH32KiNs56D0q9ITUPIfwNUNJwcmtql5DEg SjgNqj4dY8/DUPnrnD5PEVx5/b299qhHWydKHcYpWsK/mkRfN4YMNwbP+SFOaWCtUHYN NiwuZqRyTTmfIbO+kT2Ps8AmDxnzE3FBJgfyLMqBryBeWeGmhRiysQZpLePifrp9VuKT +/yvC/z4B/OFFAyoBVYakuUhnRt3YvHu3RUEL14RQkrr0dnkUHeqMPToEzRpuzvNv1fg 22quU6M/mvMvHXyF9Ux0kUC2O9qlTmEiTTufd0l6UeF++0bxeQ6W2L0oySLbRHGMTn6b fwEQ== X-Gm-Message-State: AOAM532AKALp2I83wevliBVgSX+DdYoYMDDEO1XrtvxcpumGk3p8sn8C ef3C3T9z88dYNvssbcpisUVJCkkQEKtsoA== X-Google-Smtp-Source: ABdhPJzCgFN29pJzXI4frPo5Ntr2PbRbZ6ynsKP8tdDT7kLN7m2dXvR2r5STiQndOC/DtH9H6k493g== X-Received: by 2002:a1c:e0c3:: with SMTP id x186mr494769wmg.64.1606354143428; Wed, 25 Nov 2020 17:29:03 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id q12sm6402523wmc.45.2020.11.25.17.29.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Nov 2020 17:29:02 -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?b?w4Z2YXIgQXJu?= =?utf-8?b?ZmrDtnLDsCBCamFybWFzb24=?= Subject: [RFC/PATCH 03/12] mktag: remove redundant braces in one-line body "if" Date: Thu, 26 Nov 2020 02:28:45 +0100 Message-Id: <20201126012854.399-4-avarab@gmail.com> X-Mailer: git-send-email 2.29.2.222.g5d2a92d10f8 In-Reply-To: References: 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 603b55aca0..dc354828f7 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 Thu Nov 26 01:28:46 2020 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: 11932441 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.7 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,URIBL_BLOCKED,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 29842C64E7A for ; Thu, 26 Nov 2020 01:29:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C545021534 for ; Thu, 26 Nov 2020 01:29:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="iPKrcMTg" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731719AbgKZB3G (ORCPT ); Wed, 25 Nov 2020 20:29:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730060AbgKZB3G (ORCPT ); Wed, 25 Nov 2020 20:29:06 -0500 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E7F5C061A55 for ; Wed, 25 Nov 2020 17:29:06 -0800 (PST) Received: by mail-wm1-x342.google.com with SMTP id w24so565430wmi.0 for ; Wed, 25 Nov 2020 17:29:06 -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=sgLR052BmWKstzCMaXV7x0thq6EyIOUZ/6tWgNnVfVE=; b=iPKrcMTgnvZVZcUpPHDtey9Q+I7ZpVouXAMF/xERaZt2lqYZyGdsxeYRdMd2vt6TLn AdBHpD5GehEHHlPWSiQdz19VqnQcgN871UqNHN4rZBZpAMRtb0jrMsB8pXtYfYrVW1vu /P8cjEnfW68nIUhXUIShw9XJL+6VsTQgbwL0ApAL83DWhR3PdpnFjloyI4daCLLGs2Rb iXb2PYM6o3pfFVPgFVWF5iclYfbzriGVJEud1MqcbkCs59XWRlt6qPYcPuKFHJlemuSI 8jUukj7QfCqhmxyWb9gmPCYwC8TSefX7oPW04WkYKIeoX34A72xnb0EbLyF6UqSr0IR7 0BDg== 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=sgLR052BmWKstzCMaXV7x0thq6EyIOUZ/6tWgNnVfVE=; b=CjMMIhSviKV49242O4CmoX2EJJA55c4YfGPfVF728U9QIV+AYU7z1OfmKspo8gNYI0 GsAG6eyOujxsFQm+INJoTIAWQQNSABzHmabDWq6zaPmfI/op+sB1Xm5e4gIHn9NbRDzq Qc5P5AAzLwaOZ4zBmnaLYKHK2bEzVVd6xlnn6IGteov0ySazgweVDP0BWOuFj+RcBmqu fwRMIcXYJZ/dQ51NGPLNJ2fMPCJk/U6Su9COox5g90JkqGOGpam2eVWsahDRYfyQJT9P 8r0wx+i4R4r//tp+bAYt6n+YNs6B1LsTAwH4mkkZqUpmONpN04orr1tE8lJMzX4V/z1Y UypQ== X-Gm-Message-State: AOAM533qX35vpRCmOnEUjG7tXL6uv8H1oYA84PDQ8i0Rkmxpjn89aS9T +CErJHv2AOvhs5mnz5JtxKUo8gWC0NjFaw== X-Google-Smtp-Source: ABdhPJwdNjPjk+wTdbzU1lbdaxyx2i3staBoU/GbLj2Uba2gEfABrblAZD8dVy0w/GM2RlWdXMAAEg== X-Received: by 2002:a1c:6787:: with SMTP id b129mr457438wmc.57.1606354144581; Wed, 25 Nov 2020 17:29:04 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id q12sm6402523wmc.45.2020.11.25.17.29.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Nov 2020 17:29:03 -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?b?w4Z2YXIgQXJu?= =?utf-8?b?ZmrDtnLDsCBCamFybWFzb24=?= Subject: [RFC/PATCH 04/12] mktag tests: don't needlessly use a subshell Date: Thu, 26 Nov 2020 02:28:46 +0100 Message-Id: <20201126012854.399-5-avarab@gmail.com> X-Mailer: git-send-email 2.29.2.222.g5d2a92d10f8 In-Reply-To: References: 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 d696aa4e52..0e411e3c45 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 Thu Nov 26 01:28:47 2020 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: 11932445 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.7 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,URIBL_BLOCKED,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 ACDE7C64E7C for ; Thu, 26 Nov 2020 01:29:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 540DF21534 for ; Thu, 26 Nov 2020 01:29:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WiYj9+4x" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731723AbgKZB3I (ORCPT ); Wed, 25 Nov 2020 20:29:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727062AbgKZB3I (ORCPT ); Wed, 25 Nov 2020 20:29:08 -0500 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0AF8AC061A55 for ; Wed, 25 Nov 2020 17:29:07 -0800 (PST) Received: by mail-wr1-x434.google.com with SMTP id g14so315555wrm.13 for ; Wed, 25 Nov 2020 17:29:06 -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=E+luWtVqvQqThJmgx7PmrY7Jrfbso4FN40N39n03yDU=; b=WiYj9+4xaayV+G5Dvvrw0+PzdEOXfiYLKaFNlopEy9IqWCxGKZg+ekrfsp4pbrKFc3 lir1TnBm3EvQhuH2CmIZ18obQb2ECGb6ixvxHazZgIKel0wDmRv24iB5dq601I+iT8LG gyClTVIvGQFVHnBTxkM6kXBLoIS2EzxueLNfo0iK2vX6IhOkN92Q0jBEi/VPv5Fb2tJi HB7yQ2nfA1pADjRdPXvBcCoVDhXasNzrgsoRokgSewpbiIGGQJAEhMzkxBVq4jgQKql4 6ClhsP/yXH5+KACEhW8W8k/rxvLVPoILXHdmxfR7msBcBVi55CckQMpQo0RJNueSahWT onOg== 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=E+luWtVqvQqThJmgx7PmrY7Jrfbso4FN40N39n03yDU=; b=SYYyT9CZVKdUJx9oql+Mj/1pbCPagXan4ayHwYgo1FeuR9SVNxOZOEhMf28FprnGC6 CbjbPrZLR4AcSPyMRnhXcJZxiLYpamBX9zXJnNHN/8SHmSHZoLdqDTBzh5xl6HNbkJ10 sXm52sQh0XazfRYuHKQIySD6Oh01XE1C91slVS531k82SSKWYWOpaeReW+95KcZPHNcU lfdGBbTkpVuSGNEQHAc1i9DQvweXMyMiz8IYdsBHE/qOilC6nok2yqDySVeu5l2+fpCt ZPur/XNTHO2pNyVrFfnDjgBzzAei052CI9ytvWYmQUKVUKam92NV2E11bUW50dFYFnKH xMJA== X-Gm-Message-State: AOAM531CBSKpLnEjt9y0cq6+4ouGIdNxj+IbWbqjHTtw2wtxf36lXFvj qgpkMPzlwajzUDjAwXuqf4tCsWiOJ5wgjg== X-Google-Smtp-Source: ABdhPJzdLuXynqD7Ak62uf2lg9Acolagl+GX041zRzEGRp3BnGZ9BwutjFLbjDClt9B61oZhq24kLQ== X-Received: by 2002:adf:e484:: with SMTP id i4mr717911wrm.398.1606354145554; Wed, 25 Nov 2020 17:29:05 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id q12sm6402523wmc.45.2020.11.25.17.29.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Nov 2020 17:29:04 -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?b?w4Z2YXIgQXJu?= =?utf-8?b?ZmrDtnLDsCBCamFybWFzb24=?= Subject: [RFC/PATCH 05/12] mktag tests: remove needless SHA-1 hardcoding Date: Thu, 26 Nov 2020 02:28:47 +0100 Message-Id: <20201126012854.399-6-avarab@gmail.com> X-Mailer: git-send-email 2.29.2.222.g5d2a92d10f8 In-Reply-To: References: 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 do 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. Let's just do that with a ROT13 invocation. We could get really unlucky and switch to a future hash function that just happens to produce all [0-9] output for this particular input, but that's very unlikely. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t3800-mktag.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/t/t3800-mktag.sh b/t/t3800-mktag.sh index 0e411e3c45..b5013af2aa 100755 --- a/t/t3800-mktag.sh +++ b/t/t3800-mktag.sh @@ -43,7 +43,7 @@ check_verify_failure 'Tag object length check' \ # 2. object line label check cat >tag.sig < 0 +0000 @@ -53,10 +53,11 @@ EOF check_verify_failure '"object" line label check' '^error: char0: .*"object "$' ############################################################ -# 3. object line SHA1 check +# 3. object line SHA check +invalid_sha=$(echo $head | tr A-Za-z N-ZA-Mn-za-m) cat >tag.sig < 0 +0000 From patchwork Thu Nov 26 01:28:48 2020 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: 11932439 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.7 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,URIBL_BLOCKED,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 81BA3C64E7B for ; Thu, 26 Nov 2020 01:29:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 16FA321734 for ; Thu, 26 Nov 2020 01:29:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="vheuS+52" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731727AbgKZB3J (ORCPT ); Wed, 25 Nov 2020 20:29:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726009AbgKZB3I (ORCPT ); Wed, 25 Nov 2020 20:29:08 -0500 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 250BCC061A52 for ; Wed, 25 Nov 2020 17:29:08 -0800 (PST) Received: by mail-wr1-x443.google.com with SMTP id k14so360950wrn.1 for ; Wed, 25 Nov 2020 17:29:08 -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=frXuVI0AIjBgEXytIBp3zbMeabIxHpPeNvuAp18QlY4=; b=vheuS+52ZHc1e18hos/AiLVoX/k3UAAOHqVEy9318sJNwp57DnthBOCsws0iM1Yaft wLYPN63pAYyyAAKe6C+jDNhgbg2Avo+wVaAlONt7X90R/eSPRgiaQfyR3O854Urc8Hcg WbUKt1ATn3SUl0rFWBNZOKK3qUkj9qpEx6Z8RSlk+RF9D6/lrDlZ9DkY512hcXId9VDm 5kUhZLoSbf9I7m8MRdWUPgUmgI8wZkiKujALBmnNbZwAxaz7xKwZum0ArQLsgaZvjfvV dKy3i/pHmxIVKZY19zVYPbZUw69ziT3Z0nUMq+1yUgI0TRy/P3qO1QAduh3DVp+2VWHK SQ8g== 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=frXuVI0AIjBgEXytIBp3zbMeabIxHpPeNvuAp18QlY4=; b=Ide+jVU3l6npjN6F7gXeO1cabkSdBmGLbTlJqp2Vfr53dZtzTWBZ70R1w6bd8dvt72 6BjJfzM3kyjpXnSv0McGEXLeORAcr+Fo8Ur9vPtUC6z7eZ1G7FiMQ+t2mkNwosvp4itF UbYp4umovwxs2klpPyq9madzqjfVgn81w8U/UgSYDli9nsGCDiLD8riBDruz3evqn5UO ISyk21olOWtJ/y6p0+7jn1WWbKAtC8TdZw30k4JqX2Y6111Rn81Z9D+1tsJL2km3VWD9 5wZDEU+CSOjnKxMSACIBlSIFji0Q5VZb6IbRZRQdrZu4l03VDdaajrPClC9yYQvtdEV/ SkzA== X-Gm-Message-State: AOAM5319pwswzkCtAdN3n78tIy6wsOcHditZWqA2HdHrf04HFJyU9s3K a/PK/uhG+CgBB42uIF11eghrY903022BQw== X-Google-Smtp-Source: ABdhPJyppah7MxrMH4UI0OhxRDLd1BLSQj2iDIQ0NdmZJOYNWA3LOA7XODBsQRd/99iBu088phbWKA== X-Received: by 2002:adf:ed51:: with SMTP id u17mr725690wro.61.1606354146676; Wed, 25 Nov 2020 17:29:06 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id q12sm6402523wmc.45.2020.11.25.17.29.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Nov 2020 17:29:06 -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?b?w4Z2YXIgQXJu?= =?utf-8?b?ZmrDtnLDsCBCamFybWFzb24=?= Subject: [RFC/PATCH 06/12] mktag tests: improve verify_object() test coverage Date: Thu, 26 Nov 2020 02:28:48 +0100 Message-Id: <20201126012854.399-7-avarab@gmail.com> X-Mailer: git-send-email 2.29.2.222.g5d2a92d10f8 In-Reply-To: References: 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"). Let's split these tests up, so we're testing all combinations of a non-existing object and in invalid "type" line. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t3800-mktag.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/t/t3800-mktag.sh b/t/t3800-mktag.sh index b5013af2aa..3801d3a285 100755 --- a/t/t3800-mktag.sh +++ b/t/t3800-mktag.sh @@ -128,6 +128,28 @@ check_verify_failure '"type" line type-name length check' \ ############################################################ # 9. verify object (SHA1/type) check +cat >tag.sig < 0 +0000 + +EOF + +check_verify_failure 'verify object (SHA1/type) check' \ + '^error: char7: could not verify object.*$' + +cat >tag.sig < 0 +0000 + +EOF + +check_verify_failure 'verify object (SHA1/type) check' \ + '^fatal: invalid object type' + cat >tag.sig < X-Patchwork-Id: 11932443 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 3A743C64E8A for ; Thu, 26 Nov 2020 01:29:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CAB802075A for ; Thu, 26 Nov 2020 01:29:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PdhzXhj5" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730762AbgKZB3L (ORCPT ); Wed, 25 Nov 2020 20:29:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726009AbgKZB3J (ORCPT ); Wed, 25 Nov 2020 20:29:09 -0500 Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2638EC061A52 for ; Wed, 25 Nov 2020 17:29:09 -0800 (PST) Received: by mail-wm1-x344.google.com with SMTP id d142so480249wmd.4 for ; Wed, 25 Nov 2020 17:29:09 -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=2jceSisEQ0O8uzujaoHHu5uF2kPINXx1cZjvV2eLizw=; b=PdhzXhj5qifScRYm34c075x1vj8bJlxbSHzAHnK7eFpsArGegAbhdIa91URk5v5139 f12TpMD4xApSVj7s+0Wu2Tl5IVM7RT1RCUgjQ8u3lzcAT3K6TarmWogTneGW18gwr/Vi k8xKhJ5Hizjinm2wIAPE20dvPAwNRppRZWdbXMTMPC638VwckLDlMCJzLypf5BDX/nyg wP7VrAGJVWxqjoTvO3tUjbjJjuX5FO3id2SkyxUAu4Yd+tZFBfRkHJduKFjxMKo/23HL ed0lR1GR9nNgOTECwoOd5BaqL8OiDEom6m8+w5V3sWIV13yuvSk86ywFnXpgZJsQJJzZ c6qg== 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=2jceSisEQ0O8uzujaoHHu5uF2kPINXx1cZjvV2eLizw=; b=m4Ll/oEEJKw5Zo9P0kUMNt1mYQ5LDJEBAXMaVT2nQAcl+hd8auuMjJtzMbeoB2h34C MyETiXVOJicow2Wcb4DYBL6sUeITXxxeA74PvSG+UD2HBjc1kTi6AoeoSolvnCDJqsh1 bXsT15L4PgQJjsZB6o1cjXk6thTwHZ2bmGozGoYa5NtSuUh5GZBbdm2ZZQfElceCpxIZ WCwBXkix2xuWu3TtujUbTqEhqb6LvFs0U3RTwIHFf/TMVbIACO30ssiv58fSY9eVywlT rQdEazBlaRHk+17CeMem2UCq7eIRKVLioWKYXiBixnmJO9tiOKyo8kDAwneXXV8PGNlt 4OWw== X-Gm-Message-State: AOAM533pjeBa7k1n3zGngVYZaYZ/7b/FXFZc7Va/cwZ8eVQ+F6dQaSVs Xi/JK3ipNMuCq+56og0MVTkLJfjXhzqIPw== X-Google-Smtp-Source: ABdhPJwZSZIFhcR2146QxkXAvPRPYLlZx/jkjzA5Uj1dwSXFCvwTeLAGz9rIgR4knyPFJcJPyKzUWA== X-Received: by 2002:a05:600c:2949:: with SMTP id n9mr454463wmd.29.1606354147618; Wed, 25 Nov 2020 17:29:07 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id q12sm6402523wmc.45.2020.11.25.17.29.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Nov 2020 17:29:06 -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?b?w4Z2YXIgQXJu?= =?utf-8?b?ZmrDtnLDsCBCamFybWFzb24=?= Subject: [RFC/PATCH 07/12] fsck: add new "extra" checks for "mktag" Date: Thu, 26 Nov 2020 02:28:49 +0100 Message-Id: <20201126012854.399-8-avarab@gmail.com> X-Mailer: git-send-email 2.29.2.222.g5d2a92d10f8 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Add optional "extra" checks to fsck, these are needed to eventually replace the custom not-quite-fsck code in mktag.c. The mktag checks differ from fsck_tag() in several ways, one of those is that fsck doesn't know how to refuse an object with custom headers, and isn't strict about header and body newline separation. Teach it how to optionally report these. I thought the best way to do that given the current structure of the code was to add a new "extra" category in addition to error/warn/info. 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. By adding an "extra" category and only reporting it based on a flag in fsck_options callers can opt-in to these "extra" messages, which they'll then need to deal with in their own "error_func". No tests are being added for this new functionality, they're added in a subsequent commit where we teach "mktag" to use this new validation mode. I'm not changing fsck_commit() to validate commit objects like this either, we could do that, but unlike in the tag case that code wouldn't be used anywhere. If someone wants to write a "mkcommit" they which behaves like "mktag" they can borrow or refactor this logic for use in fsck_commit(). Signed-off-by: Ævar Arnfjörð Bjarmason --- fsck.c | 32 +++++++++++++++++++++++++++++++- fsck.h | 2 ++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/fsck.c b/fsck.c index f82e2fe9e3..3c25df2244 100644 --- a/fsck.c +++ b/fsck.c @@ -80,7 +80,10 @@ 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) \ + /* extra (only reported when requested) */ \ + FUNC(EXTRA_HEADER_ENTRY, EXTRA) \ + FUNC(EXTRA_HEADER_BODY_NEWLINE, EXTRA) #define MSG_ID(id, msg_type) FSCK_MSG_##id, enum fsck_msg_id { @@ -975,6 +978,33 @@ static int fsck_tag(const struct object_id *oid, const char *buffer, else ret = fsck_ident(&buffer, oid, OBJ_TAG, options); + if (options->extra && *buffer) { + 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; + } + if (starts_with(buffer, "\n\n")) { + /* + * Some callers such as "mktag" want to + * disallow "[...]tagger + * \n\n\nmessage", only allowing a + * single newline for separation. + */ + ret = report(options, oid, OBJ_TAG, FSCK_MSG_EXTRA_HEADER_BODY_NEWLINE, "invalid format - headers separated body by more than one newline"); + if (ret) + goto done; + } + } + done: strbuf_release(&sb); return ret; diff --git a/fsck.h b/fsck.h index 69cf715e79..110efc65fd 100644 --- a/fsck.h +++ b/fsck.h @@ -6,6 +6,7 @@ #define FSCK_ERROR 1 #define FSCK_WARN 2 #define FSCK_IGNORE 3 +#define FSCK_EXTRA 4 struct fsck_options; struct object; @@ -40,6 +41,7 @@ struct fsck_options { unsigned strict:1; int *msg_type; struct oidset skiplist; + unsigned extra:1; kh_oid_map_t *object_names; }; From patchwork Thu Nov 26 01:28:50 2020 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: 11932453 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.7 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,URIBL_BLOCKED,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 DDC6DC64E7D for ; Thu, 26 Nov 2020 01:29:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8C42B2173E for ; Thu, 26 Nov 2020 01:29:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gLbWFunx" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730774AbgKZB3L (ORCPT ); Wed, 25 Nov 2020 20:29:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730656AbgKZB3L (ORCPT ); Wed, 25 Nov 2020 20:29:11 -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 9F585C061A55 for ; Wed, 25 Nov 2020 17:29:10 -0800 (PST) Received: by mail-wr1-x42a.google.com with SMTP id s8so325081wrw.10 for ; Wed, 25 Nov 2020 17:29:10 -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=6wjQylGKSs6f5k46AiccndFCBivbC1+sb7NZBEoxknM=; b=gLbWFunxAHTrWPVNE/Al7nBbo7WJ4BrylatbsU4z3PUBz9HBYZFjrob/Iq5QqLXZ+d zQMNLcuhCXaQqJuQMJPlIuu/OmJnlg8Nz4MtW8bI9DRZmxR2mJXAUBnZ8osbmdCMtqA0 Vr9kmGyzRKOB/lR8ZtJUkUFlAheqMpsRA9VFg6O30dmOGRcvkw0jQuo3SYcj6ln4Hzxl twJBahs8NF4nFHfY0aZqf7EvJvL8qCQbLy1w8Efr1jhh3Zu6vorGoo2iG6KSEHXuTRDN Gkm9m6yDtGmH0cWW7E7PVTEiVd8cMIEVrrYHzPdQ4jvFzd1K0kMUMjgyHj0G1VJRq29s ak6A== 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=6wjQylGKSs6f5k46AiccndFCBivbC1+sb7NZBEoxknM=; b=U6jjGil41vEpFmdJMLrwn7Wkdmcq7hFh2m5fnHwJcin6zKj17hobEeE8wzHVDEnQHN SJF/AYC3eXqytC7WbXSq6vHnbFMg46MVHKQICpI8yBr0bnbSjtV/PX3X1BZesoqr8d6w 8RfthJR2nogks8pMjl4dEVT4pbB1jV3fcDdqWSZZ3NeDidy1Rl4SMa5GNdkBSbvDGYMn GBBBTcJBBKjneB/37sScL0UAT/VbjYyZ807y/dus8DE2LSgBXYG48AI8j8izvRb8fOA4 IOT6LDoOFBKfkTTcObfQy54kyUmfIavdRk4I3iY/kxgMwUFdx+QB6Af7z2ZTwt2bvLBR kn0g== X-Gm-Message-State: AOAM530qS/uFkT2kH8tQabWaek2PoGDp9oeekIsxFwg5MeThMNL1QbzC 5CPE3BnZmC96/F0XFPixp//r2Gx4NYk08A== X-Google-Smtp-Source: ABdhPJwb1mK9oylPXRNLhLq00LwK92ftQrMBlE3phFPwXcNbHv22KgL0UlUrIRnt16jJb15/D5qCxQ== X-Received: by 2002:adf:ee12:: with SMTP id y18mr689365wrn.231.1606354148773; Wed, 25 Nov 2020 17:29:08 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id q12sm6402523wmc.45.2020.11.25.17.29.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Nov 2020 17:29:08 -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?b?w4Z2YXIgQXJu?= =?utf-8?b?ZmrDtnLDsCBCamFybWFzb24=?= Subject: [RFC/PATCH 08/12] mktag: use fsck instead of custom verify_tag() Date: Thu, 26 Nov 2020 02:28:50 +0100 Message-Id: <20201126012854.399-9-avarab@gmail.com> X-Mailer: git-send-email 2.29.2.222.g5d2a92d10f8 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org TODO: This subtly breaks one check, see the last patch in this series. 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. Moving to fsck_tag() required teaching it to optionally use some validations that only the old mktag code could perform. That was done in an earlier commit, the "extraHeaderEntry" and "extraHeaderBodyNewline" tests being added here make use of that logic. There was other "mktag" validation logic that I think makes sense to just remove. 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 " (but not "tagger "). Now we allow all of these. C. Like B, but "mktag" disallowed spaces in the part, fsck allows it. We didn't only lose obscure validation logic, we also gained some: 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. 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 --- builtin/mktag.c | 45 +++++++++++++++++++++++++--- t/t1006-cat-file.sh | 2 +- t/t3800-mktag.sh | 72 +++++++++++++++++++++++++++------------------ 3 files changed, 86 insertions(+), 33 deletions(-) diff --git a/builtin/mktag.c b/builtin/mktag.c index dc354828f7..a1ae80702d 100644 --- a/builtin/mktag.c +++ b/builtin/mktag.c @@ -2,6 +2,7 @@ #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 @@ -47,6 +48,9 @@ static int verify_tag(char *buffer, unsigned long size) const char *object, *type_line, *tag_line, *tagger_line, *lb, *rb, *p; size_t len; + /* verify_tag() will be removed in the next commit */ + return 0; + if (size < 84) return error("wanna fool me ? you obviously got the size wrong !"); @@ -153,10 +157,34 @@ static int verify_tag(char *buffer, unsigned long size) return 0; } +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) +{ + switch (msg_type) { + case FSCK_WARN: + case FSCK_ERROR: + case FSCK_EXTRA: + /* + * 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: %s", message); + return 1; + default: + BUG("%d (FSCK_IGNORE?) should never trigger this callback", + msg_type); + } +} + int cmd_mktag(int argc, const char **argv, const char *prefix) { + struct object obj; struct strbuf buf = STRBUF_INIT; struct object_id result; + struct fsck_options fsck_options = FSCK_OPTIONS_STRICT; if (argc != 1) usage("git mktag"); @@ -164,10 +192,19 @@ 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"); + /* verify_tag() will be removed in the next commit */ + verify_tag("", 0); + + /* + * Fake up an object for fsck_object() + */ + obj.parsed = 1; + obj.type = OBJ_TAG; + + fsck_options.extra = 1; + fsck_options.error_func = mktag_fsck_error_func; + if (fsck_object(&obj, buf.buf, buf.len, &fsck_options)) + die("tag on stdin did not pass our strict fsck check"); if (write_object_file(buf.buf, buf.len, tag_type, &result) < 0) die("unable to write annotated tag object"); diff --git a/t/t1006-cat-file.sh b/t/t1006-cat-file.sh index 2f501d2dc9..5d2dc99b74 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 3801d3a285..bc57ee85c9 100755 --- a/t/t3800-mktag.sh +++ b/t/t3800-mktag.sh @@ -37,7 +37,7 @@ too short for a tag EOF check_verify_failure 'Tag object length check' \ - '^error: .*size wrong.*$' + '^error: missingObject:' ############################################################ # 2. object line label check @@ -50,7 +50,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 SHA check @@ -64,7 +64,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 @@ -77,7 +77,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 @@ -85,7 +85,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 @@ -99,7 +99,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 @@ -111,7 +111,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 @@ -123,7 +123,7 @@ tag mytag EOF check_verify_failure '"type" line type-name length check' \ - '^error: char.*: type too long$' + '^error: badType:' ############################################################ # 9. verify object (SHA1/type) check @@ -159,7 +159,7 @@ tagger . <> 0 +0000 EOF check_verify_failure 'verify object (SHA1/type) check' \ - '^error: char7: could not verify object.*$' + '^error: badType:' ############################################################ # 10. verify tag-name check @@ -173,7 +173,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 @@ -187,7 +187,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 @@ -202,10 +202,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_success 'allow missing tag author name' ' + git mktag .git/refs/tags/mytag 2>message' ############################################################ -# 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_success 'allow spaces in tag email like fsck' ' + git mktag __ EOF check_verify_failure 'disallow missing tag timestamp' \ - '^error: char.*: missing tag timestamp$' + '^error: badDate:' ############################################################ # 18. detect invalid tag timestamp1 @@ -289,7 +291,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 @@ -303,7 +305,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 @@ -317,7 +319,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 @@ -331,10 +333,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_success 'allow invalid tag timezone' ' + git mktag tag.sig < 1206478233 -0500 + + +this line should be one line up +EOF + +check_verify_failure 'detect invalid header entry' \ + '^error: extraHeaderBodyNewline:' ############################################################ # 24. create valid tag From patchwork Thu Nov 26 01:28:51 2020 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: 11932451 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 78B2BC56201 for ; Thu, 26 Nov 2020 01:29:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1789621734 for ; Thu, 26 Nov 2020 01:29:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HRzkpXuh" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731745AbgKZB3N (ORCPT ); Wed, 25 Nov 2020 20:29:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730787AbgKZB3M (ORCPT ); Wed, 25 Nov 2020 20:29:12 -0500 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57CD7C08E862 for ; Wed, 25 Nov 2020 17:29:11 -0800 (PST) Received: by mail-wr1-x443.google.com with SMTP id r3so360474wrt.2 for ; Wed, 25 Nov 2020 17:29:11 -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=RW7sYWlismP6ozbuDJ/KNw5x9kB6k+wmAoxiuougQcY=; b=HRzkpXuhsPkjaMiP876JxEJSGM9CVYyue/Hbp65DZItzB7Ko/heTpLoCETsMPAI4wx kIA/RSKG9hEUndEFyZnpukmp9hCsc3fWp+stu9HpyAxVPsViIAgdDQQKxWNaPuOReCId Vna5E7NCJEfwZH+wy1q5qvQvbAgykA/bTVazEBbZ+ZDQOcWQfFfzkpqwLhVzlKGvn7pS lVlnWZofsb7RvJrwqrrtB/+DFIV5rjBvV+SrWsXfnFAiEc/fUPrhM/8C+m4nwOeDSWpj DVHX6CiCZukmhizwUkQIffNca/KllVTj7qGikeKXqq1q4wUhS+xvDV+3jMQSUajTrVGx 8ONg== 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=RW7sYWlismP6ozbuDJ/KNw5x9kB6k+wmAoxiuougQcY=; b=GZHcW/LSB/49wobVysCnJXql5JvtcbE5hYXkCA6AkKvbyGEL2qVQGE2Gdalwnjd6Dw ceU9qwNcGXtSEHmJFuHWRg4hgCcUKOh9OBUD2MXy09t6Qsv1WMd2UNSjr322AJzfBT78 DwNo9kfISuHbAXPzxKyJ/ewCZPnnYdSn2EMWIfdPjVej49AC1wiSS612SGdeqM6WytmN u9heJtqghsrxrLAWbZH0MFdEXqJcXG7jok0yf5K93m3zvGTA2zU36BqVV0V8rXVIHL4/ s02XRaRO7xFAQqHxWRcLkLozta/BMAEVYe3b1Fpk4Lz81fh/oIg/sHHwIwkWUnaKTNtj rZ5g== X-Gm-Message-State: AOAM530EbiaSWqzprw/uu2Tr/EpnblHD3QZiwT0V33xaIh/56kf6R+H/ GYnZtA9rLvjoLIVPf6hnyGA4OMRverIxVg== X-Google-Smtp-Source: ABdhPJwVCigjywaGF4nKcksmlWiMIRIZ1bIe9MBU0xJ2SDo2AD7zePNzvmNgAmnT0kxSOTTauBDYlA== X-Received: by 2002:adf:fa0c:: with SMTP id m12mr753845wrr.222.1606354149687; Wed, 25 Nov 2020 17:29:09 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id q12sm6402523wmc.45.2020.11.25.17.29.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Nov 2020 17:29:09 -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?b?w4Z2YXIgQXJu?= =?utf-8?b?ZmrDtnLDsCBCamFybWFzb24=?= Subject: [RFC/PATCH 09/12] mktag: remove now-unused verify_tag() code Date: Thu, 26 Nov 2020 02:28:51 +0100 Message-Id: <20201126012854.399-10-avarab@gmail.com> X-Mailer: git-send-email 2.29.2.222.g5d2a92d10f8 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The preceding commit removed the use of the verify_tag() function, but didn't remove this code to keep the diff smaller. Let's remove this unused code now. Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/mktag.c | 157 ------------------------------------------------ 1 file changed, 157 deletions(-) diff --git a/builtin/mktag.c b/builtin/mktag.c index a1ae80702d..e9a0954dcb 100644 --- a/builtin/mktag.c +++ b/builtin/mktag.c @@ -1,162 +1,8 @@ #include "builtin.h" #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) -{ - 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); - } - return ret; -} - -static int verify_tag(char *buffer, unsigned long size) -{ - int typelen; - char type[20]; - struct object_id oid; - const char *object, *type_line, *tag_line, *tagger_line, *lb, *rb, *p; - size_t len; - - /* verify_tag() will be removed in the next commit */ - return 0; - - 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)); - - /* The actual stuff afterwards we don't care about.. */ - return 0; -} - static int mktag_fsck_error_func(struct fsck_options *o, const struct object_id *oid, enum object_type object_type, @@ -192,9 +38,6 @@ 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_tag() will be removed in the next commit */ - verify_tag("", 0); - /* * Fake up an object for fsck_object() */ From patchwork Thu Nov 26 01:28:52 2020 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: 11932449 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 42CC8C71155 for ; Thu, 26 Nov 2020 01:29:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C6B222168B for ; Thu, 26 Nov 2020 01:29:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VJFmRYSt" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731733AbgKZB3N (ORCPT ); Wed, 25 Nov 2020 20:29:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730656AbgKZB3M (ORCPT ); Wed, 25 Nov 2020 20:29:12 -0500 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88FDEC061A52 for ; Wed, 25 Nov 2020 17:29:12 -0800 (PST) Received: by mail-wm1-x341.google.com with SMTP id 1so555044wme.3 for ; Wed, 25 Nov 2020 17:29:12 -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=0OBgRT2gDI16UFkLXk4ZLPAx9PhNcbUhQlyw98Y5NIA=; b=VJFmRYStEc9b7eS0J0CKdq6AYEuMs0WGnkJxFu8ZAKEUQZ2X4W0pN6mmMd9E9OFCo7 7Q9AFYcqAbQkSpJn65T6Mxave4546+oyJQdlmRfznG+6OmrSEaFHOivtqk6fkwtxVpyg fc8/iFBdUKx4MWfnAk0rMcTq6yO6lKlKXmOJlmZe1bIaUj+0O+IzwpM8mILQ6KuGvJpE wwUEcDmLGOO0x9fwWt8UNIMljWXI64Zg/LX0Fx/0n0EcnCAycg7qbEBX10ZtvJihk/8x ptD2tokCbjaqPwf3Pg75ha/ofHSw4mWoZbZ2E92lApcPG2jcLt+MUJ/lw3br6bdOuevQ 3Nzg== 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=0OBgRT2gDI16UFkLXk4ZLPAx9PhNcbUhQlyw98Y5NIA=; b=j2Csr1uMfZoKOpszfXM4+xF4fAifb8+OfiMRdYa230Cs66WF0WYb5pKGRSwhdpy5wl 8FPceVHcO1A1ZhzihTFmm4KuNB9JpIpz4MqRxeXZcnfYGZUicsXlMafl3ZRpFroGVs7N PxkrFshtM+2uG7zGIbC/7PUiLvlbh3ZCs7SrQYJwYbb816FCsTikCnnkmgmLWrNZIrqR AnaAZAT/hgGKST6xBeMFA5gumcb9jx/UPoh9LOqY5dorG75THeY//tOpLwhiyuPa2lqm vWHjJTx6vfrbuRFDvxkDtpaVjH+RZ7c28KsqzArLOSx+RSqJNTbqha3H1WLrJGGHXmOp luyg== X-Gm-Message-State: AOAM532kUTVuB0DGXi6wzSxJQPvej6crX28+amFMDbc3PQaH9XncUKgm FzLjFUapEUj099YHcLTW+qCl7qAQz1J2jw== X-Google-Smtp-Source: ABdhPJyowF6FhqeFy1O3pAQsytfcYgb2zgQsSJchb/MriWAZymYVn58TikYC/hj/wz0xG0Npxv/XoA== X-Received: by 2002:a05:600c:58e:: with SMTP id o14mr463429wmd.47.1606354151028; Wed, 25 Nov 2020 17:29:11 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id q12sm6402523wmc.45.2020.11.25.17.29.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Nov 2020 17:29:10 -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?b?w4Z2YXIgQXJu?= =?utf-8?b?ZmrDtnLDsCBCamFybWFzb24=?= Subject: [RFC/PATCH 10/12] mktag doc: update to explain why to use this Date: Thu, 26 Nov 2020 02:28:52 +0100 Message-Id: <20201126012854.399-11-avarab@gmail.com> X-Mailer: git-send-email 2.29.2.222.g5d2a92d10f8 In-Reply-To: References: 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 make it clear that it's to do with slightly different fsck validation logic, and cross-link the "mktag" and "hash-object" documentation to aid discover-ability. Signed-off-by: Ævar Arnfjörð Bjarmason --- Documentation/git-hash-object.txt | 4 ++++ Documentation/git-mktag.txt | 29 +++++++++++++++++++++++++---- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/Documentation/git-hash-object.txt b/Documentation/git-hash-object.txt index df9e2c58bd..c535661ced 100644 --- a/Documentation/git-hash-object.txt +++ b/Documentation/git-hash-object.txt @@ -58,6 +58,10 @@ OPTIONS stress-testing Git itself or reproducing characteristics of corrupt or bogus objects encountered in the wild. +SEE ALSO +-------- +linkgit:git-mktag[1] + GIT --- Part of the linkgit:git[1] suite diff --git a/Documentation/git-mktag.txt b/Documentation/git-mktag.txt index fa6a756123..11ce8e4bb4 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,20 @@ 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 accepts a subset of what linkgit:git-hash-object[1] would +accept with `-t tag --stdin`. I.e. both of these work: + + git mktag X-Patchwork-Id: 11932447 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 8F16FC64E90 for ; Thu, 26 Nov 2020 01:29:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4F4662168B for ; Thu, 26 Nov 2020 01:29:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Myc5vPSu" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731775AbgKZB3O (ORCPT ); Wed, 25 Nov 2020 20:29:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731750AbgKZB3N (ORCPT ); Wed, 25 Nov 2020 20:29:13 -0500 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84C3EC061A52 for ; Wed, 25 Nov 2020 17:29:13 -0800 (PST) Received: by mail-wm1-x342.google.com with SMTP id 1so555072wme.3 for ; Wed, 25 Nov 2020 17:29:13 -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=7XlGbzA/7iMWtkvJ+Vve3dlMVUtJbKtMllv5EkntCis=; b=Myc5vPSuaTAj6MkS3lXrShboFtCQ2YpIZ5R1nKdHxG1fl8IxbcE5ghfcV+8lghml7V SfOB8aFz6Qv/wSz3OtB6/LtOgaH4RoiE5zYM2lYWOZ6HRDl+CYKnBmYW7ptJIlfdtqCE +cdw/umGzUcxB64P0HMbhw19bM6PCixMmJjrldq4l3fCkvC71Xswtt9Rq7zw8nnU3a0L 8CX6e1B96ElOU5oLZ72pzZuiCoZmasF6o8WgT4+Xe7Olli0MFC0xFZVaX81od2ygs7w/ Sp6cTE17SWj1f8HLg1WslDHD3zvD9KF13vTlRXNLLQbLMR/N01XZT5ExsUePX/EmoLon BP5A== 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=7XlGbzA/7iMWtkvJ+Vve3dlMVUtJbKtMllv5EkntCis=; b=YR4olRvkVpFmzwYJTv4h3YvM0v6mrsExkmO/WbkWXhDBsFqT5o65CCLQBN8sL5Aggl x2Y9Do+yYAGYZstzh0elsQUEd+PNjRonREICJcx1u20idcwp12NNuoofwZhU6MvF46f0 Su11sHFgAF1K2D6xhZRzQ/uAeF55loOW/4IF02djS7RDKDcPQ9AeiR6+GMSryxZQq2CF /v+kpnkiOV4ltL2cQ+eXjc9r4Tp+8zqmw4mkt3veO90J6PsJA6CMBrtht9OR6UfT3DyP T+aJmqjMbRrRVeEXdOCX3k93xRWe+EHHXixkUHWEo/GV64/hesSUxRrZQ00JotF8C1yY 6cbw== X-Gm-Message-State: AOAM531NiEMTlfQYV/kFDTd2m/sFVRIvHyeaUAzJh3l8jKgvzZfb9tWU DH5hy45l1wdcDZAcXmte2TbjmTaEV2LUFg== X-Google-Smtp-Source: ABdhPJwddrdIk/cyrDNBvY2jIp34ooBGkMFlVnX8+lmnUlAoaDPIGulZ/HcSPJPUDXEA2+ucZHc9Cw== X-Received: by 2002:a1c:f20d:: with SMTP id s13mr476854wmc.156.1606354152017; Wed, 25 Nov 2020 17:29:12 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id q12sm6402523wmc.45.2020.11.25.17.29.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Nov 2020 17:29:11 -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?b?w4Z2YXIgQXJu?= =?utf-8?b?ZmrDtnLDsCBCamFybWFzb24=?= Subject: [RFC/PATCH 11/12] mktag docs: say not Date: Thu, 26 Nov 2020 02:28:53 +0100 Message-Id: <20201126012854.399-12-avarab@gmail.com> X-Mailer: git-send-email 2.29.2.222.g5d2a92d10f8 In-Reply-To: References: 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 11ce8e4bb4..3ba15072df 100644 --- a/Documentation/git-mktag.txt +++ b/Documentation/git-mktag.txt @@ -33,7 +33,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 Thu Nov 26 01:28:54 2020 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: 11932455 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.7 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,URIBL_BLOCKED,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 F3E8AC56202 for ; Thu, 26 Nov 2020 01:29:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 84FF8216C4 for ; Thu, 26 Nov 2020 01:29:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="m2KD/HWf" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731800AbgKZB3P (ORCPT ); Wed, 25 Nov 2020 20:29:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731750AbgKZB3P (ORCPT ); Wed, 25 Nov 2020 20:29:15 -0500 Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BD32C061A52 for ; Wed, 25 Nov 2020 17:29:14 -0800 (PST) Received: by mail-wm1-x344.google.com with SMTP id p22so486885wmg.3 for ; Wed, 25 Nov 2020 17:29:14 -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=cVKyRnsXPjyW72TxMP0IT7PzzwJNWjf+o6NrECnfcG8=; b=m2KD/HWfJmewuElJu1sG2c5wf6jlq8zvBpNIFk3EjLwOXJxn0wRbbZKemZExuOtoXE ZquoOCXaaPxSgko7FWyUQ7/bciQvJyUXcjhXa63jQDydKWvljfumhX1/MbRsZ8/l+N4K f+QnGwct6CbYERwftx1xyb0xSmeUpXL2ZYq4m+L5k5g4XweiSOCbRqZXAwDYZhn6JA8S FA4OXCa/A0fLeGSqHIeqyC0H8u+uaVkGib2VeNdTuwGIiq0pf/KJoFWTTIju7pSuAKoC JZiS1ZT68gr5Fom9t2d/6jFLUJKXf1VOeBQmPnSmRdvQ15OYHmVH7AVCrM9S/9NuURbp NZ4Q== 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=cVKyRnsXPjyW72TxMP0IT7PzzwJNWjf+o6NrECnfcG8=; b=buRgnjfUsnVj78mnCc897UchvQWhbrhZZYonu0QXTtnokdJuXzhwL86nLNKp31lscV nD4W7qaB8Cvx6dZQZEVCQtn/9TtdOptP2PFj9VZo3e6msgMzOXa28bb6L1Epu0kmVbBR VqbrubMbrJvePpqqythxFl/QKSwmII+Dj6xPjOVDxP9+VxqleHTtFPbUhxWPM3rSXsUv qZ7zAg3BNG+VA4x/GLbjYNYKWSR6UORvlB2K8NWTyAW3HegCVaZdO9QNjjHWXsYASj4X ykrLRlM1NPN3wyXhTOTKAQ8mWhWipMFEcf1161+P1PCc7UZRuagTJxIIANRpfGUgYqQd k5Yg== X-Gm-Message-State: AOAM530/x7fIIpmhyx2be+T8pl5IwqeHrf/AbBhP7Z8IUy9l4Xxnv4bX q4XMMpFY/eCb7yyqWNNcnS440TD2Vsy21Q== X-Google-Smtp-Source: ABdhPJy4ltXHIo7pvozwD2iaQV39Hs9tikGuDJ3zKufdQ9zaVim2arCbHMMqjw/r7XAi9MLwo93tAA== X-Received: by 2002:a7b:c0d7:: with SMTP id s23mr493050wmh.54.1606354153127; Wed, 25 Nov 2020 17:29:13 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id q12sm6402523wmc.45.2020.11.25.17.29.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Nov 2020 17:29:12 -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?b?w4Z2YXIgQXJu?= =?utf-8?b?ZmrDtnLDsCBCamFybWFzb24=?= Subject: [RFC/PATCH 12/12] mktag: bring back some of the verify_object() logic Date: Thu, 26 Nov 2020 02:28:54 +0100 Message-Id: <20201126012854.399-13-avarab@gmail.com> X-Mailer: git-send-email 2.29.2.222.g5d2a92d10f8 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org When working on this series I saw too late that I'd removed the mktag check for validating the object the tag points to. The fsck_tag() code doesn't do this because it's meant for the context of fsck, where we're validating reachability anyway. We'd need to either refactor fsck_tag() so that it can pass us back its "tagged_oid" and the "type_from_string_gently()" value it throws away to get rid of the re-parsing of stdin here, or just duplicate the logic as I'm doing here. Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/mktag.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ t/t3800-mktag.sh | 4 ++-- 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/builtin/mktag.c b/builtin/mktag.c index e9a0954dcb..f1f1cf04ff 100644 --- a/builtin/mktag.c +++ b/builtin/mktag.c @@ -1,5 +1,6 @@ #include "builtin.h" #include "tag.h" +#include "replace-object.h" #include "object-store.h" #include "fsck.h" @@ -25,6 +26,50 @@ static int mktag_fsck_error_func(struct fsck_options *o, } } +static int verify_object_in_tag(const char *stdin) +{ + struct object_id oid; + char *eol; + const char *p; + int expected_type_id; + const char *expected_type; + int ret = -1; + enum object_type type; + unsigned long size; + void *buffer; + const struct object_id *repl; + + if (!skip_prefix(stdin, "object ", &stdin)) + goto bug; + if (parse_oid_hex(stdin, &oid, &p) || *p != '\n') + goto bug; + stdin = p + 1; + if (!skip_prefix(stdin, "type ", &stdin)) + goto bug; + eol = strchr(stdin, '\n'); + expected_type_id = type_from_string_gently(stdin, eol - stdin, 1); + if (expected_type_id < 0) + goto bug; + expected_type = type_name(expected_type_id); + + buffer = read_object_file(&oid, &type, &size); + 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); + } + goto ok; +bug: + BUG("fsck_object() should have ensured a sane tag format already!"); +ok: + return ret; +} + int cmd_mktag(int argc, const char **argv, const char *prefix) { struct object obj; @@ -49,6 +94,9 @@ int cmd_mktag(int argc, const char **argv, const char *prefix) if (fsck_object(&obj, buf.buf, buf.len, &fsck_options)) die("tag on stdin did not pass our strict fsck check"); + if (verify_object_in_tag(buf.buf)) + 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 annotated tag object"); diff --git a/t/t3800-mktag.sh b/t/t3800-mktag.sh index bc57ee85c9..74cd2eb141 100755 --- a/t/t3800-mktag.sh +++ b/t/t3800-mktag.sh @@ -137,7 +137,7 @@ tagger . <> 0 +0000 EOF check_verify_failure 'verify object (SHA1/type) check' \ - '^error: char7: could not verify object.*$' + '^fatal: tag on stdin did not refer to a valid object' cat >tag.sig < 0 +0000 EOF check_verify_failure 'verify object (SHA1/type) check' \ - '^fatal: invalid object type' + '^error: badType:' cat >tag.sig <