unified vs context diffs (was Re: Strange Windows problem, lock_timeout test request)

From: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: Boszormenyi Zoltan <zb(at)cybertec(dot)at>, Stephen Frost <sfrost(at)snowman(dot)net>, Hari Babu <haribabu(dot)kommi(at)huawei(dot)com>, 'Craig Ringer' <craig(at)2ndQuadrant(dot)com>, 'Hans-Jürgen Schönig' <hs(at)cybertec(dot)at>, 'Ants Aasma' <ants(at)cybertec(dot)at>, 'Tom Lane' <tgl(at)sss(dot)pgh(dot)pa(dot)us>, 'PostgreSQL Hackers' <pgsql-hackers(at)postgresql(dot)org>, 'Amit kapila' <amit(dot)kapila(at)huawei(dot)com>
Subject: unified vs context diffs (was Re: Strange Windows problem, lock_timeout test request)
Date: 2013-02-24 08:44:54
Message-ID: 5129D306.5010804@vmware.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 24.02.2013 05:07, Andrew Dunstan wrote:
> On 02/23/2013 01:15 PM, Boszormenyi Zoltan wrote:
>>>
>>> First off, it's not in context diff format, which is the PG standard for
>>> patch submission.
>>
>> Since moving to GIT, this expectation is obsolete. All PG hackers
>> became comfortable with the unified diff format, see references
>> from the list. A lot of hackers post "git diff" patches which cannot
>> produce context diff, either.
>
> I am not aware that project policy has changed in the slightest in this
> regard.

I can't speak for others, but I personally don't care whether a patch is
posted in unified or context diff format. Not as a general rule, anyway;
patches that modify a few lines here and there are generally more
readable in unified format, as the old and new lines are lined up right
next to each other:

@@ -329,7 +346,7 @@ foreign_expr_walker(Node *node, foreign_expr_cxt
*context)
static bool
is_builtin(Oid oid)
{
- return (oid < FirstNormalObjectId);
+ return (oid < FirstBootstrapObjectId);
}

Then again, more complicated patches that modify large chunks of code
are often unreadable when the - and + lines are mixed up in the same
chunk; those are more readable in context format.

So if you want to be kind to readers, look at the patch and choose the
format depending on which one makes it look better. But there's no need
to make a point of it when someone posts in "wrong" format.

> Every unified diff can be turned into a context diff by passing it
> though "filterdiff --format=context".

Yep. And in emacs, there's "diff-unified->context" command. I bet most
editors have a similar functionality these days.

- Heikki

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alban Hertroys 2013-02-24 11:52:16 Re: autoanalyze criteria
Previous Message Boszormenyi Zoltan 2013-02-24 08:27:01 Re: Strange Windows problem, lock_timeout test request