[PATCH] Add diff directives to gitattributes
[PATCH] Add diff directives to gitattributes
От:
ilmari@ilmari.org (Dagfinn Ilmari Mannsåker)
Дата:
Hi hackers, Attached is a patch which adds diff= directives to .gitattributes for C, Perl and (X|SG)ML files. This makes word diffs and the function indicator in the diff chunk header and more useful. >From 57d7d4ec5b94783bf68b2959128e33c28547a6b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dagfinn=20Ilmari=20Manns=C3=A5ker?= Date: Tue, 29 Nov 2016 19:47:36 +0000 Subject: [PATCH] Add diff directives to .gitattributes This makes the function indicator in the diff chunk header and word diffs more useful for the specified languages. --- .gitattributes | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitattributes b/.gitattributes index 4dfc131..3805f90 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,11 +1,11 @@ * whitespace=space-before-tab,trailing-space -*.[chly] whitespace=space-before-tab,trailing-space,indent-with-non-tab,tabwidth=4 +*.[chly] whitespace=space-before-tab,trailing-space,indent-with-non-tab,tabwidth=4 diff=cpp *.dsl whitespace=space-before-tab,trailing-space,tab-in-indent *.patch -whitespace -*.pl whitespace=space-before-tab,trailing-space,tabwidth=4 +*.pl whitespace=space-before-tab,trailing-space,tabwidth=4 diff=perl *.po whitespace=space-before-tab,trailing-space,tab-in-indent,-blank-at-eof -*.sgml whitespace=space-before-tab,trailing-space,tab-in-indent,-blank-at-eol -*.x[ms]l whitespace=space-before-tab,trailing-space,tab-in-indent +*.sgml whitespace=space-before-tab,trailing-space,tab-in-indent,-blank-at-eol diff=html +*.x[ms]l whitespace=space-before-tab,trailing-space,tab-in-indent diff=html # Avoid confusing ASCII underlines with leftover merge conflict markers README conflict-marker-size=32 -- 2.7.4 -- "A disappointingly low fraction of the human race is, at any given time, on fire." - Stig Sandbeck Mathisen
Re: [PATCH] Add diff directives to gitattributes
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
ilmari@ilmari.org (Dagfinn Ilmari Mannsåker) writes: > Attached is a patch which adds diff= directives to .gitattributes for C, > Perl and (X|SG)ML files. This makes word diffs and the function > indicator in the diff chunk header and more useful. Could you provide some examples of what that actually does to the output? regards, tom lane
Re: [PATCH] Add diff directives to gitattributes
От:
Michael Paquier <michael.paquier@gmail.com>
Дата:
On Wed, Nov 30, 2016 at 5:16 AM, Tom Lane wrote:
> ilmari@ilmari.org (Dagfinn Ilmari Mannsåker) writes:
>> Attached is a patch which adds diff= directives to .gitattributes for C,
>> Perl and (X|SG)ML files. This makes word diffs and the function
>> indicator in the diff chunk header and more useful.
>
> Could you provide some examples of what that actually does to the output?
Per the git documentation [1], this is aimed at making the hunk
headers in a diff output more readable. For example, take this dummy
patch on a perl file:
diff --git a/src/bin/pg_rewind/t/001_basic.pl b/src/bin/pg_rewind/t/001_basic.pl
index 1764b17..729bc6d 100644
--- a/src/bin/pg_rewind/t/001_basic.pl
+++ b/src/bin/pg_rewind/t/001_basic.pl
@@ -5,6 +5,13 @@ use Test::More tests => 8;
use RewindTest;
+sub run_test2
+{
+ my $test_mode = shift;
+
+ master_sql();
+}
+sub run_test{ my $test_mode = shift;
The point to focus on is that, which is what you get on HEAD:
@@ -5,6 +5,13 @@ use Test::More tests => 8;
But what you get with this patch is that:
@@ -5,6 +5,13 @@
So this makes the detection of a subroutine being changed by a diff
more intelligent.
With or without this patch, for example I patch a subroutine I am
still getting that for both cases:
@@ -30,6 +37,10 @@ sub run_test
And as far as I can read from the docs, it is perfectly possible to
set up that at a global level with a dedicated section like [diff
"perl"]. And in short, this is a change to decide if we decide to
still rely on GNU diff -p or on what git decides is good. Honestly I
am -1 to enforce that to everybody doing serious hacking.
[1]: https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html
--
Michael