View | Details | Raw Unified | Return to bug 183084
Collapse All | Expand All

(-)./Makefile (-19 / +9 lines)
Lines 1-30 Link Here
1
# Created by: eivind
1
# Created by: eivind
2
# $FreeBSD: textproc/cdiff/Makefile 327773 2013-09-20 23:17:30Z bapt $
2
# $FreeBSD: head/textproc/cdiff/Makefile 327773 2013-09-20 23:17:30Z bapt $
3
3
4
PORTNAME=	cdiff
4
PORTNAME=	cdiff
5
PORTVERSION=	1.5
5
PORTVERSION=	0.9.3
6
PORTEPOCH=	1
6
CATEGORIES=	textproc
7
CATEGORIES=	textproc
7
MASTER_SITES=	# none
8
DISTFILES=	# none
9
8
10
MAINTAINER=	garga@FreeBSD.org
9
MAINTAINER=	garga@FreeBSD.org
11
COMMENT=	Diff readability enhancer for color terminals
10
COMMENT=	Diff readability enhancer for color terminals
12
11
13
NO_BUILD=	yes
12
USE_GITHUB=
14
NO_WRKSUBDIR=	yes
13
GH_ACCOUNT=	ymattw
15
USES=		perl5
14
GH_TAGNAME=	0.9.3
15
GH_COMMIT=	423551f
16
16
17
SRC=		${.CURDIR}/src
17
USE_PYTHON=
18
18
USE_PYDISTUTILS=	yes
19
MAN1=		cdiff.1
20
PLIST_FILES=	bin/cdiff
21
22
NO_STAGE=	yes
23
do-fetch:
24
	@${DO_NADA}
25
26
do-install:
27
	@${INSTALL_SCRIPT} ${SRC}/cdiff.sh ${PREFIX}/bin/cdiff
28
	@${INSTALL_MAN} ${SRC}/cdiff.1 ${PREFIX}/man/man1
29
19
30
.include <bsd.port.mk>
20
.include <bsd.port.mk>
(-)./distinfo (+2 lines)
Line 0 Link Here
1
SHA256 (cdiff-0.9.3.tar.gz) = 3081c7fcd1eaacfda60614544b9db8930aa09945e44343e2435914c825dc8730
2
SIZE (cdiff-0.9.3.tar.gz) = 29237
(-)./pkg-descr (-3 / +4 lines)
Lines 1-4 Link Here
1
cdiff is a readability enhancer for context diffs
1
Term based tool to view colored, incremental diff in a Git/Mercurial/Svn
2
and unified diffs on color terminals.
2
workspace or from stdin, with side by side and auto pager support. Requires
3
python (>= 2.5.0) and less.
3
4
4
It uses less(1) as a backend.
5
WWW: https://github.com/ymattw/cdiff
(-)./pkg-plist (+4 lines)
Line 0 Link Here
1
bin/cdiff
2
%%PYTHON_SITELIBDIR%%/cdiff.py
3
%%PYTHON_SITELIBDIR%%/cdiff.pyc
4
%%PYTHON_SITELIBDIR%%/cdiff.pyo
(-)./src/cdiff.1 (-80 lines)
Lines 1-80 Link Here
1
.\"-
2
.\" Copyright (c) 2000 Eivind Eklund
3
.\" All rights reserved.
4
.\"
5
.\" Redistribution and use in source and binary forms, with or without
6
.\" modification, are permitted provided that the following conditions
7
.\" are met:
8
.\" 1. Redistributions of source code must retain the above copyright
9
.\"    notice, this list of conditions and the following disclaimer
10
.\"    in this position and unchanged.
11
.\" 2. Redistributions in binary form must reproduce the above copyright
12
.\"    notice, this list of conditions and the following disclaimer in the
13
.\"    documentation and/or other materials provided with the distribution.
14
.\" 3. The name of the author may not be used to endorse or promote products
15
.\"    derived from this software without specific prior written permission.
16
.\"
17
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19
.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20
.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21
.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22
.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
.\"
28
.\"	$FreeBSD: textproc/cdiff/src/cdiff.1 300897 2012-07-14 14:29:18Z beat $
29
.\"
30
.Dd October 24, 2000
31
.Dt CDIFF 1
32
.Sh NAME
33
.Nm cdiff
34
.Nd show diffs with colors
35
.Sh SYNOPSIS
36
.Nm cdiff
37
.Op Fl m
38
.Op Ar diff ...
39
.Sh DESCRIPTION
40
.Nm
41
reads a unidiff or context diff from stdin or a set of (optionally compressed)
42
files and URLs, adds color codes, expands tabs to 8 spaces, and passes the
43
results to
44
.Xr less 1 .
45
If used on a color terminal, it makes diffs much easier to read.
46
There is also handling of "cvs annotate" in it.
47
.Pp
48
.Bl -tag -width Ds
49
.It Fl m
50
Use bold, reverse and underline codes (for monochrome terminals).
51
.El
52
.Bl -tag -width CDIFFCOLORS
53
.It Ev CDIFFCOLORS
54
The color codes used to add. Default is 1:34:31:35, for lines begin with "@", "-", "+" and "!".
55
.El
56
.Sh AUTHORS
57
.Nm
58
was written by
59
.An Eivind Eklund Aq eivind@FreeBSD.org .
60
based on a sed line somebody passed around.  The code is (much) smaller than
61
this man page.
62
.Sh SEE ALSO
63
.Xr diff 1 ,
64
.Xr less 1 ,
65
.Xr cvs 1 .
66
.Sh BUGS
67
.Nm
68
assumes standard ANSI color escape sequences (as used by xterm and most other
69
commonly used terminals), rather than using
70
.Xr curses 3 .
71
.Pp
72
.Nm
73
should really be a large and complex C program based on
74
.Xr less 1
75
and a diff library.  This would allow a more informative display, including
76
collapsing pure deletions/insertions inside a single line to one line with
77
colors for deleted/added material, avoiding the line-wrap problems in less
78
due to less not knowing the effects or lengths of the color escape codes,
79
and correct handling of shifted tabs (instead of just expanding them to
80
spaces.)
(-)./src/cdiff.sh (-43 lines)
Lines 1-43 Link Here
1
#!/bin/sh
2
if [ "$1" = "-m" ]; then
3
	shift;
4
	CODES="4:7:1:1"
5
else
6
	if [ "$CDIFFCOLORS" != "" ]; then
7
		CODES=$CDIFFCOLORS
8
	else
9
		CODES="1:34:31:35"
10
	fi
11
fi
12
(if [ "$1" != "" ]; then
13
    while [ "$1" != "" ]; do
14
    	case $1 in
15
    	http:*|https:*|ftp:*|file:*)
16
            fetch -q -o - $1
17
	    ;;
18
    	*)
19
            zcat -f $1
20
	    ;;
21
        esac
22
	shift;
23
    done
24
else
25
	cat
26
fi) | perl -p -mconstant=CODES,${CODES} -e '
27
($at, $m, $p, $c) = split /:/, CODES;
28
while (s/\t/" " x (8 - ((length($`)-1) % 8))/e) {}
29
s/^(\+.*)$/\033[${p}m$1\033[0m/o;
30
s/^(-.*)$/\033[${m}m$1\033[0m/o
31
	if !s/^(--- \d+,\d+ ----.*)$/\033[1m$1\033[0m/o;
32
s/^(\*\*\* \d+,\d+ *\*\*\*.*)$/\033[1m$1\033[0m/o;
33
s/^(\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*)$/\033[1m$1\033[0m/o;
34
s/^(!.*)$/\033[${c}m$1\033[0m/o;
35
s/^(@@.*$)/\033[${at}m$1\033[0m/o;
36
if (/^1.(\d+)(\s+\(\w+\s+\d{2}-\w{3}-\d{2}\):\s)(.*)/) {
37
	$lastcol = $lastcol || 0;
38
	$lastcol++ if defined($lastrev) && $lastrev != $1;
39
	$lastrev = $1;
40
	$lastcol %= 6;
41
	$_ = "\033[3" . ($lastcol + 1) . "m1.$1$2\033[0m$3\n";
42
}
43
' | less -R

Return to bug 183084