Re: [PATCH] Add diff directives to gitattributes

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Dagfinn Ilmari Mannsåker <ilmari(at)ilmari(dot)org>, PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] Add diff directives to gitattributes
Date: 2016-11-30 01:27:33
Message-ID: CAB7nPqRtXmEavVpyY1n+kkfWF=P2vkwfVobpRghRU83Cs37DXQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Nov 30, 2016 at 5:16 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> ilmari(at)ilmari(dot)org (Dagfinn Ilmari =?utf-8?Q?Manns=C3=A5ker?=) 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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Craig Ringer 2016-11-30 01:34:13 Re: pg_recvlogical --endpos
Previous Message Okano, Naoki 2016-11-30 01:18:32 Re: pg_recvlogical --endpos