From 354903da5c3b094513dd4522b2f3926d9ed28d6e Mon Sep 17 00:00:00 2001 From: Benoit Sigoure Date: Fri, 30 Nov 2007 16:38:57 +0100 Subject: [PATCH] Use the $PAGER for interactive diffs. * $diff_interactive: New global. * Pass -R -F -i to less when it's the $PAGER. * svn_diff: Here. Signed-off-by: Benoit Sigoure --- svn-wrapper.sh | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/svn-wrapper.sh b/svn-wrapper.sh index 7b9caf7..5f28e83 100755 --- a/svn-wrapper.sh +++ b/svn-wrapper.sh @@ -114,6 +114,9 @@ export LC_ALL # on recent Debians that use ash as their default shell). SIGINT=2 +# Whether we're diffing interactively or not +diff_interactive=no + me=$0 bme=`basename "$0"` @@ -315,10 +318,12 @@ if test x"$COLORDIFF" = xmissing; then fi fi -# -R will tell less to interpret some terminal codes, which will turn on -# colors. +# If `less' is the $PAGER, turn on some useful options: -R to let it interpret +# some terminal codes (turns on colors and accentuated characters), -i to +# allow case-insensitive search if the pattern doesn't contain upper case +# letters. case $PAGER in #( - less) PAGER='less -R';; + less | 'less '*) PAGER="$PAGER -R -i";; esac # require_diffstat @@ -1450,7 +1455,14 @@ svn_diff() # Hence the hack to stick both diff arguments together... # No comment :) test x"$1" = x'--SVNW-HACK-w' && shift && diffarg='-uw' - $SVN diff --no-diff-deleted --diff-cmd $DIFF -x $diffarg "$@" + + # If $PAGER contains -R, it most likely understand colors and stuff, so we + # can use it to show the colored diff. + diff_cmd_='$SVN diff --no-diff-deleted --diff-cmd $DIFF -x $diffarg "$@"' + case $diff_interactive:$PAGER in #( + yes:*-R*) eval "$diff_cmd_" | $PAGER;; + *) eval "$diff_cmd_" + esac fi } @@ -1986,11 +1998,13 @@ case $1 in diff | di) shift DIFF=$COLORDIFF + diff_interactive=yes svn_diff "$@" ;; diffw | dw) shift DIFF=$COLORDIFF + diff_interactive=yes svn_diffw "$@" ;; ignore) -- 2.11.4.GIT