From kbyanc@kronos.alcnet.com  Sun Jul  2 04:38:22 2000
Return-Path: <kbyanc@kronos.alcnet.com>
Received: from kronos.networkrichmond.com (kronos.networkrichmond.com [64.240.180.22])
	by hub.freebsd.org (Postfix) with ESMTP id 989F137BBFD
	for <FreeBSD-gnats-submit@freebsd.org>; Sun,  2 Jul 2000 04:38:21 -0700 (PDT)
	(envelope-from kbyanc@kronos.alcnet.com)
Received: from vaio (c1096725-a.smateo1.sfba.home.com [24.20.139.104])
	by kronos.networkrichmond.com (8.9.3/8.9.3/antispam) with ESMTP id HAA61108
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 2 Jul 2000 07:38:19 -0400 (EDT)
Received: (from kbyanc@localhost)
	by vaio (8.9.3/8.9.3) id EAA88314;
	Sun, 2 Jul 2000 04:41:11 -0700 (PDT)
	(envelope-from kbyanc@mail.posi.net)
Message-Id: <200007021141.EAA88314@vaio>
Date: Sun, 2 Jul 2000 04:41:11 -0700 (PDT)
From: kbyanc@posi.net
Sender: kbyanc@kronos.alcnet.com
Reply-To: kbyanc@posi.net
To: FreeBSD-gnats-submit@freebsd.org
Subject: patch's --skip/-S option doesn't skip when target doesn't exist
X-Send-Pr-Version: 3.2

>Number:         19638
>Category:       gnu
>Synopsis:       patch's --skip/-S option doesn't skip when target doesn't exist
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kbyanc
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Jul 02 04:40:04 PDT 2000
>Closed-Date:    Tue Aug 1 23:56:56 PDT 2000
>Last-Modified:  Tue Aug 01 23:57:25 PDT 2000
>Originator:     Kelly Yancey
>Release:        FreeBSD 5.0-CURRENT i386
>Organization:
>Environment:

FreeBSD backroom.corp.ONElist.com 5.0-CURRENT FreeBSD 5.0-CURRENT #1: Fri
Jun 30 13:47:43 PDT 2000
root@backroom.corp.ONElist.com:/usr/src/sys/compile/BACKROOM  i386
 
>Description:

	patch (as found in /usr/src/gnu/usr.bin/patch) does not honor -S
	(--skip) parameter when the target of the patchfile to skip does not
	exist. For example, if you used a command line such as:
		patch -p1 + -p2 + -S < my.diff
	to skip the third patchfile in the set, patch will prompt for the
	name of the file to patch (because it doesn't exist), even though
	it is to skip it.

	This patch addresses the issue on the simplest level. It still
	writes the 'skipped' patchfile out as a reject file (always named
	'Oops.rej' since the target filename doesn't exist). It is
	debatable as to whether writing the reject file is correct for a
	skipped patch.

	-Kelly

>How-To-Repeat:

	$ echo "this is a test" > file-a
	$ echo "this is another test" > file-b
	$ diff file-a file-b > diff-ab
	$ rm file-b
	$ patch -S < diff-ab

>Fix:

cvs diff: Diffing gnu/usr.bin/patch/
Index: gnu/usr.bin/patch//pch.c
===================================================================
RCS file: /home/cvs/src/gnu/usr.bin/patch/pch.c,v
retrieving revision 1.16
diff -u -r1.16 pch.c
--- gnu/usr.bin/patch//pch.c    1999/09/05 17:31:55     1.16
+++ gnu/usr.bin/patch//pch.c    2000/07/02 11:10:28
@@ -173,7 +173,7 @@
     if (p_indent && verbose)
 	say3("(Patch is indented %d space%s.)\n", p_indent, p_indent==1?"":"s");
     skip_to(p_start,p_sline);
-    while (filearg[0] == Nullch) {
+    while (!skip_rest_of_patch && filearg[0] == Nullch) {
 	if (force || batch) {
 	    say1("No file to patch.  Skipping...\n");
 	    filearg[0] = savestr(bestguess);


>Release-Note:
>Audit-Trail:

From: Kelly Yancey <kbyanc@posi.net>
To: freebsd-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: gnu/19638: patch's --skip/-S option doesn't skip when target
 doesn't exist
Date: Sat, 8 Jul 2000 18:06:19 -0700 (PDT)

   -f/--force will skip files that do not exist. Arguably, the solution is to
 just accect the -s/--skip behaviour and use -f instead. I assert that this PR
 still stands as -s/--skip should skip a patch whether the file that would
 have been changed exists or not.
 
   Kelly
 
 --
 Kelly Yancey  -  kbyanc@posi.net  -  Belmont, CA
 System Administrator, eGroups.com                  http://www.egroups.com/
 Maintainer, BSD Driver Database       http://www.posi.net/freebsd/drivers/
 Coordinator, Team FreeBSD        http://www.posi.net/freebsd/Team-FreeBSD/
 
 
Responsible-Changed-From-To: freebsd-bugs->kbyanc 
Responsible-Changed-By: kbyanc 
Responsible-Changed-When: Tue Aug 1 22:04:47 PDT 2000 
Responsible-Changed-Why:  
Taking my own PR. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=19638 
State-Changed-From-To: open->closed 
State-Changed-By: kbyanc 
State-Changed-When: Tue Aug 1 23:56:56 PDT 2000 
State-Changed-Why:  
Committed. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=19638 
>Unformatted:
