diff -Nru colordiff-1.0.18/CHANGES colordiff-1.0.20/CHANGES --- colordiff-1.0.18/CHANGES 2017-06-02 19:41:16.000000000 +0000 +++ colordiff-1.0.20/CHANGES 2022-02-12 16:02:06.000000000 +0000 @@ -141,5 +141,17 @@ Fix regression which broke piping to less. -# vim: tw=72 +Changes between 1.0.18 and 1.0.19 + +Add 'difffile' color option, allowing more git-like coloring (separate color for +header of each changed file). Thanks Geraint Edwards. Improved portability of +Makefile, thanks Michael Osipov. Provide support for 24-bit colour strings, +thanks Stephen Wall. + +Changes between 1.0.19 and 1.0.20 +Some improvements to reading command-line options and Makefile +portability. Support for Windows configurations, thanks Rafael Kitover; and for +Octopus git/merge thanks Kiyoshi Ohgishi. + +# vim: tw=72 diff -Nru colordiff-1.0.18/colordiff.pl colordiff-1.0.20/colordiff.pl --- colordiff-1.0.18/colordiff.pl 2017-06-02 19:41:27.000000000 +0000 +++ colordiff-1.0.20/colordiff.pl 2022-02-12 16:21:49.000000000 +0000 @@ -1,11 +1,11 @@ -#!/usr/bin/perl -w +#!/usr/bin/perl ######################################################################## # # # ColorDiff - a wrapper/replacement for 'diff' producing # # colourful output # # # -# Copyright (C)2002-2017 Dave Ewart (davee@sungate.co.uk) # +# Copyright (C)2002-2020 Dave Ewart (davee@sungate.co.uk) # # # ######################################################################## # # @@ -21,17 +21,17 @@ # # ######################################################################## +use warnings; use strict; use Getopt::Long qw(:config pass_through no_auto_abbrev); my $app_name = 'colordiff'; -my $version = '1.0.18'; +my $version = '1.0.20'; my $author = 'Dave Ewart'; my $author_email = 'davee@sungate.co.uk'; my $app_www = 'http://www.colordiff.org/'; -my $copyright = '(C)2002-2017'; +my $copyright = '(C)2002-2022'; my $show_banner = 1; -my $color_patch = undef; my $diff_cmd = "diff"; # ANSI sequences for colours @@ -59,20 +59,34 @@ my $file_old = $colour{red}; my $file_new = $colour{blue}; my $diff_stuff = $colour{magenta}; +my $diff_file = $diff_stuff; my $cvs_stuff = $colour{green}; +# Config options controlling presence or absence of colour in output +# cfg_* options come from config files +# cmd_* options come from the command line +my $cfg_color_mode = 1; +my $cfg_color_patch = 0; +my $cmd_color_mode = undef; +my $cmd_color_patch = undef; +my $color_mode = undef; +my $color_patch = undef; + # Locations for personal and system-wide colour configurations -my $HOME = $ENV{HOME}; +my $HOME = (grep { defined && length } + @ENV{qw/HOME USERPROFILE/})[0] || ''; my $etcdir = '/etc'; my ($setting, $value); my @config_files = ("$etcdir/colordiffrc"); -if (defined $ENV{XDG_CONFIG_HOME} && $ENV{XDG_CONFIG_HOME} ne '') { - push (@config_files, "$ENV{XDG_CONFIG_HOME}/colordiff/colordiffrc") +my $USER_CONFIG_DIR = (grep { defined && length } + @ENV{qw/XDG_CONFIG_HOME LOCALAPPDATA APPDATA/})[0] || ''; +if (length $USER_CONFIG_DIR) { + push (@config_files, "${USER_CONFIG_DIR}/colordiff/colordiffrc") } -elsif (defined $ENV{HOME}) { - push (@config_files, "$ENV{HOME}/.config/colordiff/colordiffrc") +elsif (length $HOME) { + push (@config_files, "${HOME}/.config/colordiff/colordiffrc") } -push (@config_files, "$ENV{HOME}/.colordiffrc") if (defined $ENV{HOME}); +push (@config_files, "${HOME}/.colordiffrc") if length $HOME; my $config_file; my $diff_type = 'unknown'; @@ -164,15 +178,17 @@ my $enable_verifymode; my $specified_difftype; my $enable_fakeexitcode; -my $color_mode = "auto"; my $color_term_output_only = "no"; + +# Command-line options may over-ride config files GetOptions( # --enable-verifymode option is for testing behaviour of colordiff # against standard test diffs "verifymode" => \$enable_verifymode, "fakeexitcode" => \$enable_fakeexitcode, "difftype=s" => \$specified_difftype, - "color=s" => \$color_mode, + "color=s" => \$cmd_color_mode, + "color-patches=s" => \$cmd_color_patch, "color-term-output-only=s" => \$color_term_output_only ); @@ -183,13 +199,11 @@ if (defined $enable_verifymode) { # When in verify mode, to ensure consistent output we don't source - # any external config files, so we use built-in defaults - # and we add colour to our patches + # any external config files @config_files = (); - $color_patch = 1; - $show_banner = 0; } +# Read config file options foreach $config_file (@config_files) { if (open (COLORDIFFRC, "<$config_file")) { while () { @@ -200,7 +214,7 @@ s/\s+//g; ($setting, $value) = split ('='); if (!defined $value) { - print STDERR "Invalid configuration line ($_) in $config_file\n"; + print STDERR "Ignored invalid configuration line ($_) in $config_file\n"; next; } if ($setting eq 'banner') { @@ -209,11 +223,19 @@ } next; } + if ($setting eq 'color_mode') { + if ($value eq 'yes') { + $cfg_color_mode = 1; + } elsif ($value eq 'no') { + $cfg_color_mode = 0; + } + next; + } if ($setting eq 'color_patches') { if ($value eq 'yes') { - $color_patch = 1; + $cfg_color_patch = 1; } elsif ($value eq 'no') { - $color_patch = 0; + $cfg_color_patch = 0; } next; } @@ -226,7 +248,16 @@ if (($value eq 'normal') || ($value eq 'none')) { $value = 'off'; } - if ($value =~ m/[0-9]+/ && $value >= 0 && $value <= 255) { + # Find full 24-bit colour spec string + if (( $value =~ m/^([0-9];)*([34]8);2;([0-9]+);([0-9]+);([0-9]+)$/) && + ($3 >= 0) && ($3 <= 255) && + ($4 >= 0) && ($4 <= 255) && + ($5 >= 0) && ($5 <= 255) + ) { + $colourval = "\033[$1$2;2;$3;$4;$5m"; + } + # 256 colour single value + elsif ($value =~ m/^[0-9]+$/ && $value >= 0 && $value <= 255) { # Numeric color if( $value < 8 ) { $colourval = "\033[0;3${value}m"; @@ -257,6 +288,9 @@ elsif ($setting eq 'diffstuff') { $diff_stuff = $colourval; } + elsif ($setting eq 'difffile') { + $diff_file = $colourval; + } elsif ($setting eq 'cvsstuff') { $cvs_stuff = $colourval; } @@ -267,25 +301,63 @@ close COLORDIFFRC; } } +# Default color_mode is 1, over-ridden by config files +# All over-ridden by command line options +$color_mode = 1; +if ($cfg_color_mode == 0) { + $color_mode = 0; +} +if (defined $cmd_color_mode) { + if ($cmd_color_mode eq 'yes' + || $cmd_color_mode eq 'always' + || $cmd_color_mode eq 'auto') { + $color_mode = 1; + } + elsif ($cmd_color_mode eq 'no' + || $cmd_color_mode eq 'never') { + $color_mode = 0; + } +} + +# Default color_patch is 0, over-ridden by config files +# All over-ridden by command line options +$color_patch = 0; +if (defined $cfg_color_patch) { + if ($cfg_color_patch == 1) { + $color_patch = 1; + } +} +if (defined $cmd_color_patch) { + if ($cmd_color_patch eq 'yes' + || $cmd_color_patch eq 'always' + || $cmd_color_patch eq 'auto') { + $color_patch = 1; + } + elsif ($cmd_color_patch eq 'no' + || $cmd_color_patch eq 'never') { + $color_patch = 0; + } +} -# --color=(yes|no|auto) will override the color_patches setting -if ($color_mode eq "yes") { - $color_patch = 1; -} elsif ($color_mode eq "no") { - $color_patch = 0; -} elsif ($color_mode eq "auto") { - $color_patch = undef; +if (defined $enable_verifymode) { + # When in verify mode, to ensure consistent output we use built-in defaults + # and we add colour to our patches + $color_patch = 1; + $show_banner = 0; } -# If output is to a file, switch off colours unless overriden by $color_patch. -# Relates to http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=378563 -# Relates to http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=862878 -if ( (!$color_patch && (defined $color_patch || -f STDOUT)) || +# Switch off colours if any of these are true: +# - color_mode is no +# - output to a file unless overriden by $color_patch. +# - color_term_output_only is set and output not to a terminal +if ( (!$color_mode) || + (-f STDOUT && ($color_patch != 1)) || ($color_term_output_only eq 'yes' && !-t STDOUT) ) { $plain_text = ''; $file_old = ''; $file_new = ''; + $diff_file = ''; $diff_stuff = ''; $cvs_stuff = ''; $plain_text = ''; @@ -442,6 +514,7 @@ } } # ------------------------------------------------------------------------------ +my $count_marks = 1; while (defined( $_ = @inputstream ? shift @inputstream : ($lastline and <$inputhandle>) )) { if (/^Binary files (.*) and (.*) differ$/) { @@ -462,7 +535,7 @@ print "$cvs_stuff"; } elsif (/^Only in/) { - print "$diff_stuff"; + print "$diff_file"; } else { print "$plain_text"; @@ -476,20 +549,20 @@ print "$file_new"; } elsif (/^\*{4,}/) { - print "$diff_stuff"; + print "$diff_file"; } elsif (/^Only in/) { - print "$diff_stuff"; + print "$diff_file"; } elsif (/^\*\*\* [0-9]+,[0-9]+/) { - print "$diff_stuff"; + print "$diff_file"; $inside_file_old = 1; } elsif (/^\*\*\* /) { print "$file_old"; } elsif (/^--- [0-9]+,[0-9]+/) { - print "$diff_stuff"; + print "$diff_file"; $inside_file_old = 0; } elsif (/^--- /) { @@ -511,19 +584,29 @@ } } elsif ($diff_type eq 'diffu') { - if (/^-/) { + if (/^--- /) { print "$file_old"; } - elsif (/^\+/) { + elsif (/^\+\+\+ /) { print "$file_new"; } - elsif (/^\@/) { + elsif (/^([-\+ ]{$count_marks})/) { + my $diff_marks = $1; + if ($diff_marks =~ /-/) { + print $file_old; + } + elsif ($diff_marks =~ /\+/) { + print $file_new; + } + } + elsif (/^(\@+)/) { + $count_marks = length($1) - 1; print "$diff_stuff"; } elsif (/^Only in/) { - print "$diff_stuff"; + print "$diff_file"; } - elsif (/^(Index: |={4,}|RCS file: |retrieving |diff )/) { + elsif (/^(Index: |={4,}|RCS file: |retrieving |diff |old |new |deleted |copy |rename |similarity |dissimilarity |index |reverted:$|unchanged:$|only in patch2:$)/) { print "$cvs_stuff"; } else { @@ -550,7 +633,7 @@ } } elsif (/^Only in/) { - print "$diff_stuff"; + print "$diff_file"; } else { print "$plain_text"; diff -Nru colordiff-1.0.18/colordiffrc colordiff-1.0.20/colordiffrc --- colordiff-1.0.18/colordiffrc 2014-03-08 19:19:09.000000000 +0000 +++ colordiff-1.0.20/colordiffrc 2017-06-20 18:57:50.000000000 +0000 @@ -27,3 +27,4 @@ oldtext=darkred diffstuff=darkcyan cvsstuff=cyan +difffile=white diff -Nru colordiff-1.0.18/colordiffrc-gitdiff colordiff-1.0.20/colordiffrc-gitdiff --- colordiff-1.0.18/colordiffrc-gitdiff 2015-05-21 09:13:01.000000000 +0000 +++ colordiff-1.0.20/colordiffrc-gitdiff 2017-06-20 18:57:50.000000000 +0000 @@ -28,3 +28,4 @@ oldtext=darkred diffstuff=darkcyan cvsstuff=white +difffile=white diff -Nru colordiff-1.0.18/colordiffrc-lightbg colordiff-1.0.20/colordiffrc-lightbg --- colordiff-1.0.18/colordiffrc-lightbg 2012-10-17 20:14:35.000000000 +0000 +++ colordiff-1.0.20/colordiffrc-lightbg 2017-06-20 18:57:50.000000000 +0000 @@ -27,3 +27,4 @@ oldtext=red diffstuff=darkgreen cvsstuff=darkmagenta +difffile=darkyellow diff -Nru colordiff-1.0.18/debian/changelog colordiff-1.0.20/debian/changelog --- colordiff-1.0.18/debian/changelog 2021-01-01 14:21:06.000000000 +0000 +++ colordiff-1.0.20/debian/changelog 2022-05-20 19:35:01.000000000 +0000 @@ -1,3 +1,11 @@ +colordiff (1.0.20-1) unstable; urgency=medium + + * New upstream release. + * debhelper-compat updated to version 13. + * Updates standards version to 4.6.0, added Rules-Require-Root. + + -- Dave Ewart Fri, 20 May 2022 20:35:01 +0100 + colordiff (1.0.18-1.1) unstable; urgency=medium * Non maintainer upload by the Reproducible Builds team. @@ -115,7 +123,7 @@ * Match asterisks (from context diffs) only at start of line; thanks to Robert Luberda. (closes: #246679) - + -- Graham Wilson Mon, 31 May 2004 05:47:29 +0000 colordiff (1.0.4-3) unstable; urgency=low diff -Nru colordiff-1.0.18/debian/compat colordiff-1.0.20/debian/compat --- colordiff-1.0.18/debian/compat 2017-05-31 18:01:14.000000000 +0000 +++ colordiff-1.0.20/debian/compat 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -9 diff -Nru colordiff-1.0.18/debian/control colordiff-1.0.20/debian/control --- colordiff-1.0.18/debian/control 2017-05-31 18:01:14.000000000 +0000 +++ colordiff-1.0.20/debian/control 2022-05-20 19:34:18.000000000 +0000 @@ -2,8 +2,9 @@ Section: text Priority: optional Maintainer: Dave Ewart -Build-Depends: debhelper (>> 9.0.0) -Standards-Version: 3.9.8 +Build-Depends: debhelper-compat (= 13) +Standards-Version: 4.6.0 +Rules-Requires-Root: no Homepage: http://www.colordiff.org/ Package: colordiff @@ -13,6 +14,6 @@ ColorDiff is a wrapper for the 'diff' command. It produces the same output as diff, but with colored highlighting to improve readability. The color schemes can be customized. - . + . The output is similar to the syntax-highlighting mode of Vim or Emacs when editing a patch created by diff. diff -Nru colordiff-1.0.18/debian/copyright colordiff-1.0.20/debian/copyright --- colordiff-1.0.18/debian/copyright 2017-05-31 18:01:14.000000000 +0000 +++ colordiff-1.0.20/debian/copyright 2022-02-13 22:27:07.000000000 +0000 @@ -1,7 +1,9 @@ -Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: colordiff -Source: http://www.colordiff.org/ +Source: https://www.colordiff.org/ +Files: * +Copyright: 2002-2022 Dave Ewart License: GPL-2+ 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 @@ -19,7 +21,3 @@ . On Debian systems, the complete text of the GNU General Public License can be found in "/usr/share/common-licenses/GPL-2". - -Files: * -Copyright: 2002-2017 Dave Ewart -License: GPL-2+ diff -Nru colordiff-1.0.18/debian/rules colordiff-1.0.20/debian/rules --- colordiff-1.0.18/debian/rules 2017-05-31 18:01:14.000000000 +0000 +++ colordiff-1.0.20/debian/rules 2022-02-15 21:57:44.000000000 +0000 @@ -1,6 +1,6 @@ #!/usr/bin/make -f # $Id: rules 5 2004-03-01 22:16:51Z bob $ -# Sample debian/rules that uses debhelper. +# Sample debian/rules that uses debhelper # This file is public domain software, originally written by Joey Hess. # Nothing to do. diff -Nru colordiff-1.0.18/debian/watch colordiff-1.0.20/debian/watch --- colordiff-1.0.18/debian/watch 2017-05-31 18:01:14.000000000 +0000 +++ colordiff-1.0.20/debian/watch 2022-02-13 22:19:10.000000000 +0000 @@ -1,2 +1,2 @@ -version=3 -opts=pgpsigurlmangle=s/$/.sig/ http://www.colordiff.org/colordiff-(.*)\.tar\.gz +version=4 +opts=pgpsigurlmangle=s/$/.sig/ https://www.colordiff.org/colordiff-(.*)\.tar\.gz diff -Nru colordiff-1.0.18/Makefile colordiff-1.0.20/Makefile --- colordiff-1.0.18/Makefile 2016-11-12 12:12:14.000000000 +0000 +++ colordiff-1.0.20/Makefile 2020-06-01 13:20:03.000000000 +0000 @@ -1,6 +1,7 @@ INSTALL_DIR?=/usr/local/bin MAN_DIR?=/usr/local/man/man1 ETC_DIR?=/etc +INSTALL?=install VERSION=$(shell egrep '^my .version' colordiff.pl |cut -f 2 -d "'") DIST_FILES=COPYING INSTALL Makefile README \ colordiff.pl colordiffrc colordiffrc-lightbg cdiff.sh BUGS CHANGES colordiff.1 \ @@ -21,23 +22,23 @@ .PHONY: install install: - install -d ${DESTDIR}${INSTALL_DIR} + $(INSTALL) -d ${DESTDIR}${INSTALL_DIR} sed -e "s%/etc%${ETC_DIR}%g" colordiff.pl > \ ${DESTDIR}${INSTALL_DIR}/colordiff chmod +x ${DESTDIR}${INSTALL_DIR}/colordiff if [ ! -f ${DESTDIR}${INSTALL_DIR}/cdiff ] ; then \ - install cdiff.sh ${DESTDIR}${INSTALL_DIR}/cdiff; \ + $(INSTALL) cdiff.sh ${DESTDIR}${INSTALL_DIR}/cdiff; \ fi - install -Dm 644 colordiff.1 ${DESTDIR}${MAN_DIR}/colordiff.1 - install -Dm 644 cdiff.1 ${DESTDIR}${MAN_DIR}/cdiff.1 + $(INSTALL) -d ${DESTDIR}${MAN_DIR} + $(INSTALL) -m 644 colordiff.1 ${DESTDIR}${MAN_DIR}/colordiff.1 + $(INSTALL) -m 644 cdiff.1 ${DESTDIR}${MAN_DIR}/cdiff.1 if [ -f ${DESTDIR}${ETC_DIR}/colordiffrc ]; then \ mv -f ${DESTDIR}${ETC_DIR}/colordiffrc \ ${DESTDIR}${ETC_DIR}/colordiffrc.old; \ else \ - install -d ${DESTDIR}${ETC_DIR}; \ + $(INSTALL) -d ${DESTDIR}${ETC_DIR}; \ fi cp colordiffrc ${DESTDIR}${ETC_DIR}/colordiffrc - -chown root.root ${DESTDIR}${ETC_DIR}/colordiffrc chmod 644 ${DESTDIR}${ETC_DIR}/colordiffrc .PHONY: uninstall