From 3b3a5fa7b090b26996883c9f28145190b9cd2168 Mon Sep 17 00:00:00 2001 From: Scott Bronson Date: Fri, 14 Mar 2008 18:07:33 -0700 Subject: Prune .bzr and .hg now (as well as .git) when running the find commands. --- pre-commit.d/30store-metadata | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'pre-commit.d/30store-metadata') diff --git a/pre-commit.d/30store-metadata b/pre-commit.d/30store-metadata index 363788e..5190a2c 100755 --- a/pre-commit.d/30store-metadata +++ b/pre-commit.d/30store-metadata @@ -18,24 +18,27 @@ filter_unknown() { generate_metadata() { # This function generates the script commands to fix any files # that aren't owner=root, group=root, or mode=0644 or 0755. - # Script is produced on stdout. Errors go to stderr. + # The script is produced on stdout. Errors go to stderr. + + # We maintain the permissions on the directory containing VCS data + # but we want find to ignore the VCS files themselves. + NOVCS='. -wholename ./.git -prune -o -wholename ./.bzr -prune -o -wholename ./.hg -prune -o' # Find all files and directories that don't have root as the owner - find . \! -user root -exec stat --format="chown %U {}" {} \; \ + find $NOVCS \! -user root -exec stat --format="chown %U {}" {} \; \ | sort | filter_unknown chown owner # Find all files and directories that don't have root as the group - find . \! -group root -exec stat --format="chgrp %G {}" {} \; \ + find $NOVCS \! -group root -exec stat --format="chgrp %G {}" {} \; \ | sort | filter_unknown chgrp group # Find all directories that aren't 0755 - find . -type d \! -perm 0755 -exec stat --format="chmod %a {}" {} \; | sort + find $NOVCS -type d \! -perm 0755 \ + -exec stat --format="chmod %a {}" {} \; | sort # Find all files that aren't 0644 or 0755 (we can assume the VCS will - # maintain the executable bit). All the files in the - # /etc/.git/objects directory are 0444 so we'll specifically avoid it. - find . -wholename ./.git -prune -o \ - -type f \! -perm 0644 \! -perm 0755 -exec stat --format="chmod %a {}" {} \; \ - | sort + # maintain the executable bit). + find $NOVCS -type f \! -perm 0644 \! -perm 0755 \ + -exec stat --format="chmod %a {}" {} \; | sort # We don't handle xattrs. # Maybe check for getfattr/setfattr and use them if they're available? -- cgit v1.2.3