Subject: bin/2429: a patch from /dev/null can appened to an existing file
To: None <gnats-bugs@NetBSD.ORG>
From: John Hawkinson <jhawk@mit.edu>
List: netbsd-bugs
Date: 05/17/1996 21:01:28
>Number:         2429
>Category:       bin
>Synopsis:       a patch from /dev/null can appened to an existing file
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri May 17 21:35:08 1996
>Last-Modified:
>Originator:     John Hawkinson
>Organization:
MIT SIPB
>Release:        1.1
>Environment:
System: NetBSD lola-granola 1.1B NetBSD 1.1B (LOLA) #8: Fri Apr 19 11:03:57 EDT 1996 mycroft@zygorthian-space-raiders:/afs/sipb.mit.edu/project/netbsd/dev/current-source/build/i386_nbsd1/sys/arch/i386/compile/LOLA i386


>Description:

	Patches are sometimes generated from /dev/null to a filename
	to indicate that the file should be created if it does not
	already exist.

	If a patch from /dev/null is applied to a file that already exists,
	patch(1) will dutifully append the entire contents of the file
	(from which the patch was generated) to the target, resulting in
	a target that has two copies of itself, which is just wrong.

	Not surprisingly, gnu patch also has this bug, hence
	the cc list.

>How-To-Repeat:

[lola-granola!jhawk] /var/tmp/patchbug> diff -c /dev/null /etc/motd > mypatch
[lola-granola!jhawk] /var/tmp/patchbug> patch -p2 < mypatch
Hmm...  Looks like a new-style context diff to me...
The text leading up to this was:
--------------------------
|*** /dev/null  Fri May 17 19:33:14 1996
|--- /etc/motd  Mon May  6 21:02:36 1996
--------------------------
(Creating file motd...)
Patching file motd using Plan A...
Hunk #1 succeeded at 1.
done
[lola-granola!jhawk] /var/tmp/patchbug> cat motd
NetBSD 1.1B (LOLA) #8: Fri Apr 19 11:03:57 EDT 1996

Welcome to NetBSD!

6 May 1996: granola is running an athena telnetd with LINEMODE
support. Lemme know if there are problems --jhawk
[lola-granola!jhawk] /var/tmp/patchbug> patch -p2 < mypatch
Hmm...  Looks like a new-style context diff to me...
The text leading up to this was:
--------------------------
|*** /dev/null  Fri May 17 19:33:14 1996
|--- /etc/motd  Mon May  6 21:02:36 1996
--------------------------
Patching file motd using Plan A...
Hunk #1 succeeded at 1.
done
[lola-granola!jhawk] /var/tmp/patchbug> cat motd
NetBSD 1.1B (LOLA) #8: Fri Apr 19 11:03:57 EDT 1996

Welcome to NetBSD!

6 May 1996: granola is running an athena telnetd with LINEMODE
support. Lemme know if there are problems --jhawk
NetBSD 1.1B (LOLA) #8: Fri Apr 19 11:03:57 EDT 1996

Welcome to NetBSD!

6 May 1996: granola is running an athena telnetd with LINEMODE
support. Lemme know if there are problems --jhawk
[lola-granola!jhawk] /var/tmp/patchbug> 	

>Fix:

>Audit-Trail:
>Unformatted: