Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp189395rwr; Wed, 19 Apr 2023 05:22:56 -0700 (PDT) X-Google-Smtp-Source: AKy350aYXLwMIjK0EXRwpDzv8NVKQKBKcRkbmmozq1p7eaAXfkUG4tS/LH3VMmxJbq/gNtyQR5Di X-Received: by 2002:a05:6a20:7d9f:b0:f0:9de1:193e with SMTP id v31-20020a056a207d9f00b000f09de1193emr2491251pzj.6.1681906976479; Wed, 19 Apr 2023 05:22:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1681906976; cv=pass; d=google.com; s=arc-20160816; b=Bt6nx1D/HyRBynQPRcu2F6XycDdLdiS9I6nr6X6vPhLn3vN+BAWj4lhSf7Ctelz8Iz ckOclz/A3OFCu86NOVMlaHG9AsbvYMkmihWkirfHrScuLpOaHwrQyGZWr2Z8+3Nd6+Pw ekcTGjJ32aFjUDx/98XYMimxDucgAoywPFbzA/OgKhP3kGXsfFnpgvPg4wCF5GlDxy5X U7YFAwK9oKpXMFsYU+Dy9iCDHdEpEwDBI5ofDdRw4+krE6EFmVaU9UYC+3FDscmmO8p1 f2J3TexRsCTJW/D6bGoC1iLudSGbSEWJPD0m36gwbGGGrR7TUNQ5FS7jTsKV6k6SJpgx 0NtQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=W0/fg8BXxMaJWfZ6AIraY1IascZUbBQQfTqBzRPzOw0=; b=Iqmunkic33xPEDKZklNLXc4EQj4UODlVqnD0Z/dA56Wp4MpObm9/xxDxSRfqUVVTzY xVrygH+82tHDNjhdQAlzgHThnw9zu4Fy2RxFvOkkWdKmIoeNw9FUSkUsriHqNhzI6JHP XKhYXEwCXRuJZXfSGi6JOPstYWKJAlQDc27xZHWdmgF9r6xymHmpMwC/x//CT0nytelp 6LsKmGOH+p7uhqcf3F5oekBMl6Ku8IW3mcXMcoi0v7Emr0JUYbA9a0am5gCPYgbjM2wE 5/2swEL2b+B2kiIiZQySUGdg068Rw3ux0J/jrQU3lyuq9wRj3x9Cgfo4f/nExLgx8IvM LcaA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@garyguo.net header.s=selector1 header.b="oN4/erj0"; arc=pass (i=1 spf=pass spfdomain=garyguo.net dkim=pass dkdomain=garyguo.net dmarc=pass fromdomain=garyguo.net); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w191-20020a6382c8000000b0051f2183c68fsi3978142pgd.333.2023.04.19.05.22.40; Wed, 19 Apr 2023 05:22:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@garyguo.net header.s=selector1 header.b="oN4/erj0"; arc=pass (i=1 spf=pass spfdomain=garyguo.net dkim=pass dkdomain=garyguo.net dmarc=pass fromdomain=garyguo.net); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232614AbjDSMLb (ORCPT + 99 others); Wed, 19 Apr 2023 08:11:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232560AbjDSML3 (ORCPT ); Wed, 19 Apr 2023 08:11:29 -0400 Received: from GBR01-LO2-obe.outbound.protection.outlook.com (mail-lo2gbr01on2137.outbound.protection.outlook.com [40.107.10.137]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E815461AB; Wed, 19 Apr 2023 05:11:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=It0zX3ZCaXxF/13STsJAIXAvqyyKLIOGLKpoWjXOHJDKMOcIEb0UDH2FjpWdizYC3TnjbJnZOq33wH1yPK5OedkWbHD4HdL926F+3ZYxB7kS1K0sr5x7IuNXPTgDzJmY8ALaOzfnMhPW/rBkiIaYhYI5USG+AKn9O8ffYWamxUJjq9MBVPIP0XZ5Huy/AnK2aPutoN0IJT/hOYnSTxMdgTbHixHhqSQkfY6d8YN3gtTClotisfSmXdG2TwYCItu1Q3gT5c21BGFDkkeiTZKJfI4ML4eXtFymCyEhwJYxYIAu177011ZX3zS9DtnCyX4mM53QGCPJxc1CMPvqPmpLbQ== 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=W0/fg8BXxMaJWfZ6AIraY1IascZUbBQQfTqBzRPzOw0=; b=BptdP6xvxuX58XK36Zc4i3qmuIDAt7bCy/dhDC8GwsT3FO+mG376No77VDgTAGStTmo+OmUeonJ4YPz5WLJSYGRsjITzAzqz/jaZCTpX2s5SBafLjAT4FnpvaFPcyOFVx016Tp4htWf8E1arehM06C+SqGOnbf9x/eEO5Xo2WI56ZzBQ1cNTq3bJQ+c+3YHdZjWxte83Vb2eFcarwIEoiu+oAT0rA6PfauHqhjF00bo0q4EiQHlcUSbRx+pj8eShdd8fTUjDpFWd14BGveaC5w+3OIUUwD/xXGyA4l6OwlY1paMUvQIq9mIcyU2ycF2Rh+pvhUmGw25l+13kle9CyQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=garyguo.net; dmarc=pass action=none header.from=garyguo.net; dkim=pass header.d=garyguo.net; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=garyguo.net; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=W0/fg8BXxMaJWfZ6AIraY1IascZUbBQQfTqBzRPzOw0=; b=oN4/erj0dCoJ127lf+PRf+jOnjzr0x/O5luJoV2d6KUz4lk6RpImMdvuKSuzAdbaecvVdeBSttkkn03Ye9Xgx+6Tp9MtiwjwxdlIORTnzbCDga1ZZQiDh/X6IyqIBv/Mz6MaA7PvKsqFOk440hsRuvHAs/GzoOm3ntk5TJ+BEEQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=garyguo.net; Received: from CWLP265MB5186.GBRP265.PROD.OUTLOOK.COM (2603:10a6:400:15f::14) by CWXP265MB5009.GBRP265.PROD.OUTLOOK.COM (2603:10a6:400:19a::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.20; Wed, 19 Apr 2023 12:11:23 +0000 Received: from CWLP265MB5186.GBRP265.PROD.OUTLOOK.COM ([fe80::1b25:7ea3:7339:6a0f]) by CWLP265MB5186.GBRP265.PROD.OUTLOOK.COM ([fe80::1b25:7ea3:7339:6a0f%4]) with mapi id 15.20.6319.020; Wed, 19 Apr 2023 12:11:23 +0000 Date: Wed, 19 Apr 2023 13:11:21 +0100 From: Gary Guo To: Miguel Ojeda Cc: Wedson Almeida Filho , Alex Gaynor , Boqun Feng , =?UTF-8?B?QmrDtnJu?= Roy Baron , Benno Lossin , Masahiro Yamada , Stephen Boyd , Jean Delvare , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev Subject: Re: [PATCH] .gitattributes: set diff driver for Rust source code files Message-ID: <20230419131121.6f5f5acf.gary@garyguo.net> In-Reply-To: <20230418233048.335281-1-ojeda@kernel.org> References: <20230418233048.335281-1-ojeda@kernel.org> X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.33; x86_64-pc-linux-gnu) Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-ClientProxiedBy: LO4P123CA0185.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1a4::10) To CWLP265MB5186.GBRP265.PROD.OUTLOOK.COM (2603:10a6:400:15f::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CWLP265MB5186:EE_|CWXP265MB5009:EE_ X-MS-Office365-Filtering-Correlation-Id: db42e17f-6ea9-4e00-3c3d-08db40cf3190 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: i8s68f9fJWvcZ2K/PhHBBDlt1DgPU4D2AadGF2S5dfFU0tmdjOcVtKrjXhMifwRi/XbdSRlcB3etVeByxIZEgZyW8N1LKXJcUq1FYw1dwkPFSr5MkUiI6y2Q5DgXX7S5CAi2aUC2l8c2MY8mx9f3XFiuQwena9Y7bnt//EQwEHpARUrS6iMs1Z8/gXNQTstnwR9s6GmlPJ+JlFt4ogaaFlMhgX8ChQqOrmQylMIIZPCzNdwTqrr+P5lGVT2I/38zQDmpxs7x5M8eQ7BXVqiokA7LUwkS+5KB/x6OpIpAWszgngEqrlgRxTAj9X1jipQmVSYAL2z2NlEd+VyaIyxkQfohldGgacLa4yQL+BQlQNdiSsqxWmlEDo1yV5xZmj3z7GxGAyt+6/b1iU3TAE3qji4+f6L6PBRzISTP7VJwbZgmzdXsSp5wHQuaseOuD5TWGghvV29d/5E1pEoxD6q98Scueff+KzV2d7crFvLFksKcjKEDn9TZT5oUIqf+b2LDZCVJQC+ERpE07bz3JHOSU5XOF9JiRaD9meq/J+01HQE= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CWLP265MB5186.GBRP265.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230028)(39830400003)(396003)(376002)(366004)(346002)(136003)(451199021)(6486002)(966005)(478600001)(86362001)(36756003)(2616005)(83380400001)(6512007)(186003)(6506007)(26005)(38100700002)(1076003)(316002)(66946007)(66476007)(66556008)(2906002)(6916009)(8676002)(5660300002)(8936002)(7416002)(41300700001)(4326008)(54906003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?AnDfZtyidZ5C/DKU+elkLrG/TspLqBJyvHWxamnXujvAqXMfZXvaUbWEQmG/?= =?us-ascii?Q?ijTCihTFjd+aI7fe6b79w5hXCkskxjXymGkMw+7y5fFKMAHgTsAcJBz6URm2?= =?us-ascii?Q?AESVcOXC9ntzJDN5bIKiBLNv0YeotJtmhD29+IAEl0js+jWcE2cwyipLSJJB?= =?us-ascii?Q?LYIhYDHOuPTTohxEmVBc1x+HCRtgUX5QbxNATGUQjzH7QJEjSYLFLUPpJI9j?= =?us-ascii?Q?9A3xxBj+fOFOEUznoSdcv5B2Irs8VGgzQucpFm7lDsea1Gt4p/jgd0OH0HI5?= =?us-ascii?Q?1x5zcGvZx3Ke5SH/UpwiCvzwSfb2QHeOlsmlihSiXhgbpEQB8hLLaNiTZJRg?= =?us-ascii?Q?aVZD1nEybnBNYiR/HG1C13Zn50r49SsfVqQcdqUNKdqMOohVSfNJNWT3dICC?= =?us-ascii?Q?CUPOGL9LnnUibajjBMgwUZ5ntHOpUgfkfCUZx35enHARdSww/kJExnWVZJts?= =?us-ascii?Q?u0wiQKSvAOMQvspHMUuXVZq3gsoDL3vMi2CFnimK56ZC2+zBV1K9LuDg/MDw?= =?us-ascii?Q?3cqBQXCXtDyB8ZGlD8ce+19eI+wgN+PrYqSh+juCV/N2D/FmHidWdnawOOmX?= =?us-ascii?Q?trPg0asnpBRDIr662jhibjkLhtOlQb9RwCVcZ1AdYIbCA5teSEh+y8NbwF05?= =?us-ascii?Q?e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fjggVC7fEPkVZJ7Id?= =?us-ascii?Q?5gfhfuMmednTbkkXNqaLxQG9Sv9VXJ8ejXsZQuJE?= X-OriginatorOrg: garyguo.net X-MS-Exchange-CrossTenant-Network-Message-Id: db42e17f-6ea9-4e00-3c3d-08db40cf3190 X-MS-Exchange-CrossTenant-AuthSource: CWLP265MB5186.GBRP265.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Apr 2023 12:11:23.8325 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bbc898ad-b10f-4e10-8552-d9377b823d45 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: c/uFDiJPIdrK9opo9ydqaEgX0jAa/1MiHmyrTAHD1QTFW04DOk98L3zE3PKT7uXgCMiWU5zWch0hhygN2//rhw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CWXP265MB5009 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 19 Apr 2023 01:30:48 +0200 Miguel Ojeda wrote: > Git supports a builtin Rust diff driver [1] since v2.23.0 (2019). > > It improves the choice of hunk headers in some cases, such as > diffs within methods, since those are indented in Rust within > an `impl` block, and therefore the default diff driver would > pick the outer `impl` block instead (rather than the method > where the changed code is). > > For instance, with the default diff driver: > > @@ -455,6 +455,8 @@ impl fmt::Write for RawFormatter { > // Amount that we can copy. `saturating_sub` ensures we get 0 if `pos` goes past `end`. > let len_to_copy = core::cmp::min(pos_new, self.end).saturating_sub(self.pos); > > + test_diff_driver(); > + > if len_to_copy > 0 { > // SAFETY: If `len_to_copy` is non-zero, then we know `pos` has not gone past `end` > // yet, so it is valid for write per the type invariants. > > With the Rust diff driver: > > @@ -455,6 +455,8 @@ fn write_str(&mut self, s: &str) -> fmt::Result { > // Amount that we can copy. `saturating_sub` ensures we get 0 if `pos` goes past `end`. > let len_to_copy = core::cmp::min(pos_new, self.end).saturating_sub(self.pos); > > + test_diff_driver(); > + > if len_to_copy > 0 { > // SAFETY: If `len_to_copy` is non-zero, then we know `pos` has not gone past `end` > // yet, so it is valid for write per the type invariants. > > Thus set the `rust` diff driver for `*.rs` source files. > > Link: https://git-scm.com/docs/gitattributes#_defining_a_custom_hunk_header [1] > Signed-off-by: Miguel Ojeda This is also done in rustc repo: https://github.com/rust-lang/rust/blob/master/.gitattributes Reviewed-by: Gary Guo > --- > .gitattributes | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/.gitattributes b/.gitattributes > index c9ba5bfc4036..2325c529e185 100644 > --- a/.gitattributes > +++ b/.gitattributes > @@ -2,3 +2,4 @@ > *.[ch] diff=cpp > *.dts diff=dts > *.dts[io] diff=dts > +*.rs diff=rust > > base-commit: 09a9639e56c01c7a00d6c0ca63f4c7c41abe075d