Created
January 19, 2012 09:54
-
-
Save neonichu/1639121 to your computer and use it in GitHub Desktop.
Git diff for SQLite databases
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
## | |
# Git diff for SQLite databases | |
## | |
if [ -z "$DIFF" ] | |
then | |
DIFF=diff | |
fi | |
SQLITE=sqlite3 | |
if [ -z "$1" ] | |
then | |
export GIT_EXTERNAL_DIFF=$0 | |
git diff | |
else | |
tmp="`dirname "$2"`" | |
file "$2"|grep 'SQLite 3.x' >/dev/null 2>&1 | |
if [ $? -ne 0 ] | |
then | |
$DIFF "$2" "$5" | |
exit 0 | |
fi | |
$SQLITE "$2" .dump >"$tmp/olddump.txt" | |
$SQLITE "$5" .dump >"$tmp/newdump.txt" | |
$DIFF "$tmp/olddump.txt" "$tmp/newdump.txt" | |
rm -f "$tmp/olddump.txt" "$tmp/newdump.txt" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment