I've made several regexes for diff and log to define what a word is. They are quite long and complex, and of course very because sometimes I want a word to be defined one way under certain circumstances, and another way in others. So I define some aliases to hide the complexity, named diff1, diff2, diff3, ... and log1, log2, log3, .... diff1 uses the same regex as log1, diff2 same as log2, etc... Also, the regex for 1, 2, 3, etc... can be composed of smaller regexes which they all share.
I would like to minimize the amount of copy coding because these are a bit experimental and I'm updating them every so often, so using variables are a logical conclusion, not to mention, it would make the regexes far more readable.
Does .gitconfig support some variable/replacement mechanism? I couldn't find anything in the man page and this question would appear to indicate that it's not available either, but I just wanted to make sure before I give up or try another tact.
Example .gitconfig file:
[alias]
# 1 2 3 4 5 6 7 8 9 10 11 12
diff2 = diff --color=always --ignore-space-change '--word-diff-regex=((\\r\\n?|\\n\\r?)[\\t ]*)?([a-zA-Z_][a-zA-Z_0-9]*|0([xX]([0-9][a-fA-F])+|[0-7]+|[bB][01]+)|[1-9][0-9]*(\\.[0-9]+)?([eE][0-9]+|[pP][0-9a-fA-F])?|\\S)(\\r\\n?|\\n\\r?)?' -p
# 1. Begining of the line whitespace can be thought of as a word
# 2. A word starts with a letter and is followed by 0 or more letters/numbers/underscores
# 3. A word (hex, octal or binary number) starts with a 0
# 4. A Word (hex) continues with an 'x' followed by 1 or more chars in [0-9a-fA-F] class.
# 5. A word (octal) continues with 1 or more chars in [0-7] class.
# 6. A word (binary) continues with 1 or more chars in [01] class.
# 7. A word (integer or decimal) starts with [1-9] and has 0 or more [0-9] chars after it.
# 8. A word (floating) continues with a '.' followed by 1 or more [0-9] chars after it.
# 9. A word (floating) can continue with an integer exponent.
# 10. A word (floating) can continue with a hex exponent.
# 11. A word can be any non-whitespace character.
# 12. A word can be all above with a newline after it.
Would be nicer if I could break this down. Like:
[alias]
# Beginning_of_line: (\\r\\n?|\\n\\r?)[\\t ]*)?
# User_defined_literal: ([a-zA-Z_][a-zA-Z_0-9]*)
# Nondecimal_number: 0([xX]([0-9][a-fA-F])+|[0-7]+|[bB][01]+)
# Decimal_number: [1-9][0-9]*(\\.[0-9]+)?([eE][0-9]+|[pP][0-9a-fA-F])?
# Single_nonwhitespace_character: \\S
# End_of_line: (\\r\\n?|\\n\\r?)?
diff2 = diff --color=always --ignore-space-change '--word-diff-regex='%Beginning_of_line%(%User_defined_literal%|%Nondecimal_number%|%Decimal_number%|%Single_nonwhitespace_character%)%End_of_line%' -p
pickaxe2 = log -p --color=always --ignore-space-change '--word-diff-regex='%Beginning_of_line%(%User_defined_literal%|%Nondecimal_number%|%Decimal_number%|%Single_nonwhitespace_character%)%End_of_line%' -s
diff3 = diff --color=always --ignore-space-change '--word-diff-regex='(%User_defined_literal%|%Nondecimal_number%|%Decimal_number%|%Single_nonwhitespace_character%)%End_of_line%' -p
pickaxe3 = log -p --color=always --ignore-space-change '--word-diff-regex='(%User_defined_literal%|%Nondecimal_number%|%Decimal_number%|%Single_nonwhitespace_character%)%End_of_line%' -s