summaryrefslogtreecommitdiff
path: root/examples/hooks
diff options
context:
space:
mode:
authorPrzemyslaw Pawelczyk <przemoc@gmail.com>2016-01-19 23:32:49 +0100
committerPrzemyslaw Pawelczyk <przemoc@gmail.com>2016-01-19 23:32:49 +0100
commit95921e7ad884f4b7c19ce6f716e452f41dbf18c9 (patch)
tree64216478851185edeba1f91d8095b982f61aff0d /examples/hooks
parent10f95bf8b1eb81ae8730487db2c9c53139481a17 (diff)
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.
Diffstat (limited to 'examples/hooks')
-rw-r--r--examples/hooks/pre-commit6
1 files changed, 6 insertions, 0 deletions
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