Added post-rewrite hook to automatically update submodules when

they change.
This commit is contained in:
Ulrich Germann 2017-03-21 18:08:33 +00:00
parent b133012cf8
commit 93af06e9c7
2 changed files with 17 additions and 0 deletions

4
git-hooks/README.md Normal file
View File

@ -0,0 +1,4 @@
This directory contains git hooks (programs automatically triggered by git events).
They cannot be put in ./git/hooks by way of version control; you have to copy them
there yourself. Make sure they are executable.

13
git-hooks/post-rewrite Normal file
View File

@ -0,0 +1,13 @@
#!/bin/bash
# from https://gist.github.com/digitaljhelms/f74eaf56835262d6bf3f
echo "[post rewrite hook: $1]"
# quick script to call "git submodule update" automatically if the
# .gitmodules file is changed
changedfiles=( `git diff-tree --no-commit-id --name-only HEAD@{1} HEAD` )
if [[ "${changedfiles[*]}" =~ ".gitmodules" ]]; then
echo "initializing & updating submodule(s)"
git submodule update --init --recursive
fi