Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp199710rwr; Wed, 19 Apr 2023 05:32:14 -0700 (PDT) X-Google-Smtp-Source: AKy350Z0bsMom4mY0mRN5phREXqEpyDxktvT/Fj1CoScJsFtQkaX+tojwSiF3T6Rsxz/y0kAQPR4 X-Received: by 2002:a05:6a20:9185:b0:ef:e927:700f with SMTP id v5-20020a056a20918500b000efe927700fmr3927253pzd.31.1681907534351; Wed, 19 Apr 2023 05:32:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681907534; cv=none; d=google.com; s=arc-20160816; b=W1qoJSuRWS7EYWzQeZmjoNffpDooKooEGbZQBikvrSbrMH1xpTZjmJoeKQmXvuK2g4 VCH3uFgn8uy6PZHTiX0h+sPJoqpPTuyVqop+KELWO4dAUPar8whi8QKW2zXMdGG2wsrl hjvIXx/pc81D7RiWKodFnfjiDxJzWeQndISrRVdOiQom1nYd4zvaYqOpH+suUx82j4+0 rZpBQA0jtvej1mICqeVIspkpDWty3tnF+0+U5DPQDvKiUVIhBINRtnEOZNXRY3Yu4eV3 +rjHQrZ/b0D37rv6F07Tlh5iC0cTT1zqGXI5UBhIOYT1d+2MtJg6lvCZJi2YGw5LzLlZ un9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :feedback-id:references:in-reply-to:message-id:subject:cc:from:to :dkim-signature:date; bh=LbKgikniMFbDyFN2g7zWAoErWCoMlEFPq1fVjDbUYh8=; b=qHIc+tUAtK668Q5fWnVOrw2n/LY0O1UTzqDHu7h1c9DyA5q/orIrcd6xGfI9vLNC7d 17zBFUKFwU5Ike0sxlyl7AxpGa3/bixdxHJPLV7RjSG0W2uHVcZN+M7XYmF+W10DOZ2V NaJxmqMw4dv1oicknpzodJVXPI026Ri9B8LTGLWZ6cFfq6wCSVygpMvUorZWwuAAGyoX cLqtz5x33MWzrNYVki2yfMI0oRc1fbZsXkcACWmA4wCNmgrrMMi7mwhhEJmujrayePn+ y8ruCNNF8E4tvi5lr88PmO8hkh7k8fiadTQ2yqRyn8RE+Xsi2TMLFK3UbJkPZEKArYI7 1rlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@proton.me header.s=protonmail header.b=W+vrUebu; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=proton.me Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x28-20020aa79adc000000b0063d3387b4a3si4583647pfp.303.2023.04.19.05.31.59; Wed, 19 Apr 2023 05:32:14 -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=@proton.me header.s=protonmail header.b=W+vrUebu; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=proton.me Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230265AbjDSMbJ (ORCPT + 99 others); Wed, 19 Apr 2023 08:31:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230117AbjDSMbI (ORCPT ); Wed, 19 Apr 2023 08:31:08 -0400 Received: from mail-4316.protonmail.ch (mail-4316.protonmail.ch [185.70.43.16]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8705CE50 for ; Wed, 19 Apr 2023 05:31:06 -0700 (PDT) Date: Wed, 19 Apr 2023 12:30:53 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=protonmail; t=1681907464; x=1682166664; bh=LbKgikniMFbDyFN2g7zWAoErWCoMlEFPq1fVjDbUYh8=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=W+vrUebuJp1hiaq5J6Yn0guavbN34v+IU5fOapkRumgszhzjBMXFFFHcpMEbT0G4C ZXKilDurS+3o5ptA5jQS/Mt0ddLeJJBmW66gZWd/IhQLVTt/XKOrWBEDEdp25Tzi+O d9L3k23CouM0jZ6YjIHmogFZOgMjFN2oIEiAgM+FYH5osEj8L3xQ19wsYl9Vzp96KQ kih/4GNsISO83sMmwiCenYVPMcDdca1S3NCmDJGv+ATJSXKPCGJzPOyNNtSM8BPwi6 HtNPG/fSeY2uDPVpPbRM2d1B73iFMPTDYxCGPwS8TiyMojBNzdU1dYChuOMz6y7F6j pZtB11+AvOD4Q== To: Miguel Ojeda From: Benno Lossin Cc: Wedson Almeida Filho , Alex Gaynor , Boqun Feng , Gary Guo , =?utf-8?Q?Bj=C3=B6rn_Roy_Baron?= , 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: In-Reply-To: <20230418233048.335281-1-ojeda@kernel.org> References: <20230418233048.335281-1-ojeda@kernel.org> Feedback-ID: 71780778:user:proton MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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_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 19.04.23 01:30, Miguel Ojeda wrote: > Git supports a builtin Rust diff driver [1] since v2.23.0 (2019). >=20 > 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). >=20 > For instance, with the default diff driver: >=20 > @@ -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 =3D core::cmp::min(pos_new, self.end).satur= ating_sub(self.pos); >=20 > + 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 invariant= s. >=20 > With the Rust diff driver: >=20 > @@ -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 =3D core::cmp::min(pos_new, self.end).satur= ating_sub(self.pos); >=20 > + 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 invariant= s. >=20 > Thus set the `rust` diff driver for `*.rs` source files. >=20 > Link: https://git-scm.com/docs/gitattributes#_defining_a_custom_hunk_head= er [1] > Signed-off-by: Miguel Ojeda Reviewed-by: Benno Lossin > --- > .gitattributes | 1 + > 1 file changed, 1 insertion(+) >=20 > diff --git a/.gitattributes b/.gitattributes > index c9ba5bfc4036..2325c529e185 100644 > --- a/.gitattributes > +++ b/.gitattributes > @@ -2,3 +2,4 @@ > *.[ch] diff=3Dcpp > *.dts diff=3Ddts > *.dts[io] diff=3Ddts > +*.rs diff=3Drust >=20 > base-commit: 09a9639e56c01c7a00d6c0ca63f4c7c41abe075d > -- > 2.40.0 >