From owner-svn-src-head@freebsd.org Mon Jul 3 02:53:04 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 83B6A9DC16F; Mon, 3 Jul 2017 02:53:04 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: from mail-pg0-f50.google.com (mail-pg0-f50.google.com [74.125.83.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4F1E97EA2D; Mon, 3 Jul 2017 02:53:04 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: by mail-pg0-f50.google.com with SMTP id k14so12104718pgr.0; Sun, 02 Jul 2017 19:53:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:reply-to:in-reply-to:references :from:date:message-id:subject:to:cc; bh=rJHkEmrudPVrfwQj1Oh6IzAGAKT2AKaa4yq7IynEAeU=; b=k2CVCtltk4aVuO/MTnWAnxPAUjrTvMuGscaxDJjluUIiix37V/BHnpehZj7e3PBOu5 axH1HOXjfA+JlpORCEJWiIiOeb1g1zNYaw/3NDxGnt8st8RhNKEz9w6oy8K+s1FgJZYi akQ4cR0s/66Giaimqj4W4iJ+BrHTT9Lw8D9Ds5Qre24cftx9i6RaNyVAyaJs/4KsDPTr Q0g1rkBm1MoOlDPhl8DPU3I8wZ0WG4tc1pnd9xCVLhevut5CJ5XxoAtlzR4hmTcpsuAK Y/ALdL9AEzPUNb9TArvbY+Vc5htDmN6SMJB4GqY5s8MChza9PLmWqORZA40It0dHGzQQ IOjg== X-Gm-Message-State: AIVw1112ReZuHR2Y0Qb4+/7xfKUl8PzWL/In9Ise+VEQPTAqKT/i+sgb QCS2pll5ybmO0A08vaM= X-Received: by 10.98.103.18 with SMTP id b18mr7732553pfc.171.1499050383135; Sun, 02 Jul 2017 19:53:03 -0700 (PDT) Received: from mail-pg0-f44.google.com (mail-pg0-f44.google.com. [74.125.83.44]) by smtp.gmail.com with ESMTPSA id s88sm28373669pfk.16.2017.07.02.19.53.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 02 Jul 2017 19:53:03 -0700 (PDT) Received: by mail-pg0-f44.google.com with SMTP id u62so87843482pgb.3; Sun, 02 Jul 2017 19:53:03 -0700 (PDT) X-Received: by 10.98.200.27 with SMTP id z27mr7664563pff.136.1499050382845; Sun, 02 Jul 2017 19:53:02 -0700 (PDT) MIME-Version: 1.0 Reply-To: cem@freebsd.org Received: by 10.100.163.172 with HTTP; Sun, 2 Jul 2017 19:53:02 -0700 (PDT) In-Reply-To: <201707022100.v62L0Ume001253@repo.freebsd.org> References: <201707022100.v62L0Ume001253@repo.freebsd.org> From: Conrad Meyer Date: Sun, 2 Jul 2017 19:53:02 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r320579 - head/usr.bin/patch To: "Pedro F. Giffuni" Cc: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" 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 02:53:04 -0000 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? If so, that's a somewhat surprising change in behavior. Does GNU patch have the same behavior? 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) >