NetBSD Problem Report #47367

From dholland@macaran.localdomain  Thu Dec 27 02:00:57 2012
Return-Path: <dholland@macaran.localdomain>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	by www.NetBSD.org (Postfix) with ESMTP id 0CF8D63D82E
	for <gnats-bugs@gnats.NetBSD.org>; Thu, 27 Dec 2012 02:00:57 +0000 (UTC)
Message-Id: <20121227020128.782496E239@macaran.localdomain>
Date: Wed, 26 Dec 2012 21:01:28 -0500 (EST)
From: dholland@eecs.harvard.edu
Reply-To: dholland@eecs.harvard.edu
To: gnats-bugs@gnats.NetBSD.org
Subject: patch(1) mishandles Oops.rej
X-Send-Pr-Version: 3.95

>Number:         47367
>Category:       bin
>Synopsis:       patch(1) mishandles Oops.rej
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Dec 27 02:05:00 +0000 2012
>Originator:     David A. Holland
>Release:        NetBSD 6.99.11 (20120906)
>Organization:
>Environment:
System: NetBSD macaran 6.99.11 NetBSD 6.99.11 (MACARAN) #15: Mon Oct 15 21:24:31 EDT 2012 dholland@macaran:/usr/src/sys/arch/amd64/compile/MACARAN amd64
Architecture: x86_64
Machine: amd64
/usr/bin/patch:
     $NetBSD: patch.c,v 1.29 2011/09/06 18:25:14 joerg Exp $
     $NetBSD: pch.c,v 1.24 2011/09/06 18:25:14 joerg Exp $
     $NetBSD: inp.c,v 1.23 2009/10/21 17:16:11 joerg Exp $
     $NetBSD: util.c,v 1.26 2010/10/02 19:31:14 wiz Exp $
     $NetBSD: backupfile.c,v 1.14 2008/09/19 18:33:34 joerg Exp $
     $NetBSD: mkpath.c,v 1.1 2008/09/19 18:33:34 joerg Exp $

>Description:

If you try to patch a file that doesn't exist, and attempt to continue
instead of ^Cing out, patch goes

   File to patch: 
   No file found--skip this patch? [n] y
   Skipping patch...
   Hunk #1 ignored at 64.
   Hunk #2 ignored at 99.
   Hunk #3 ignored at 133.
   3 out of 3 hunks ignored--saving rejects to Oops.rej

...but it truncates Oops.rej for each missing file, so you lose most
of the patch.

The output Oops.rej file also doesn't have a patch header, so you
can't tell where it was supposed to go.

>How-To-Repeat:

Pick your favorite pkgsrc package with a bunch of patches, then do

	mkdir foo
	cd foo
	tar -xvzf ../../../distfiles/thingy-1.0.tar.gz
	cd thingy-1.0
	cat ../../patches/patch-* | patch -p1

and enter nothing at the "File to patch:" prompts and 'y' and the
"skip this patch?" prompts.

Then look at the output Oops.rej file and notice that it reflects only
the last of the patches.

There is an Oops.rej.orig file also left behind that contains the
contents of the second-last patch, but the others are lost.

(I'm furthermore wondering what happens if the current directory also
contains a file called Oops for which a patch fails...)

>Fix:

Dunno.

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.