Skip to content

Instantly share code, notes, and snippets.

@neonichu
Created January 19, 2012 09:54
Show Gist options
  • Save neonichu/1639121 to your computer and use it in GitHub Desktop.
Save neonichu/1639121 to your computer and use it in GitHub Desktop.
Git diff for SQLite databases
#!/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