Save errno for logging before potentially overwriting it.
[chromium-blink-merge.git] / build / git-hooks / pre-commit
blob3ea49c572175c07a318f0c01d12a5cc7cbbe0abf
1 #!/bin/bash
3 submods=$(git diff-index --cached --ignore-submodules=dirty HEAD | grep -e '^:160000' -e '^:...... 160000' | xargs)
4 if test "$submods"; then
5 echo "You are trying to commit changes to the following submodules:" 1>&2
6 echo 1>&2
7 echo $submods | cut -d ' ' -f 6 | sed 's/^/ /g' 1>&2
8 cat <<EOF 1>&2
10 Submodule commits are not allowed. Please run:
12 git status --ignore-submodules=dirty
14 and/or:
16 git diff-index --cached --ignore-submodules=dirty HEAD
18 ... to see what's in your index.
20 If you're really and truly trying to roll the version of a submodule, you should
21 commit the new version to DEPS, instead.
22 EOF
23 exit 1
26 if test "$(git diff-index --cached HEAD .gitmodules)"; then
27 cat <<EOF 1>&2
28 You are trying to commit a change to .gitmodules. That is not allowed.
29 To make changes to submodule names/paths, edit DEPS.
30 EOF
31 exit 1
34 exit 0