From 95921e7ad884f4b7c19ce6f716e452f41dbf18c9 Mon Sep 17 00:00:00 2001 From: Przemyslaw Pawelczyk Date: Tue, 19 Jan 2016 23:32:49 +0100 Subject: examples/hooks/pre-commit: Improve handling of first metastore commit. Previously after first metastore commit, metastore -c would show ./.metadata: added which was misleading. Now metastore -s is run twice if .metadata is not in repository yet. --- examples/hooks/pre-commit | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'examples') diff --git a/examples/hooks/pre-commit b/examples/hooks/pre-commit index de66e3e..dc79432 100644 --- a/examples/hooks/pre-commit +++ b/examples/hooks/pre-commit @@ -27,6 +27,12 @@ exit_on_fail() { exit_on_fail \ metastore -s -f "$MSFILE" +# If it's first metastore commit, store again to include $MSFILE in $MSFILE. +if ! git-ls-tree --name-only HEAD 2>/dev/null | grep -Fqx "$MSFILE"; then + exit_on_fail \ + metastore -s -f "$MSFILE" +fi + if [ ! -e "$MSFILE" ]; then echo "\"$MSFILE\" missing" >&2 exit 1 -- cgit v1.2.1