NAME

makepatch - create patch diffs between two versions of source

SYNOPSIS

makepatch [ options ] old new

makepatch -filelist [ options ] manifest

DESCRIPTION

Makepatch generates a set of differences between two files or two sets of files maintained in two different directories and prints the results to stdout. This resulting output is suitable for use by the patch(1) program to update copies of the target file from the old to the new version.

Features of this utility include:

  • Recursive descend through sub-directories.

  • Generation of commands to remove obsolete files.

  • Automatic handling of the patchlevel.h file first.

  • Automatic inclusion of Index: and Prereq: lines.

  • Ability to utilize specified manifest files.

ARGUMENTS

old

This is the name of either a single file or else a directory which contains copies of the older version of the target files; in other words, copies of the files prior to any modifications.

new

This is the name of either a single file or else a directory which contains copies of the newer version of the target files; in other words, copies of the files after the modifications have been made. A rm(1) command will automatically be generated for every old file that no longer has a corresponding new version.

makepatch takes several options to control its behaviour. Options are usually specified on the command line, but makepatch can take options from three sources in the following order:

  • Environment variable MAKEPATCHINIT.

    When this environment variable is set its contents are considered to be command line options that are processed upon startup. All normal options are allowed, plus one: -rcfile filename. Option -rcfile can be used to specify an alternate option file, see below.

  • An option file.

    By default, makepatch looks for a file named .makepatchrc in the user's home directory, and, if found, consideres all lines to contain one or more command line options.

    An alternative option file can be specified with option -rcfile in environment variable MAKEPATCHINIT.

  • The command line.

MAKEPATCH OPTIONS

-generate type

This can be used to select the type of script to generate. Default is a script to be executed under the standard Unix shell sh, but it is much better to generate a perl program instead.

type can be perl to designate that a perl program is required, or sh or shell to designate a shell script.

-diff cmd

If specified, cmd is the command to be used to generate the differences between the two versions of the files. If not specified, this command defaults to "diff -c".

-patchlevel pfile

If specified, pfile indicates an alternate file that is to be used in lieu of "patchlevel.h".

-man[ifest] mfile

If specified, mfile indicates the name of the manifest file which consists of a list of the files contained in both the old and the new directories.

-oldman[ifest] omfile

If specified, omfile indicates the name of the manifest file which consists of a list of the files contained in the old directory. This option is designed to be used in conjunction with the -newmanifest option. Note that the old and new directories must still be indicated.

-newman[ifest] nmfile

If specified, nmfile indicates the name of the manifest file which consists of a list of the files contained in the new directory. This option is designed to be used in conjunction with the -oldmanifest option. Note that the old and new directories must still be indicated.

-[no]recurse

makepatch recurses through directories by default. Option -norecurse prevents recursion beyond the initial directories.

-follow

If specified, symbolic links to directories are traversed as if they were real directories.

-infocmd command

If specified, the output of running command will be added before each patch chunk. command will undergo the following substitutions first: %oP will be replaced by the name of the old file, %nP will be replaced by the name of the new file. %% will be replaced by a single %; other % sequences may be added in future versions.

Note that %oP and %nP are modelled after the % sequences of find -printf.

-exclude pattern

If specified, files that match the shell pattern pattern will be excluded. Only wildcard characters * and ?, and character classes [...] are handled. Multiple -exclude options may be supplied.

-exclude-regex pattern

If specified, files and directories that match the Perl regular expression pattern pattern will be excluded. Multiple -exclude-regex options may be supplied.

-exclude-vc

If specified, files and directories that are usually part of version control systems are excluded. Supported version control systems are CVS, RCS and SCCS.

-exclude-vc is a quick way to enable exclusion by the following regular expressions:

	     (\A|.*/)CVS(/.*|\Z)
	     (\A|.*/)RCS(/.*|\Z)
             ,v\Z
	     (\A|.*/)SCCS(/.*|\Z)
             (\A|.*/)[sp]\..+\Z'
-fixpath

Correct diff pathnames for new files. Use this for buggy diff or patch programs.

-fixallpath

Correct diff path names for all files. Use this for buggy diff or patch programs.

FILELIST OPTIONS

-[file]list

This option instructs makepatch to read a manifest file, and output the list of files included in this manifest. This option is useful to turn the contents of a manifest file into a list of files suitable for other programs.

-man[ifest] mfile

If specified, mfile indicates the name of the manifest file to be used. Alternatively, the name of the manifest file may follow the command line options.

-prefix string

Every entry in the manifest file is prefixed with string before it is written to stdout.

-nosort

Retain the order of filenames from the manifest file.

The exclude options -exclude, -exclude-regex and -exclude-vc can also be used with b<filelist>.

GENERAL OPTIONS

-ident

The program name and version is reported.

-verbose

This is the default mode which displays information concerning makepatchs activity to stderr.

-quiet

The opposite of -verbose. This instructs makepatch to suppress the display of activity information.

-help

This causes a short help message to be displayed, after which the program immediately exits.

MANIFEST FILES

Although there is no formal standard for manifest files, the following rules apply:

  • If the second line from the manifest file looks like a separator line (e.g. it is empty, or contains only dashes), it is discarded and so is the first line.

  • Empty lines and lines that start with a # are ignored.

  • If there are multiple space-separated ``words'' on a line, the first word is considered to be the filename.

ENVIRONMENT VARIABLES

MAKEPATCHINIT

When this environment variable is set its contents is considered to be command line options that are processed upon startup. All normal options are allowed, plus one: -rcfile filename. If -rcfile is specified, the file is read and all lines of it are considered to contain one or more command line options.

TMPDIR

TMPDIR can be used to designate the area where temporary files are placed. It defaults to /usr/tmp.

EXAMPLES

Suppose you have a directory tree emacs-18.58 containing the sources for GNU Emacs 18.58, and a directory tree emacs-18.59 containing the sources for GNU Emacs 18.59. The following command will generate the patch file needed to transform the 18.58 sources into 18.59:

makepatch emacs-18.58 emacs-18.59 > emacs-18.58-18.59.diff

This is one way to generate and use manifest files:

(cd emacs-18.58; find . -type f -print > MANIFEST)

(cd emacs-18.59; find . -type f -print > MANIFEST)

makepatch \
  -oldmanifest emacs-18.58/MANIFEST \
  -newmanifest emacs-18.59/MANIFEST \
  emacs-18.58 emacs-18.59 > emacs-18.58-18.59.diff

The following example transforms the manifest file into a list of files suitable for GNU tar. Note the trailing / in the prefix string:

makepatch -filelist -prefix emacs-18.59/ emacs-18.59/MANIFEST | \
  gtar -Zcvf emacs-18.59.tar.Z -T -Op

BUGS AND RESTRICTIONS

Filenames thet contain single quotes may confuse the process.

makepatch does not know about symbolic links. These will be treated like plain files.

SEE ALSO

diff(1), patch(1), perl(1), rm(1).

AUTHOR AND CREDITS

Johan Vromans (jvromans@squirrel.nl) wrote the program, with a little help and inspiration from: Jeffery Small (jeff@cjsa.uucp), Ulrich Pfeifer (pfeifer@ls6.informatik.uni-dortmund.de), Nigel Metheringham <Nigel.Metheringham@ThePLAnet.net>, Julian Yip <julian@computer.org>, Tim Bunce <Tim.Bunce@ig.co.uk>, Rob Browning <rlb@cs.utexas.edu>, and others.

COPYRIGHT AND DISCLAIMER

This program is Copyright 1992,1998 by Johan Vromans. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

If you do not have a copy of the GNU General Public License write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.