From f8f96acd4f375eb5b31cf231c3067e3d074cd370 Mon Sep 17 00:00:00 2001 From: Jan Holesovsky Date: Wed, 14 Nov 2018 15:20:14 +0100 Subject: git hooks: Check that you are not committing to submodules by accident. And also for a dangerous setting in the configuration that hides the changes from you. Change-Id: I99bad8024baf7048696d9602e857c253c20cb5c2 Reviewed-on: https://gerrit.libreoffice.org/63389 Tested-by: Jenkins Reviewed-by: Jan Holesovsky --- .git-hooks/pre-commit | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to '.git-hooks') diff --git a/.git-hooks/pre-commit b/.git-hooks/pre-commit index c0464e1c0778..8b9a4a5b4b95 100755 --- a/.git-hooks/pre-commit +++ b/.git-hooks/pre-commit @@ -200,6 +200,57 @@ sub check_style($) } } +sub check_submodules($) +{ + my ($h) = @_; + + my $toplevel = `git rev-parse --show-toplevel`; + chomp $toplevel; + + # trick to get a list of submodules - directly read from the .gitmodules + open(SUBMODULES, "git config --file '$toplevel'/.gitmodules --get-regexp path | awk '{ print \$2 }' |" ) || die "Cannot run git config on the .gitmodules."; + while () + { + chomp; + + my $ignore = `git config submodule.$_.ignore`; + chomp $ignore; + if ($ignore eq 'all') + { + print <