2 #create a nice commit message that contains the names
3 # of all modified, added and deleted contacts
4 # to make it easier to find changes in the git history
7 numadd=$(git status --porcelain -uno|grep ^A|wc -l)
8 numdel=$(git status --porcelain -uno|grep ^D|wc -l)
9 nummod=$(git status --porcelain -uno|grep ^M|wc -l)
10 if [ "$numadd" -eq 0 -a "$numdel" -eq 0 -a "$nummod" -eq 0 ]; then
14 echo "Backup $(date +%F): ~$nummod +$numadd -$numdel"
17 for addressbook in $(ls -1d */* | grep -v vdirsyncer-status/); do
18 user=$(echo $addressbook | cut -d/ -f1)
19 addressbookTitle=$(cat $addressbook/displayname)
21 added=$(git status --porcelain -uno\
22 | grep ^A.*$addressbook.*vcf$\
24 | xargs -L1 grep ^FN:\
27 modified=$(git status --porcelain -uno\
28 | grep ^M.*$addressbook.*vcf$\
30 | xargs -L1 grep ^FN:\
33 deleted=$(git status --porcelain -uno\
34 | grep ^D.*$addressbook.*vcf$\
36 | xargs --replace={} git diff --cached -- {}\
41 if [ -n "$added" -o -n "$modified" -o -n "$deleted" ]; then
42 echo "$user: $addressbookTitle"
45 if [ -n "$added" ]; then
47 echo "$added" | sed 's/^/- /'
51 if [ -n "$modified" ]; then
53 echo "$modified" | sed 's/^/- /'
57 if [ -n "$deleted" ]; then
59 echo "$deleted" | sed 's/^/- /'