add git_diff_replacing function

This commit is contained in:
Ivan Malison 2014-04-18 16:31:23 -07:00
parent 77ad61d281
commit 7cc0839582

View File

@ -101,3 +101,27 @@ function clipboard() {
function git_root() {
cd `git root`
}
function git_diff_replacing() {
local original_sha='HEAD~1'
local new_sha='HEAD'
while getopts "do:n:" OPTCHAR; do;
case $OPTCHAR in
o)
original_sha="$OPTARG"
;;
n)
new_sha="$OPTARG"
;;
d)
debug="true"
esac
done
shift $((OPTIND-1))
local replaced="$1"
local replacing="$2"
local replace_sha_string='$(echo filename | sed '"s:$replaced:$replacing:g"')'
test -z $debug || echo "Diffing from $original_sha to $new_sha, replacing $replaced with $replacing"
test -z $debug || git diff $original_sha $new_sha --name-only | grep -v "$replacing"
git diff $original_sha $new_sha --name-only | grep -v "$replacing" | xargs -I filename sh -c "git diff $original_sha:filename $new_sha:"$replace_sha_string
}