Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp8477rwe; Tue, 18 Apr 2023 16:33:48 -0700 (PDT) X-Google-Smtp-Source: AKy350ZRBhNrb4ADcpzVWJKIsNW0VrvuBUuXW4+A6FD8yNl8e4eXisGoQHOupK9t61p0MD2D0Krw X-Received: by 2002:a17:902:dacf:b0:1a6:669f:18ae with SMTP id q15-20020a170902dacf00b001a6669f18aemr3721140plx.67.1681860828210; Tue, 18 Apr 2023 16:33:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681860828; cv=none; d=google.com; s=arc-20160816; b=Sg9+B4YdePYDk4m7xQHZd+GEJJM2v/7kmF820UUOlIseLCYE9O6LvFb2+9hyipR99N XV+UWooSKsPa1oc1PCbJnBAT0W24/TxmwizA0oirBffg/OFuvzzPe9OlXuVF+MUfcUip QNIFRA/hvRj9od7EW83x3lEWPcJoQToEXN9qiY6r3gNgckDQlzYPmR2o5CblJ7zwQsEc Fg2oqagVQgYm32qYBQTNe4HTTrFTjE/o3BuYcxZv1zgPobQg5X0kYugSC9vP7YeMmyeY NLythV8/6CltfG7k5NogLXBhxoFaq5RGw2JdeJdvK/L+rvbbOdV19uU0SeHUnFf1H8u6 zB8Q== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=PhglwvWlSgthDlHIkB+MKZrf0HFSOExgD2fCy5cvMKk=; b=0uEQwjPszrawANFAzC6SEeMMUrQ70QErPJvfavfnfxVjpQndtewe3yP54aVerKL1bX Z4JRoTKtoNb9JPHo/UX9IrVNrPSu6roJ0uQ5O3z0zdXS+uAn44OYPsLf5HTeeFzNC+GD OxgiTB/cGDTpsSUm0P6NJfo95HoeSpU2m54doIEDAMQj1swdsKrxHOIargGLNFJfV1BO 9bViGmJcpsaf6m3qWEdVh8EP0KnoK/LIkjMOX10f/M2msYwMQ5K+rICylGW+UGmUvSgs 6Yyl4ObGeRXVjBP5xgHCpBl8dclwbiTzI8tX8KiC1l1Db8UBQCJmX7xGzsT1FkkFzMA6 t+oA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kHUv3Wsq; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u6-20020a170902e80600b001967d895ce0si15980922plg.213.2023.04.18.16.33.34; Tue, 18 Apr 2023 16:33:48 -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=@kernel.org header.s=k20201202 header.b=kHUv3Wsq; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231256AbjDRXbv (ORCPT + 99 others); Tue, 18 Apr 2023 19:31:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229750AbjDRXbu (ORCPT ); Tue, 18 Apr 2023 19:31:50 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EED8776B6; Tue, 18 Apr 2023 16:31:36 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8A58C62F93; Tue, 18 Apr 2023 23:31:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1734BC433EF; Tue, 18 Apr 2023 23:31:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681860696; bh=dXrs6HEsN21LvkE2B3upLi4G+i29wmCt/lPdjsvXpGI=; h=From:To:Cc:Subject:Date:From; b=kHUv3WsqPqzTUjKZj5daYdXJVOeGYPfR+HG/1Ev5CEQ8LdaBAskFK4XARG+8WHt/l GRshbswOxIG769iM5hqnzpq+Me6XxQeuva7mJ4pTq26GfkqPkePob7eqP4FjCFoGKj YVreXt3MhxRSydf5g8/5BTs4qeLw+dStiJ4bxqgBZehB3XlYIduJUmcsj0fLs2YxKs 8zM7imnjJv5k5PVMlIrKpk2CRnIf3UhYDigJQ1XRnUJXxBvLly+IlibqKRWYDZDLEA P4yKAZZu33mYQriE3r4DblTGy29Q6smgowNEh7YCYmBkJBZ91sSGahWyPJPFjW+p2g cko7jlNtKcWhg== From: Miguel Ojeda To: Miguel Ojeda , Wedson Almeida Filho , Alex Gaynor Cc: Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Benno Lossin , Masahiro Yamada , Stephen Boyd , Jean Delvare , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev Subject: [PATCH] .gitattributes: set diff driver for Rust source code files Date: Wed, 19 Apr 2023 01:30:48 +0200 Message-Id: <20230418233048.335281-1-ojeda@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,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 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 --- .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 -- 2.40.0