-
Notifications
You must be signed in to change notification settings - Fork 0
/
bt-commit
executable file
·64 lines (57 loc) · 1.52 KB
/
bt-commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
# are we in a normal BlobTracker repository
if [ -d .bt_objects -a -d .bt_layout ]; then
true
# or a non-working directory BlobTracker repository
elif [ -d bt_objects -a -d bt_layout ]; then
echo "You can't do a commit on non-working directory repositories."
exit 1
else
echo "This is not a BlobTracker repository."
exit 1
fi
recursively_add() {
for x in $1/*; do
if [ $x == "$1/*" ]; then continue; fi
if [ -d $x ]; then
if [ ! -d .bt_layout/$x ]; then
mkdir .bt_layout/$x
fi
recursively_add $x
else
if [ ! $x -nt .bt_layout/$x ]; then
continue;
fi
SHA1=`sha1sum $x | cut -f 1 -d " "`
echo $SHA1 > .bt_layout/$x
touch -d "`/bin/ls -lGg --full-time $x | cut -d " " -f 4-5`" \
.bt_layout/$x
if [ ! -f .bt_objects/$SHA1 ]; then
echo "new file $x"
cp $x .bt_objects/$SHA1
fi
fi
done
}
recursively_remove() {
for x in $1/*; do
if [ $x == "$1/*" ]; then continue; fi
if [ -d $x ]; then
recursively_remove $x
else
if [ -f ../$x ]; then
continue;
fi
git rm $x
fi
done
}
# recursively add new or modified files to the layout
recursively_add .
# recursively remove items from the layout as needed
cd .bt_layout
git add *
recursively_remove .
# commit the changes
git commit
cd ..