From owner-svn-src-head@freebsd.org Mon Jul 3 15:42:24 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BBC129E9483 for ; Mon, 3 Jul 2017 15:42:24 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from nm10-vm0.bullet.mail.ne1.yahoo.com (nm10-vm0.bullet.mail.ne1.yahoo.com [98.138.91.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 87B5E75002 for ; Mon, 3 Jul 2017 15:42:24 +0000 (UTC) (envelope-from pfg@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1499096537; bh=qKJVkMhV0ERaE09WKG6Ab0HzhkNm+EDtSuE4QQwnlX8=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From:Subject; b=mC8lt6kHy/jMzoIwGFoj8KGSeH4CI6GQU//9rH6eV5ijAqi6ls/5dvhUUuevVtHCTYSglfgzcrQ0qYt8abpGrNykPhsQxf6DAe7zsQRLc0tVe5795/LRD4VLUa0xC37kPVPJPYO3CWKqOpAfhBQ2dY3cNnyvgVQEbxKR5ZjNuUmuMrlESS240/qfHZOSeXTDmOFhc0D0Xa6weR6XOq1aZmfXt8+Lx/DttAYtY5TOtJDJ+Rv6PEPu/pDmdh8X1z6VZjCmq0+TjLJJ2VI1YxUnt7YCMQOfjd1x2v4kcawod3QVqzpSvnvFocl1HAuH3cileOgwbuFGss1qrqJkTPDmaA== Received: from [98.138.226.177] by nm10.bullet.mail.ne1.yahoo.com with NNFMP; 03 Jul 2017 15:42:17 -0000 Received: from [98.138.84.47] by tm12.bullet.mail.ne1.yahoo.com with NNFMP; 03 Jul 2017 15:42:17 -0000 Received: from [127.0.0.1] by smtp115.mail.ne1.yahoo.com with NNFMP; 03 Jul 2017 15:42:17 -0000 X-Yahoo-Newman-Id: 170243.98318.bm@smtp115.mail.ne1.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: WdFjRgUVM1kLPuw95KNN4jau9362NUU.mh4HFmFX2cYs2kp 3BfzsAr1ckzxyWruThjzrb0w7U17QMG6bfzTLiCeP3Vb4V_RQ47dS30MCdB2 wZWJ7ipS8.KvU6aJdEeehprhaxfUg81WQgxeHRkUdN_s2yFy4XKbh95vWcUL 1yiDC_6O24rDHljb5gG2pFaab.grxKEssTqH5SlKuMF9FqAeWPe.515KWGbB T.890je9vRXApK1__kuuSC.lDXBKqDAUJ10Lc89aFBc4FeKkK1mxcbow3B7L ET4KhpLdDxmFFWX7HHJhE.Lw7KdYhDLfwqFUs.HFRvguKlTvpztfaLtFTU.G PitBOMV.64RrpTNIm1a_lxxNJ.n.SVRUj2SfBMHQ1dMxRJtsdU6q7qC4LIOS kGDo1mfBtigoyEjdBQjtoo9orvT9K_O42fvFA4soxYJjVN3gN8NjIIBqAwEi .nekrHc4z0c_dOGy1US7oOnYw6HdSmKe.iAFSh80wWn7QLQ6_kfD7tGcafvP JlK7lh6lgi7m.CT.gWAo- X-Yahoo-SMTP: xcjD0guswBAZaPPIbxpWwLcp9Unf Subject: Re: svn commit: r320579 - head/usr.bin/patch To: cem@freebsd.org Cc: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org References: <201707022100.v62L0Ume001253@repo.freebsd.org> From: Pedro Giffuni Organization: FreeBSD Message-ID: Date: Mon, 3 Jul 2017 10:42:15 -0500 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Jul 2017 15:42:24 -0000 Hello; On 07/02/17 21:53, Conrad Meyer wrote: > Hi Pedro, > > Does this change the behavior of 'patch -p1' (for example) with 'git > diff' generated diffs? So patches that could be applied with -p1 > before now need to be applied with -p0? Or is this a different mode > of patch? Thanks for pointing this out. This doesn't change the meaning of the patch level so previous behavior is not affected. In fact using patch -p1 still patches the file. The behavior is consistent with some incipient path detection we have on CVS files. No problem AFAICT. > If so, that's a somewhat surprising change in behavior. Does GNU > patch have the same behavior? I did some testing on {g}patch. GNU patch indeed has a different behavior and requires -p1 on such diffs. IMHO, the (new) BSD patch behavior is somewhat more natural in the sense that no one asked git to add a prefix to the path so it makes sense to ignore it. Recent GNU patch does support many git-specific features that we don't. Pedro. > Thanks, > Conrad > > On Sun, Jul 2, 2017 at 2:00 PM, Pedro F. Giffuni wrote: >> Author: pfg >> Date: Sun Jul 2 21:00:30 2017 >> New Revision: 320579 >> URL: https://svnweb.freebsd.org/changeset/base/320579 >> >> Log: >> patch(1): add support for git generated diffs. >> >> Sometimes patches coming from other places have extra a/ and b/ >> directories prepended to filenames. >> >> Obtained from: OpenBSD (CVS rev. 1.57, 1.58) >> >> Modified: >> head/usr.bin/patch/pch.c >> >> Modified: head/usr.bin/patch/pch.c >> ============================================================================== >> --- head/usr.bin/patch/pch.c Sun Jul 2 20:47:25 2017 (r320578) >> +++ head/usr.bin/patch/pch.c Sun Jul 2 21:00:30 2017 (r320579) >> @@ -264,6 +264,7 @@ intuit_diff_type(void) >> char *s, *t; >> int indent, retval; >> struct file_name names[MAX_FILE]; >> + int piece_of_git = 0; >> >> memset(names, 0, sizeof(names)); >> ok_to_create_file = false; >> @@ -308,14 +309,20 @@ intuit_diff_type(void) >> if (!stars_last_line && strnEQ(s, "*** ", 4)) >> names[OLD_FILE].path = fetchname(s + 4, >> &names[OLD_FILE].exists, strippath); >> - else if (strnEQ(s, "--- ", 4)) >> - names[NEW_FILE].path = fetchname(s + 4, >> + else if (strnEQ(s, "--- ", 4)) { >> + size_t off = 4; >> + if (piece_of_git && strippath == 957) >> + off = 6; >> + names[NEW_FILE].path = fetchname(s + off, >> &names[NEW_FILE].exists, strippath); >> - else if (strnEQ(s, "+++ ", 4)) >> + } else if (strnEQ(s, "+++ ", 4)) { >> /* pretend it is the old name */ >> - names[OLD_FILE].path = fetchname(s + 4, >> + size_t off = 4; >> + if (piece_of_git && strippath == 957) >> + off = 6; >> + names[OLD_FILE].path = fetchname(s + off, >> &names[OLD_FILE].exists, strippath); >> - else if (strnEQ(s, "Index:", 6)) >> + } else if (strnEQ(s, "Index:", 6)) >> names[INDEX_FILE].path = fetchname(s + 6, >> &names[INDEX_FILE].exists, strippath); >> else if (strnEQ(s, "Prereq:", 7)) { >> @@ -330,6 +337,9 @@ intuit_diff_type(void) >> free(revision); >> revision = NULL; >> } >> + } else if (strnEQ(s, "diff --git a/", 13)) { >> + /* Git-style diffs. */ >> + piece_of_git = 1; >> } else if (strnEQ(s, "==== ", 5)) { >> /* Perforce-style diffs. */ >> if ((t = strstr(s + 5, " - ")) != NULL) >>