* Jeff King [Fri, 02 Jan 2009 14:39:04 -0500]: > If you just want to see the results on some real-world cases (and don't > care about measuring performance), try installing bzr and using their > patiencediff test program as a GIT_EXTERNAL_DIFF. > On Debian, it's: > $ sudo apt-get install bzr > $ cat >$HOME/patience <<'EOF' > #!/bin/sh > exec python /usr/share/pyshared/bzrlib/patiencediff.py "$2" "$5" > EOF > $ chmod 755 patience > $ GIT_EXTERNAL_DIFF=$HOME/patience git diff In case somebody's interested, I have this script lying around that does that, and knows how to colorize the output using bzrtools, and honoring color.{diff,ui}. No support for color.diff.<slot>, though. -- Adeodato Simó dato at net.com.org.es Debian Developer adeodato at debian.org - Oh my God, you're pimping me out for a new roof? - And windows! -- Andrew and Bree Van De Kamp
#! /usr/bin/python import os import sys import stat import subprocess from bzrlib.patiencediff import unified_diff, PatienceSequenceMatcher try: from bzrlib.plugins.bzrtools.colordiff import DiffWriter except ImportError: _have_colordiff = False else: _have_colordiff = True ## def main(): path = sys.argv[1] file1 = open(sys.argv[2], 'rb') file2 = open(sys.argv[5], 'rb') if use_color(): writer = DiffWriter(sys.stdout, check_style=True) else: writer = sys.stdout for line in unified_diff( file1.readlines(), file2.readlines(), path, path, sequencematcher=PatienceSequenceMatcher): writer.write(line) ## def use_color(): if not _have_colordiff: return False for c in ['color.diff', 'color.ui']: p = subprocess.Popen( ['git', 'config', '--get', c], stdout=subprocess.PIPE) if p.wait() == 0: when = p.stdout.readline().strip() break else: return False if when == 'always': return True elif when in ['false', 'never']: return False elif when in ['true', 'auto']: stdout = sys.stdout.fileno() return (os.isatty(stdout) or stat.S_ISFIFO(os.fstat(sys.stdout.fileno()).st_mode)) else: return False ## if __name__ == '__main__': sys.exit(main())