Parallelizing diff Filter
Back in 1992, after I left Digital
Equipment and VMS
and found myself programming on Suns and PCs, I wrote this utility to
take the output of diff and display it in a parallel (side-by-side)
format, emulating the /PARALLEL option on the VMS version of diff.
Once you get used to side-by-side diff output, you really never want
to go back.
The code was developed on a Sun workstation. I soon thereafter
ported it to DOS. Most recently, I have moved it to Linux. I used
KDevelop in order to quickly
bring up the automake/autoconf environment.
It has come to my attention that
GNU diff
has a --side-by-side
option.
I must admit that I don't understand this option too well, but, for
the curious, pardiff output is different. Pardiff surrounds each diff
section (called a hunk in GNU diff terminology) with dashes
and pipe characters, includes line numbers with each section, and
will truncate diff lines in order to format the output to the
terminal. Pardiff's output format is not my invention, but simply an
emulation of DIFF/PARALLEL
on VMS.
Features
Pardiff detects the width of the terminal on which it is running
and adjusts its output accordingly.
Usage
Pardiff has no options. Simply pipe the output of diff to it.
E.g.:
$ diff file1 file2 | pardiff | more
The distribution includes a shell script ("diffp") to do
the above (I generally alias it to "dp").
To display context output format diff in a side-by-side mode,
use the -C option, e.g.:
$ diff -C3 file1 file2 | pardiff -C | more
Screen shots
Everybody else does them... so...
here's pardiff in action.
License
Pardiff is licensed under the GNU General Public License.
Portability
Pardiff has been compiled on Red Hat Linux 6.0 through 7.1,
Solaris 7 for Intel, HP-UX 10.20,
NetBSD, FreeBSD and OpenBSD.
The source code is nearly
identical to the version which compiled both on the Sun workstation
(in 1992) and DOS. I expect that it will be easy to get it to compile
in any ANSI C environment, but the terminal width detection code is
UNIX-only, I believe.
If you successfully compile pardiff on other platforms,
please let me know.
Bugs and Limitations
Pardiff has a fixed width in the display for line numbers, and
therefore file line numbers with 6 or more characters throw off the
formatting.
TABs and other control characters may throw off the formatting.
Changes
- Version 0.9.4 (Aug 15, 2001)
- Handle context format diff (thanks Adam Bernstein)
- Portability fixes for {Net,Free,Open}Bsd (thanks Tomasz Luchowski)
- Fixed flawed #!/bin/sh line in diffp shell script (thanks Tomasz Luchowski)
- Version 0.9.3 (Jul 6, 2001)
- Normalize EOL characters so DOS file diffs are displayed correctly on UNIX
- Version 0.9.2 (Jan 9, 2000)
- Pardiff handles up to 5-digit line numbers and diffp uses the PAGER
environment variable (thanks Asgeir Nilsen)
- Man pages for pardiff and diffp.
- Version 0.9.1 (Jan 5, 2000)
- #include file change for greater portability (thanks David Stivers).
- Initial RPMs released (thanks David Hayes).
- Version 0.9.0 (Jan 4, 2000)
- Initial public release of pardiff and diffp.
Download
Download the lastest source or RPM packages from SourceForge