summaryrefslogtreecommitdiff
path: root/pre-commit.d/30store-metadata
diff options
context:
space:
mode:
authorJoey Hess <joey@kitenet.net>2011-11-25 12:33:48 -0400
committerJoey Hess <joey@kitenet.net>2011-11-25 12:33:48 -0400
commit3137b75b6b0d86096e66daa24c477d4e71d85d77 (patch)
tree1a6184c1625cb6bd95bd98fd65adfc06d2389b52 /pre-commit.d/30store-metadata
parent618123e77322ea002cde9b80cce269b1960b574d (diff)
parent299dc44f1014404ca1367b72e2a22605ef22d127 (diff)
Merge branch 'master' into allperms
Conflicts: debian/changelog
Diffstat (limited to 'pre-commit.d/30store-metadata')
-rwxr-xr-xpre-commit.d/30store-metadata14
1 files changed, 10 insertions, 4 deletions
diff --git a/pre-commit.d/30store-metadata b/pre-commit.d/30store-metadata
index 871d5c8..3b79e46 100755
--- a/pre-commit.d/30store-metadata
+++ b/pre-commit.d/30store-metadata
@@ -32,10 +32,16 @@ filter_ignore() {
statf() {
while read statfile; do
- echo "$(stat --format="$1" "$statfile") '$statfile'"
+ printf "$(stat --format="$1" "$statfile") "
+ echo "$statfile" | shellquote
done
}
+shellquote() {
+ # Single quotes text, escaping existing single quotes.
+ sed -e "s/'/'\"'\"'/" -e "s/^/'/" -e "s/$/'/"
+}
+
generate_metadata() {
# This function generates the script commands to fix any file
# ownerships that aren't owner=root, group=root, as well as to
@@ -62,7 +68,7 @@ generate_metadata() {
# These version control systems do not track directories,
# so empty directories must be stored specially.
find $NOVCS -type d -empty -print |
- sort | sed -e "s/^/mkdir -p '/" -e "s/\$/'/"
+ sort | shellquote | sed -e "s/^/mkdir -p /"
fi
if [ "$VCS" = darcs ]; then
@@ -70,7 +76,7 @@ generate_metadata() {
# so they must be stored specially.
find $NOVCS -type l -print | sort | filter_ignore | while read link; do
dest=$( readlink "$link" )
- printf "ln -sf '%s' '%s'\n" "$dest" "$link"
+ printf "ln -sf '%s' '%s'\n" "$(echo "$dest" | shellquote)" "$(echo "$link" | shellquote)"
done
fi
@@ -79,7 +85,7 @@ generate_metadata() {
# Find all files and directories that don't have root as the group
find $NOVCS \! -group $(id -g) -print | statf "maybe chgrp %G" | sort | filter_unknown 'maybe chgrp' group
- find $NOVCS -print | statf "maybe chmod %a" | sort
+ find $NOVCS \( -type f -or -type d \) -print | statf "maybe chmod %a" | sort
# We don't handle xattrs.
# Maybe check for getfattr/setfattr and use them if they're available?