kieranpotts / dotfiles

A baseline, extensible UNIX user configuration.
MIT License
1 stars 0 forks source link

Git diff, ignoring simple line number changes #208

Open kieranpotts opened 1 year ago

kieranpotts commented 1 year ago

f you've eg. moved around a bunch of lines in data files, and want a diff of what else happened, you can use the following alias

[alias]
    sortdiff = !sh -c 'git diff "$@" | grep "^[+-]" | sort --key=1.2 | uniq -u -s1'

(sort --key=1.2 ignores the leading + or -, as does -s to uniq, while -u removes any consequtive lines; I would grep -v '^(+++ b|--- a)' but that gave me "bad config file" for some reason)

You could probably include line numbers here too, by using the field features of sort/uniq

https://git.wiki.kernel.org/index.php/Aliases