]> git.somenet.org - tools/vmdiff.git/blob - vmdiff.sh
GITOLITE.txt
[tools/vmdiff.git] / vmdiff.sh
1 #!/bin/bash
2 #
3 # Copyright 2015-2016 by Jan Vales <jan@jvales.net> (Someone <someone@somenet.org>)
4 #
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.
8 #
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.
13 #
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/>.
16 #
17 # Script to create diff from two selected snapshots.
18 #
19
20 if [[ $2 == "" ]]; then
21   echo "parameters missing: $0 <from hash> <to hash>"
22   exit 1
23 fi
24
25 if [ ! -d "untracked" ]; then
26   echo "cannot cd untracked. wtf? fail!"
27   exit 1
28 fi
29
30 cd untracked
31
32 if [ ! -d ".git" ]; then
33   echo "git repo not found. cannot continue."
34   exit 1
35 fi
36
37 rm -f vmdiff.*
38
39 echo "extracting file permission changes..."
40 git diff -U0 "$1".."$2" -- setPerms.sh > vmdiff.perms.changed.txt
41
42 echo "extracting changed file list..."
43 git diff --name-status "$1".."$2" -- root | sort > vmdiff.files.changed.txt
44
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
51
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
54
55 git checkout "$2"
56 tar --null -caf vmdiff.tar.gz -T vmdiff.tar.files0.txt --no-recursion
57 rm vmdiff.tar.files0.txt 
58
59 # TODO: handle git "submodules" -.-
60