summaryrefslogtreecommitdiff
path: root/hg/pre-commit.d/20store-empty-directory
blob: 2f127dd9e6b23f65526c6f4eb4751f9f908c4a30 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/sh
set -e

# Make sure the file is not readable by others, since it can leak
# information about contents of non-readable directories in /etc.
umask 077

if [ -e .etckeeper ]; then
	egrep -v '^mkdir ' .etckeeper > .etckeeper.new || true
fi
find -type d -empty | grep -v /.git/ | sort | 
	sed -e "s/^/mkdir -p '/" -e "s/\$/'/" >> .etckeeper.new

if [ ! -e .etckeeper ] || ! cmp -s .etckeeper .etckeeper.new ; then
	mv -f .etckeeper.new .etckeeper
	hg add .etckeeper
else
	rm -f .etckeeper.new
fi