Re: git apply vs patch -p1

Lists: pgsql-hackers
From: Josh Berkus <josh(at)agliodbs(dot)com>
To: PG Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: git apply vs patch -p1
Date: 2013-09-14 18:37:33
Message-ID: 5234ACED.7070403@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Folks,

Lately I've been running into a lot of reports of false conflicts
reported by "git apply". The most recent one was the "points" patch,
which git apply rejected for completely ficticious reasons (it claimed
that the patch was trying to create a new file where a file already
existed, which it wasn't).

I think we should modify the patch review and developer instructions to
recommend always using patch -p1 (or -p0, depending), even if the patch
was produced with "git diff".

Thoughts?

--
Josh Berkus
PostgreSQL Experts Inc.
http://pgexperts.com


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Josh Berkus <josh(at)agliodbs(dot)com>
Cc: PG Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: git apply vs patch -p1
Date: 2013-09-14 19:03:52
Message-ID: 5234B318.5020406@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


On 09/14/2013 02:37 PM, Josh Berkus wrote:
> Folks,
>
> Lately I've been running into a lot of reports of false conflicts
> reported by "git apply". The most recent one was the "points" patch,
> which git apply rejected for completely ficticious reasons (it claimed
> that the patch was trying to create a new file where a file already
> existed, which it wasn't).
>
> I think we should modify the patch review and developer instructions to
> recommend always using patch -p1 (or -p0, depending), even if the patch
> was produced with "git diff".
>
> Thoughts?
>

FWIW that's what I invariably use.

You do have to be careful to git-add/git-rm any added/deleted files,
which git-apply does for you (as well as renames) - I've been caught by
that a couple of times.

cheers

andrew


From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: Josh Berkus <josh(at)agliodbs(dot)com>, PG Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: git apply vs patch -p1
Date: 2013-09-14 19:08:19
Message-ID: 20130914190819.GB2291@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2013-09-14 15:03:52 -0400, Andrew Dunstan wrote:
>
> On 09/14/2013 02:37 PM, Josh Berkus wrote:
> >Folks,
> >
> >Lately I've been running into a lot of reports of false conflicts
> >reported by "git apply". The most recent one was the "points" patch,
> >which git apply rejected for completely ficticious reasons (it claimed
> >that the patch was trying to create a new file where a file already
> >existed, which it wasn't).
> >
> >I think we should modify the patch review and developer instructions to
> >recommend always using patch -p1 (or -p0, depending), even if the patch
> >was produced with "git diff".
> >
> >Thoughts?
> >
>
>
> FWIW that's what I invariably use.
>
> You do have to be careful to git-add/git-rm any added/deleted files, which
> git-apply does for you (as well as renames) - I've been caught by that a
> couple of times.

git reset?

Greetings,

Andres Freund

--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: Josh Berkus <josh(at)agliodbs(dot)com>, PG Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: git apply vs patch -p1
Date: 2013-09-14 20:00:09
Message-ID: 5234C049.8050700@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


On 09/14/2013 03:08 PM, Andres Freund wrote:
> On 2013-09-14 15:03:52 -0400, Andrew Dunstan wrote:
>> On 09/14/2013 02:37 PM, Josh Berkus wrote:
>>> Folks,
>>>
>>> Lately I've been running into a lot of reports of false conflicts
>>> reported by "git apply". The most recent one was the "points" patch,
>>> which git apply rejected for completely ficticious reasons (it claimed
>>> that the patch was trying to create a new file where a file already
>>> existed, which it wasn't).
>>>
>>> I think we should modify the patch review and developer instructions to
>>> recommend always using patch -p1 (or -p0, depending), even if the patch
>>> was produced with "git diff".
>>>
>>> Thoughts?
>>>
>>
>> FWIW that's what I invariably use.
>>
>> You do have to be careful to git-add/git-rm any added/deleted files, which
>> git-apply does for you (as well as renames) - I've been caught by that a
>> couple of times.
> git reset?
>
>

Yes, of course you can roll back as long as you haven't published your
commits. But it's a nuisance.

cheers

andrew


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Josh Berkus <josh(at)agliodbs(dot)com>
Cc: PG Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: git apply vs patch -p1
Date: 2013-09-15 05:01:18
Message-ID: 1379221278.10763.3.camel@vanquo.pezone.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sat, 2013-09-14 at 11:37 -0700, Josh Berkus wrote:
> Lately I've been running into a lot of reports of false conflicts
> reported by "git apply". The most recent one was the "points" patch,
> which git apply rejected for completely ficticious reasons (it claimed
> that the patch was trying to create a new file where a file already
> existed, which it wasn't)

Every file in that patch contains

new file mode 100644

which means it is creating a new file. I would review how that patch
was created.


From: Ashutosh Bapat <ashutosh(dot)bapat(at)enterprisedb(dot)com>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Josh Berkus <josh(at)agliodbs(dot)com>, PG Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: git apply vs patch -p1
Date: 2013-09-16 04:46:37
Message-ID: CAFjFpRcDuoD_Tf9Syu=y6yVwhkLT6p+RtrE336hY5-GDbJW2qA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sun, Sep 15, 2013 at 12:38 AM, Andres Freund <andres(at)2ndquadrant(dot)com>wrote:

> On 2013-09-14 15:03:52 -0400, Andrew Dunstan wrote:
> >
> > On 09/14/2013 02:37 PM, Josh Berkus wrote:
> > >Folks,
> > >
> > >Lately I've been running into a lot of reports of false conflicts
> > >reported by "git apply". The most recent one was the "points" patch,
> > >which git apply rejected for completely ficticious reasons (it claimed
> > >that the patch was trying to create a new file where a file already
> > >existed, which it wasn't).
> > >
> > >I think we should modify the patch review and developer instructions to
> > >recommend always using patch -p1 (or -p0, depending), even if the patch
> > >was produced with "git diff".
> > >
> > >Thoughts?
> > >
> >
> >
> > FWIW that's what I invariably use.
> >
> > You do have to be careful to git-add/git-rm any added/deleted files,
> which
> > git-apply does for you (as well as renames) - I've been caught by that a
> > couple of times.
>
> git reset?
>
>
git reset wouldn't remove the files that were newly added by the patch,
would it?

> Greetings,
>
> Andres Freund
>
> --
> Andres Freund http://www.2ndQuadrant.com/
> PostgreSQL Development, 24x7 Support, Training & Services
>
>
> --
> Sent via pgsql-hackers mailing list (pgsql-hackers(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers
>

--
Best Wishes,
Ashutosh Bapat
EnterpriseDB Corporation
The Postgres Database Company


From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Ashutosh Bapat <ashutosh(dot)bapat(at)enterprisedb(dot)com>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Josh Berkus <josh(at)agliodbs(dot)com>, PG Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: git apply vs patch -p1
Date: 2013-09-16 10:23:38
Message-ID: 20130916102338.GL1330627@alap2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2013-09-16 10:16:37 +0530, Ashutosh Bapat wrote:
> On Sun, Sep 15, 2013 at 12:38 AM, Andres Freund <andres(at)2ndquadrant(dot)com>wrote:
>
> > On 2013-09-14 15:03:52 -0400, Andrew Dunstan wrote:
> > >
> > > On 09/14/2013 02:37 PM, Josh Berkus wrote:
> > > >Folks,
> > > >
> > > >Lately I've been running into a lot of reports of false conflicts
> > > >reported by "git apply". The most recent one was the "points" patch,
> > > >which git apply rejected for completely ficticious reasons (it claimed
> > > >that the patch was trying to create a new file where a file already
> > > >existed, which it wasn't).
> > > >
> > > >I think we should modify the patch review and developer instructions to
> > > >recommend always using patch -p1 (or -p0, depending), even if the patch
> > > >was produced with "git diff".
> > > >
> > > >Thoughts?
> > > >
> > >
> > >
> > > FWIW that's what I invariably use.
> > >
> > > You do have to be careful to git-add/git-rm any added/deleted files,
> > which
> > > git-apply does for you (as well as renames) - I've been caught by that a
> > > couple of times.
> >
> > git reset?
> >
> >
> git reset wouldn't remove the files that were newly added by the patch,
> would it?

Depends on how you do it. I simply commit patches I look at - then they
can easily be removed using git reset --hard HEAD^. And it allows to
make further changes/annotations during review that are clearly
separated from the patch.

Greetings,

Andres Freund

--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services


From: Josh Berkus <josh(at)agliodbs(dot)com>
To: Ashutosh Bapat <ashutosh(dot)bapat(at)enterprisedb(dot)com>
Cc: Andres Freund <andres(at)2ndquadrant(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>, PG Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: git apply vs patch -p1
Date: 2013-09-16 19:06:57
Message-ID: 523756D1.7080303@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 09/15/2013 11:46 PM, Ashutosh Bapat wrote:
> On Sun, Sep 15, 2013 at 12:38 AM, Andres Freund <andres(at)2ndquadrant(dot)com>wrote:
>> git reset?
>>
>>
> git reset wouldn't remove the files that were newly added by the patch,
> would it?

The issue isn't that, it's that git apply is just buggy and can't tell
the difference between a new file and a modified one.

The "points" patch contained no new files, just modifications. But for
some reason, git apply read it as being all new files, which failed.

"patch -p1" worked fine.

--
Josh Berkus
PostgreSQL Experts Inc.
http://pgexperts.com


From: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>
To: Josh Berkus <josh(at)agliodbs(dot)com>
Cc: Ashutosh Bapat <ashutosh(dot)bapat(at)enterprisedb(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, PG Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: git apply vs patch -p1
Date: 2013-09-16 19:11:29
Message-ID: 8738p47feh.fsf@news-spur.riddles.org.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

>>>>> "Josh" == Josh Berkus <josh(at)agliodbs(dot)com> writes:

Josh> The issue isn't that, it's that git apply is just buggy and
Josh> can't tell the difference between a new file and a modified
Josh> one.

It's not the fault of git apply; the patch contained explicit
annotations on all the files claiming that they were new. Both the
patches I've looked at so far (picksplit NaNs and enable_material)
had the same defect.

The question is, how are these submitters preparing their patches?

--
Andrew (irc:RhodiumToad)


From: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
To: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>
Cc: Josh Berkus <josh(at)agliodbs(dot)com>, Ashutosh Bapat <ashutosh(dot)bapat(at)enterprisedb(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, PG Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: git apply vs patch -p1
Date: 2013-09-16 19:55:09
Message-ID: CAMkU=1wJ+RGubfv5QCzz2R4PvfR2SW6xY+JfeLje+4jj6zX05g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Sep 16, 2013 at 12:11 PM, Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk
> wrote:

> >>>>> "Josh" == Josh Berkus <josh(at)agliodbs(dot)com> writes:
>
> Josh> The issue isn't that, it's that git apply is just buggy and
> Josh> can't tell the difference between a new file and a modified
> Josh> one.
>
> It's not the fault of git apply; the patch contained explicit
> annotations on all the files claiming that they were new. Both the
> patches I've looked at so far (picksplit NaNs and enable_material)
> had the same defect.
>
> The question is, how are these submitters preparing their patches?
>

I used "git diff" configured to use src/tools/git-external-diff, as
described here:

http://wiki.postgresql.org/wiki/Working_with_Git

The resulting patch applies fine with patch, but not with git apply.

If I instead generate a patch with git diff --no-ext-diff, then it applies
with git apply.

Cheers,

Jeff


From: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>
To: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
Cc: Josh Berkus <josh(at)agliodbs(dot)com>, Ashutosh Bapat <ashutosh(dot)bapat(at)enterprisedb(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, PG Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: git apply vs patch -p1
Date: 2013-09-16 21:10:16
Message-ID: 87k3ig5vhh.fsf@news-spur.riddles.org.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

>>>>> "Jeff" == Jeff Janes <jeff(dot)janes(at)gmail(dot)com> writes:

Jeff> I used "git diff" configured to use
Jeff> src/tools/git-external-diff, as described here:

hmm...

so that git-external-diff script is trying to fake git diff output,
including using 'diff -git' and index lines, but the context-diff
output wouldn't work with git apply even if the header lines were
correct (as far as I can see git apply accepts only git's unified-diff
format - the git people clearly have no truck with context diffs).

--
Andrew (irc:RhodiumToad)