Hello, all:
I have run into an unfortunate situation where SQL files in my project are stored in a mixture of ansi and utf-16 formats. Thanks SQL Server Management Studio!
So, I tried to modify my earlier Clean/Smudge filter to use this script:
#!/bin/bash
set -o nounset
set -o errexit
# all this shows is that variable 1 is not set
mypath="${1:-unset_or_null}"
if [ ! -e "$mypath" ]; then
echo "Number of arguments passed: $#" 1>&2
echo "$@" 1>&2
echo "File does not exist! Given path: $mypath" 1>&2
exit 1
fi
iconv -f $(file -b --mime-encoding "$mypath") -t utf-8 "$mypath"
exit 0
The only problem is, the file name is never passed into this script!
Questions:
1. Is this a bug? The above approach certainly works when setting up a diff filter
2. Is there a file name placeholder I can put directly into gitconfig? I tried putting in "$1" in the filter definition, but that failed.
Thanks,
-Ken