]> ruderich.org/simon Gitweb - config/dotfiles.git/blobdiff - gitconfig.m4
gitconfig: Add diff.wordregex for better git --color-words.
[config/dotfiles.git] / gitconfig.m4
index 439f7808977f5864c0beb026fa27115b6faf0bd4..f7bfd4eaba94dc79e565e62c7d635fdec26c422c 100644 (file)
@@ -118,6 +118,16 @@ include(../lib.m4)
        # Detect copies and renames.
        renames = copy
 
+       # Change the definition of a word as used by diff --color-words to be
+       # shorter (not only spaces) and thus simplify the generated diffs.
+       # Words ([a-zA-Z0-9_]+) are matched, or a single non-word character
+       # ([^a-zA-Z0-9_]), therefore changes to words are shown in complete
+       # (e.g. from "word" to "newword" as "[-word-]{+newword+}"), but
+       # changes to non-word characters are shown character wise (e.g. from
+       # "==" to "!=" as "[-=-]{+!+}="); [-..-] is removal, {+..+} is
+       # addition. See t/ for some tests and examples.
+       wordregex = [a-zA-Z0-9_]+|[^a-zA-Z0-9_]
+
 # Allow diffing of some binary files.
 # `pdftotext-` is a wrapper around pdftotext which writes to stdout.
 # `sqlite3dump` is a wrapper calling `sqlite3 database-file .dump`.