From 0eec33bc01b3b6db6e99d7ca307c66f046ebff2e Mon Sep 17 00:00:00 2001 From: Catalin Marinas Date: Fri, 20 Oct 2006 21:48:30 +0100 Subject: [PATCH] Add the diffcol.sh file to the contrib directory This script is a pager for colourifying the diff output. Copied from Quilt. Signed-off-by: Catalin Marinas --- MANIFEST.in | 1 + contrib/diffcol.sh | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ examples/stgitrc | 2 +- setup.py | 1 + 4 files changed, 54 insertions(+), 1 deletion(-) create mode 100755 contrib/diffcol.sh diff --git a/MANIFEST.in b/MANIFEST.in index 4ebca0e..5668fdf 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -3,3 +3,4 @@ include stg-prof include templates/*.tmpl include examples/*.tmpl include examples/stgitrc +include contrib/diffcol.sh diff --git a/contrib/diffcol.sh b/contrib/diffcol.sh new file mode 100755 index 0000000..ea9109d --- /dev/null +++ b/contrib/diffcol.sh @@ -0,0 +1,51 @@ +#!/bin/sh + +# Code copied from Quilt (http://savannah.nongnu.org/projects/quilt) +# +# Copyright 2006 - the Quilt authors +# +# This script is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. + +setup_colors() +{ + local C="diffhdr=1;36:diffhdradd=1;32:diffadd=32:diffhdrmod=1;35:diffmod=35:diffhdrrem=1;31:diffrem=31:diffhunk=36:diffctx=34:diffcctx=33:default=0" + [ -n "$DIFF_COLORS" ] && C="$C:$DIFF_COLORS" + + C=${C//=/=\'$'\e'[} + C=col${C//:/m\'; col}m\' + #coldefault=$(tput op) + eval $C +} + +setup_colors + +gawk '{ + if (/^(Index:|diff --git) /) + print "'$coldiffhdr'" $0 "'$coldefault'" + else if (/^======*$/) + print "'$coldiffhdr'" $0 "'$coldefault'" + else if (/^\+\+\+/) + print "'$coldiffhdradd'" $0 "'$coldefault'" + else if (/^\*\*\*/) + print "'$coldiffhdrmod'" $0 "'$coldefault'" + else if (/^---/) + print "'$coldiffhdrrem'" $0 "'$coldefault'" + else if (/^(\+|new( file)? mode )/) + print "'$coldiffadd'" $0 "'$coldefault'" + else if (/^(-|(deleted file|old) mode )/) + print "'$coldiffrem'" $0 "'$coldefault'" + else if (/^!/) + print "'$coldiffmod'" $0 "'$coldefault'" + else if (/^@@ \-[0-9]+(,[0-9]+)? \+[0-9]+(,[0-9]+)? @@/) + print gensub(/^(@@[^@]*@@)([ \t]*)(.*)/, + "'$coldiffhunk'" "\\1" "'$coldefault'" \ + "\\2" \ + "'$coldiffctx'" "\\3" "'$coldefault'", "") + else if (/^\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/) + print "'$coldiffcctx'" $0 "'$coldefault'" + else { + print + } +}' $1 | less -R -S diff --git a/examples/stgitrc b/examples/stgitrc index cd22e97..28e1879 100644 --- a/examples/stgitrc +++ b/examples/stgitrc @@ -25,7 +25,7 @@ smtpserver: localhost:25 #editor: /usr/bin/vi # this value overrides the default PAGER environment variable -#pager: less -S +#pager: ~/share/stgit/contrib/diffcol.sh # The three-way merge tool. Note that the 'output' file contains the # same data as 'branch1'. This is useful for tools that do not take an diff --git a/setup.py b/setup.py index 7888f29..7c043b8 100755 --- a/setup.py +++ b/setup.py @@ -18,5 +18,6 @@ setup(name = 'stgit', data_files = [('share/stgit/templates', glob.glob('templates/*.tmpl')), ('share/stgit/examples', glob.glob('examples/*.tmpl')), ('share/stgit/examples', ['examples/stgitrc']), + ('share/stgit/contrib', ['contrib/diffcol.sh']), ('share/doc/stgit', glob.glob('doc/*.txt'))] ) -- 2.11.0