summaryrefslogtreecommitdiff
path: root/pre-commit.d/30store-metadata
diff options
context:
space:
mode:
authorZdenek Crha <zdenek.crha@gmail.com>2013-08-28 09:43:33 +0200
committerJoey Hess <joey@kitenet.net>2013-08-28 10:50:45 -0400
commit87cf41f85c187be47f83f9b28d1f3848aaa29fa8 (patch)
tree94e7348b311fef06f7be70aab60b6629e422f665 /pre-commit.d/30store-metadata
parentca37ae96474f597c69390f43a76571d2d6c43434 (diff)
Omit files ignored by git from .etckeeper file
Add processing of the .gitignore file into filter_ignore() function. The .gitignore content is a list of globs and not regular expressions, so it is not possible to use same approach darcs uses. Instead, we use git commands to generate list of files that exist and need to be excluded as pattern file.
Diffstat (limited to 'pre-commit.d/30store-metadata')
-rwxr-xr-xpre-commit.d/30store-metadata23
1 files changed, 16 insertions, 7 deletions
diff --git a/pre-commit.d/30store-metadata b/pre-commit.d/30store-metadata
index 03ce475..d9afbe7 100755
--- a/pre-commit.d/30store-metadata
+++ b/pre-commit.d/30store-metadata
@@ -15,14 +15,23 @@ filter_unknown() {
}
filter_ignore() {
- if [ "$VCS" = darcs ]; then
- ignorefile=.darcsignore
- fi
+ case "$VCS" in
+ darcs) ignorefile=.darcsignore ;;
+ git) ignorefile=.gitignore ;;
+ esac
- if [ "$VCS" = darcs ] && [ -e "$ignorefile" ]; then
+ if [ -n "$ignorefile" ] && [ -e "$ignorefile" ]; then
patternsfile="$( mktemp -t etckeeper-$VCS.XXXXXXXXXX )"
- grep -v '^[[:space:]]*\(#\|$\)' "$ignorefile" > "$patternsfile" || true
- grep -Evf "$patternsfile"
+ case "$VCS" in
+ darcs)
+ grep -v '^[[:space:]]*\(#\|$\)' "$ignorefile" > "$patternsfile" || true
+ grep -Evf "$patternsfile"
+ ;;
+ git)
+ git ls-files --others --ignore --directory > "$ignorefile" || true
+ grep -Fvf "$patternsfile"
+ ;;
+ esac
rm -f "$patternsfile"
unset patternsfile
else
@@ -74,7 +83,7 @@ generate_metadata() {
# Store things that don't have the default user or group.
# Store all file modes, in case the user has an unusual umask.
- find $NOVCS \( -type f -or -type d \) -print | sort | perl -ne '
+ find $NOVCS \( -type f -or -type d \) -print | filter_ignore | sort | perl -ne '
BEGIN { $q=chr(39) }
sub uidname {
my $want=shift;