3 # Copyright 2015-2016 by Jan Vales <jan@jvales.net> (Someone <someone@somenet.org>)
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, version 3 of the License.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 # Script to create diff from two selected snapshots.
20 if [[ $2 == "" ]]; then
21 echo "parameters missing: $0 <from hash> <to hash>"
25 if [ ! -d "untracked" ]; then
26 echo "cannot cd untracked. wtf? fail!"
32 if [ ! -d ".git" ]; then
33 echo "git repo not found. cannot continue."
39 echo "extracting file permission changes..."
40 git diff -U0 "$1".."$2" -- setPerms.sh > vmdiff.perms.changed.txt
42 echo "extracting changed file list..."
43 git diff --name-status "$1".."$2" -- root | sort > vmdiff.files.changed.txt
45 echo "extracting changed files..."
46 echo "setPerms.sh" > vmdiff.tar.files.txt
47 echo "vmdiff.perms.changed.txt" >> vmdiff.tar.files.txt
48 echo "vmdiff.files.changed.txt" >> vmdiff.tar.files.txt
49 echo "root" >> vmdiff.tar.files.txt
50 cat vmdiff.files.changed.txt | egrep -v "^D" | sed -e 's/^.\s\+//' >> vmdiff.tar.files.txt
52 # workaround for \n in filename
53 sed -e's/^"//g' -e 's/"$//g' vmdiff.tar.files.txt | tr '\n' '\0' | sed -e 's/\\n/\n/g' > vmdiff.tar.files0.txt
56 tar --null -caf vmdiff.tar.gz -T vmdiff.tar.files0.txt --no-recursion
57 rm vmdiff.tar.files0.txt
59 # TODO: handle git "submodules" -.-