From patchwork Thu Jun 16 15:46:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Oliver X-Patchwork-Id: 12884388 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 32B47C433EF for ; Thu, 16 Jun 2022 15:46:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377241AbiFPPqN (ORCPT ); Thu, 16 Jun 2022 11:46:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377191AbiFPPqM (ORCPT ); Thu, 16 Jun 2022 11:46:12 -0400 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2077.outbound.protection.outlook.com [40.107.101.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BFCE39808 for ; Thu, 16 Jun 2022 08:46:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UDgnYlmRbqFILf85kxJV9ZmJNaUD2kXkA9WkNqb14pCbcd04LRAOBfCvfWYCFtu5v/kw64iJNlEM+qWy3Q0wbrE9skWmjbC1Kg+0w5Fbgx7sw5ElstsOqwGttgRRSxktQuQrb1tGwwljNF2BhMGLcsuWpT+R2e1smUILbHOCORyZNUjhCwWhSLN9PbDQ2Jp/oOkZqhq7a2ntPwxLcjfxAYJlaF0fUp2GI6zAg+qbDkBBsgE8xP7fmiMqz3xrOKf839OurDHo0TL48JV7h0Orq0mfrSfPf2M6JLSVjl1goU9VhZAEsVymgElxnzDM/xKidSECsZPh/7S2PlApLpoU/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mEJXcMIC6yj7fZWIqeozpiRhCchsG6NMYzttGiO3ce0=; b=NQ/k2d3OBKineiRaRs6XzA3h5hg/Di23sddrFZ+EX1sIG4rH4ZAJZya7MdfksqK6F/mVAQpz+ILmRczMnK4liCCTPHqYi/pCs84mumx4EZgqHfKJotl/635xmvWT0Wz82gTVSmqn86rqAISfTl2Il0IyJ1Td3KjIIaqoyWZZaqQOvurCq6K7fdWn8ODIzCwRjpoUqSkJBSmZQxqHlGaWKCIctq6p7Y+8umdHKLEVe/yp9r6beulC3T7n1EhWRQn6doHWr0+nsFVlnnYxqURUf1fuEofiC4W0Nw4lwL1NtDr6OY9TD3zfnlJxXdOnijxLBhFljuXaPq85AnqZ6sCpgg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=roku.com; dmarc=pass action=none header.from=roku.com; dkim=pass header.d=roku.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=roku.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mEJXcMIC6yj7fZWIqeozpiRhCchsG6NMYzttGiO3ce0=; b=uP+lk/hSuwrjjPwdBMIxVVsGqX4pmKtnkE1xjPah1kL3Lfn6eU56Ij896uiWDI9q3tYKsEWFFnsTjNd50HG1VMtNUKK5SvzkwypZXzRp57a9HTE7lgGz6OuIl4xuRbjdEJKYB/kM2y80EbtUI5GV6B1WwZZHyAKoQsdpvrVvzYFyRFYdhEW5SJ1gi33Jv+l5OWAGK3zMAH5JyV2/CY/Kgj798zMNllULT9aejLezl1HomYDIl7F+4Wh88kKAN3O1XRlzmtGJehGeWDBw/g4e0oz4HpYS64S97Kz7NueAybv5oi9Vh5Z2Svkd1mLm+EVkSsyzjy6vq+TCv4nB6l6BSw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=roku.com; Received: from CO1PR01MB7225.prod.exchangelabs.com (2603:10b6:303:160::21) by BN6PR01MB2676.prod.exchangelabs.com (2603:10b6:404:d7::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.17; Thu, 16 Jun 2022 15:46:07 +0000 Received: from CO1PR01MB7225.prod.exchangelabs.com ([fe80::1062:158b:2993:5535]) by CO1PR01MB7225.prod.exchangelabs.com ([fe80::1062:158b:2993:5535%6]) with mapi id 15.20.5353.015; Thu, 16 Jun 2022 15:46:07 +0000 Message-ID: <1566aed1-a38f-a9ca-241c-21b56d732328@roku.com> Date: Thu, 16 Jun 2022 16:46:00 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: [PATCH] mktree: Make '--missing' behave as documented To: Junio C Hamano Cc: Jeff King , Taylor Blau , Derrick Stolee , git@vger.kernel.org, jonathantanmy@google.com References: <77035a0f-c42e-5cb3-f422-03fe81093adb@roku.com> <0067c46a-7bfd-db9c-5156-16f032814464@github.com> <797af8c8-229f-538b-d122-8ea48067cc19@roku.com> <574dc4a9-b3c7-1fd3-8c0e-39071117c7f0@github.com> From: Richard Oliver In-Reply-To: X-ClientProxiedBy: AM5PR0502CA0015.eurprd05.prod.outlook.com (2603:10a6:203:91::25) To CO1PR01MB7225.prod.exchangelabs.com (2603:10b6:303:160::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 074bfd3f-ebf7-4af9-31c1-08da4faf53b6 X-MS-TrafficTypeDiagnostic: BN6PR01MB2676:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: L9PykeroIi59cGxPiho2G/jkt6MOiTOyQAuUXRH6Lu5oXRzxeen26djrBJjn0jsrgFK0X04hN+zOtFg+RlGXAocXzwOZRDPVaMfHZMcoq+XKqKArc4ZZHsFv8V4J5trllALWAQTzSAldTvDKHMhdENDM6lE9NPG5HeEkdyxE6cgBZLedDjLujQKypcjMPiX7trncC0L1hAC32x6tYXI8nQ/yg/7LOx8DQLbr192YxinVba8y4WtGGqyAyQJt4xvUPd6S9aAHwsAHuKVPmnGk+CET8+tU16nnEzRD2uNKOWsNxMfW1xa8UkgSubgZbArmtng+5mpYqnK54knXWi7km2WH6RIkdNh9pI14ZIjvSsbWk9NB1b8YcP+aJqCyARq5PgH0SqNwS2fikng1HhDMwHX4aMxZ2+KEABQ8ACI4SwIl1Gq5dCa7urpr6fgFDhqyiPp9nPAD2xB6Inp6kU5eNsqjMok8+e7e5gVitbwc8bN0ONZQjN9DjvnlRjaZ+LExcTZHKGG98cOcs264/AF5ZIY3gh+qZZcHVTJExz4HlKIIT7Lc2A75XxtpKGYKL+ogXfQyCUSRxpOAZh4EendZ2bP4gVgxnu93ssiXCT4Jur5JCyNrCfGk0BqKhJZcTy9YL/7DIvyxE1trupUjQKXmvjxHBm2AN4OtxTX8E/LcGLeuFnd5voK50387Phlqp9aY8L1N7gwTmIJXZkUXqVyjtQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR01MB7225.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(13230016)(366004)(66476007)(66556008)(5660300002)(8676002)(36756003)(6506007)(186003)(4326008)(2616005)(53546011)(6916009)(83380400001)(6666004)(54906003)(31696002)(66946007)(316002)(38100700002)(2906002)(6486002)(31686004)(6512007)(508600001)(26005)(8936002)(86362001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =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da4faf53b6 X-MS-Exchange-CrossTenant-AuthSource: CO1PR01MB7225.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jun 2022 15:46:07.3665 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 00fc7e42-ad65-4c4c-ab54-848ba124a5b7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: OQc4BxIgd7iqR5zOpm4utQ/8FcZlo0DkitOsDlk5DoZLrh4FUpCwZSBqBkGWskrPvhjfSavz1w0HPSKjbfDUEw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR01MB2676 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On 15/06/2022 22:01, Junio C Hamano wrote: > We by grave mistake at 31c8221a (mktree: validate entry type in > input, 2009-05-14) started insisting on inspecting objects even when > allow-mising was given. I do not think it was sensible, given why > we had "--missing" as an option to allow users to say "you do not > have to be too paranoid". > > The codebase is so distant but I think we should probably do a moral > revert/reconstruct of that commit so that the extra paranoia of the > said commit applies only when "--missing" is not in effect, or > something like that. -- >8 -- Subject: [PATCH] mktree: Make '--missing' behave as documented Do not make use of the object store to verify object type for 'allow_missing' objects in mktree_line(). GIT-MKTREE(1) documents '--missing' as disabling "verif[ication] that each tree entry's sha1 identifies an existing object". This change retains the check for '' and '' for 'allow_missing' objects as this check is merely input validation that avoids interrogating the object store. Signed-off-by: Richard Oliver --- builtin/mktree.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/builtin/mktree.c b/builtin/mktree.c index 902edba6d2..f41fda6e7d 100644 --- a/builtin/mktree.c +++ b/builtin/mktree.c @@ -116,15 +116,12 @@ static void mktree_line(char *buf, int nul_term_line, int allow_missing) path, ptr, type_name(mode_type)); } - /* Check the type of object identified by sha1 */ - obj_type = oid_object_info(the_repository, &oid, NULL); - if (obj_type < 0) { - if (allow_missing) { - ; /* no problem - missing objects are presumed to be of the right type */ - } else { + if (!allow_missing) { + /* Check the type of object identified by sha1 */ + obj_type = oid_object_info(the_repository, &oid, NULL); + if (obj_type < 0) { die("entry '%s' object %s is unavailable", path, oid_to_hex(&oid)); } - } else { if (obj_type != mode_type) { /* * The object exists but is of the wrong type.