examples/git-metapull: Apply stored metadata with -e -E options.
[metastore.git] / examples / git-metapull
blob98def18d60e75717c5dbdcae6326b996f4fcf592
1 #!/bin/sh
3 # This script can be used instead of git pull when updating from
4 # a remote repo to make sure the metadata matches what is stored in
5 # the repo.
6 # It will do a git pull, show a list of changes to be made to
7 # the metadata, and after getting confirmation, apply the changes.
9 DO_MTIME=yes
10 MSFILE=".metadata"
11 umask 0077
13 [ "$DO_MTIME" = "yes" ] && MSFLAGS="-m"
15 exit_on_fail() {
16 "$@"
17 if [ $? -ne 0 ]; then
18 echo "Failed to execute: $@" >&2
19 exit 1
23 exit_on_fail \
24 git pull "$@"
26 if [ ! -e "$MSFILE" ]; then
27 echo "\"$MSFILE\" missing" >&2
28 exit 1
31 echo "Going to apply the following metadata changes" >&2
33 metastore -c $MSFLAGS -f "$MSFILE" >&2
35 printf "%s" "Ok to apply? (y/n): " >&2
36 read REPLY
37 echo ""
39 if [ "$REPLY" != "y" ]; then
40 echo "Aborted" >&2
41 exit 1
44 exit_on_fail \
45 metastore -a $MSFLAGS -e -E -f "$MSFILE"
47 exit 0