From e737d1795d0acbaba09412b3b969b33fc8956b85 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 5 Nov 2007 18:02:20 -0500 Subject: metastore fun work around various bugs and issues to avoid each commit making a change that would be seen by the next commit.. --- README | 6 +++--- init.d/10restore-metadata | 2 +- pre-commit.d/10store-metadata | 16 ++++++++++++++-- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/README b/README index 2751eb7..967ffea 100644 --- a/README +++ b/README @@ -41,9 +41,9 @@ git has only limited tracking of file metadata, being able to track the executable bit, but not other permissions or owner info. So file metadata storage is handled by `metastore`. Amoung other chores, `etckeeper-init` sets up a git hook that use `metastore` to store metadata about file -owners, permissions, modification times, and even extended attributes. This -metadata is stored in git along with everything else, and can be applied if -the repo should need to be checked back out. +owners, permissions, and even extended attributes. This metadata is stored +in git along with everything else, and can be applied if the repo should +need to be checked back out. git cannot track empty directories. So `etckeeper-init` also sets up a git hook to run `etckeeper-pre-commit`, which checks for empty directories diff --git a/init.d/10restore-metadata b/init.d/10restore-metadata index 4ce97ed..fdb1f8e 100755 --- a/init.d/10restore-metadata +++ b/init.d/10restore-metadata @@ -1,5 +1,5 @@ #!/bin/sh set -e if [ -e .metadata ]; then - metastore --apply --mtime + metastore --apply fi diff --git a/pre-commit.d/10store-metadata b/pre-commit.d/10store-metadata index 322a3ae..7958888 100755 --- a/pre-commit.d/10store-metadata +++ b/pre-commit.d/10store-metadata @@ -1,4 +1,16 @@ #!/bin/sh set -e -metastore --save --mtime -git add .metadata + +# ensure the file exists so that it will list its own metadata +if [ ! -e .metadata ]; then + metastore --save + # the file could leak hidden dir contents.. + chmod 600 .metadata +fi + +# metastore doesn't produce the same output file for the same metadata +# everytime, so avoid changing the file if nothing really changed. +if [ ! -z "$(metastore --compare)" ]; then + metastore --save + git add .metadata +fi -- cgit v1.2.3