[PATCH] Add diff directives to gitattributes

Started by Dagfinn Ilmari Mannsåkerover 9 years ago3 messageshackers
Jump to latest

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.

Attachments:

0001-Add-diff-directives-to-.gitattributes.patchtext/x-diffDownload+4-5
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Dagfinn Ilmari Mannsåker (#1)
Re: [PATCH] Add diff directives to gitattributes

ilmari@ilmari.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?

regards, tom lane

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#3Michael Paquier
michael@paquier.xyz
In reply to: Tom Lane (#2)
Re: [PATCH] Add diff directives to gitattributes

On Wed, Nov 30, 2016 at 5:16 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

ilmari@ilmari.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
--
Michael

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers