I\'m trying to rewrite history, using:
git filter-branch --tree-filter \'git ls-files -z \"*.php\" |xargs -0 perl -p -i -e \"s#(PASSWORD1|PASSWORD2|PASSWORD3)#
Using a wrapper script:
#!/bin/bash
readarray -t PASSWORDS < list_file
REPLACEMENT='xXxXxXxXxXx'
SEP=$'\xFF'
EXPR=${PASSWORDS[0]}
for (( I = 1; I < ${#PASSWORDS[@]}; ++I )); do
EXPR+="|${PASSWORDS[I]}"
done
EXPR="s${SEP}(${EXPR})${SEP}$REPLACEMENT${SEP}g"
EXPR=${EXPR//'\'/'\\\\'}; EXPR=${EXPR//'$'/'\\\$'}
EXPR=${EXPR//'"'/'\"'}; EXPR=${EXPR//'`','\`'}
EXPR=${EXPR//'^','\\^'}; EXPR=${EXPR//'[','\\['}
EXPR=${EXPR//']','\\]'}; EXPR=${EXPR//'+','\\+'}
EXPR=${EXPR//'?','\\?'}; EXPR=${EXPR//'.','\\.'}
EXPR=${EXPR//'*','\\*'}; EXPR=${EXPR//'{','\\{'}
EXPR=${EXPR//'}','\\}'}; EXPR=${EXPR//'(','\\('}
EXPR=${EXPR//')','\\)'}
FILTER="git ls-files -z '*.php' | xargs -0 perl -p -i -e \"$EXPR\""
echo "Number of passwords: ${#PASSWORDS[@]}"
echo "Passwords:" "${PASSWORDS[@]}"
echo "EXPR: $EXPR"
echo "FILTER: $FILTER"
git filter-branch --tree-filter "$FILTER" -- --all