Subject: How to manually remove $Id$ from a patch file
To: Jeremy C. Reed <reed@reedmedia.net>
From: Roland Illig <rillig@NetBSD.org>
List: tech-pkg
Date: 11/09/2005 22:40:47
Jeremy C. Reed wrote:
> On Wed, 9 Nov 2005, Roland Illig wrote:
> 
>> Log Message:
>> Removed the $Id$ from patches/patch-aa.
> 
> 
> Please teach me how you did this, so I don't have this problem later.

Before my change, the converters/latex2rtf/patches/patch-aa looked like:

----snip----
$NetBSD: patch-aa,v 1.3 2005/11/09 07:17:04 reed Exp $

--- Makefile.orig       2004-11-07 18:59:18.000000000 -0800
+++ Makefile    2005-11-03 15:42:07.000000000 -0800
@@ -1,6 +1,6 @@
  # $Id: patch-aa,v 1.3 2005/11/09 07:17:04 reed Exp $

-CC=gcc
+CC?=gcc
  MKDIR=mkdir -p

  CFLAGS:=-DUNIX
@@ -18,14 +18,14 @@
...
----snip----

Each hunk in a (unified) diff starts with an "@@ -$del_at,$del_lines 
+$add_at,$add_lines @@" line. That means the patch takes away the lines 
$del_at..($del_at+$del_lines-1) and inserts the lines 
$add_at..($add_at+$add_lines-1).

Now we want to get rid of the first line in the hunk, as it contains the 
$Id$. So we just remove it. Then we have the following hunk:

----snip----
@@ -1,6 +1,6 @@

-CC=gcc
+CC?=gcc
  MKDIR=mkdir -p

  CFLAGS:=-DUNIX
----snip----

Now obviously the numbers in the @@ line are wrong. This hunk only takes 
away 5 lines (the ones starting with " " or "-") and adds 5 lines (the 
ones starting with " " or "+"). So we need to recalculate the numbers.

As the new hunk does not affect line 1 of the file at all, the affected 
lines start with 2. And, the line count needs to be one less than 
before. So the change starts at line 2 and takes 5 lines away. It then 
inserts 5 lines at line 2. In short: @@ -2,5 +2,5 @@.

----snip----
@@ -2,5 +2,5 @@

-CC=gcc
+CC?=gcc
  MKDIR=mkdir -p

  CFLAGS:=-DUNIX
----snip----

That's it.

After changing a patch manually, you should run "make mdi; pkglint; make 
clean; make patch" in the package directory to verify that the patch 
still applies.

Roland