blob: 519a725b3b3eeefa12ec8e7487bc54cb99e0c913 (
plain)
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
|
#!/bin/sh
set -e
if [ "$VCS" = git ]; then
rm -rf .git
file=.gitignore
elif [ "$VCS" = hg ]; then
rm -rf .hg
file=.hgignore
elif [ "$VCS" = bzr ]; then
rm -rf .bzr
file=.bzrignore
elif [ "$VCS" = darcs ]; then
rm -rf _darcs
file=.darcsignore
fi
managed_by_etckeeper="managed by etckeeper"
if ! grep -q "$managed_by_etckeeper" "$file"; then
exit 0
else
realfile="$file"
if type -p tempfile >/dev/null 2>&1; then
tempfile="tempfile"
elif type -p mktemp >/dev/null 2>&1; then
tempfile="mktemp"
else
echo "etckeeper warning: can't find tempfile or mktemp" >&2
exit 1
fi
file=$($tempfile)
otherentries=
skipping=
while read line; do
if echo "$line" | grep -q "$managed_by_etckeeper"; then
if [ ! "$skipping" ]; then
skipping=1
else
skipping=
fi
elif [ ! "$skipping" ]; then
echo "$line" >> "$file"
otherentries=1
fi
done <"$realfile"
if [ "$otherentries" ]; then
mv -f "$file" "$realfile"
else
rm -f "$file"
rm -f "$realfile"
fi
fi
|