bin/84816: patch(1) inserts a line in the wrong place

Bram Moolenaar Bram at
Thu Aug 11 20:20:17 GMT 2005

>Number:         84816
>Category:       bin
>Synopsis:       patch(1) inserts a line in the wrong place
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    freebsd-bugs
>State:          open
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Aug 11 20:20:16 GMT 2005
>Originator:     Bram Moolenaar
>Release:        FreeBSD 5.3-RELEASE i386
Zimbu Labs
System: FreeBSD 5.3-RELEASE FreeBSD 5.3-RELEASE #12: Wed Mar 2 20:26:40 CET 2005 mool at i386

	When patching a file, where the change is that one line is inserted at
	the start of the file, the new line ends up as the second line instead.
	This only appears to happen when the diff file was generated with a
	context of one line "diff -C 1".

	Example original file:
		asdf 1
		asdf 2
	Example of the patched file as it should end up:
		asdf 1
		asdf 2
	The diff file used, generated with "diff -C 1"
		*** try.orig	Thu Aug 11 19:33:39 2005
		--- try	Thu Aug 11 19:33:53 2005
		*** 1 ****
		--- 1,2 ----
		+ 999999
		  asdf 1

	The resulting patched file:
		asdf 1
		asdf 2
	Unknown.  I tried changing the "1" in the diff file to "1,1", but that
	didn't help.  The contents of the file doesn't seem to matter.  When
	using a different number of context lines the bug does not appear.


More information about the freebsd-bugs mailing list