.git-hooks/pre-commit | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+)
New commits: commit dd6a371daf6e00733fa30ce96e14b82f83d59595 Author: Jan Holesovsky <ke...@collabora.com> AuthorDate: Thu Nov 22 11:52:21 2018 +0100 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Sun Oct 6 19:14:30 2019 +0200 git hooks: Tell what to do in another problematic submodules case. Change-Id: I6247df16c021c13c97471cae16d3a1c0f3ddc691 Reviewed-on: https://gerrit.libreoffice.org/80257 Reviewed-by: Andras Timar <andras.ti...@collabora.com> Tested-by: Andras Timar <andras.ti...@collabora.com> diff --git a/.git-hooks/pre-commit b/.git-hooks/pre-commit index 6c87dc890483..1f3d21ebff98 100755 --- a/.git-hooks/pre-commit +++ b/.git-hooks/pre-commit @@ -257,6 +257,12 @@ To remove the change, you can do: git submodule update $_ +If it fails with 'error: Server does not allow request for unadvertised object', +run the following: + + git submodule sync + git submodule update $_ + EOM exit(1); } commit c2e222eb39ef15ff077e8cf3f63ae46c31fd0605 Author: Jan Holesovsky <ke...@collabora.com> AuthorDate: Wed Nov 14 15:20:14 2018 +0100 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Sun Oct 6 19:14:03 2019 +0200 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 <ke...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/80256 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Andras Timar <andras.ti...@collabora.com> diff --git a/.git-hooks/pre-commit b/.git-hooks/pre-commit index 7ef34809165a..6c87dc890483 100755 --- a/.git-hooks/pre-commit +++ b/.git-hooks/pre-commit @@ -212,6 +212,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 (<SUBMODULES>) + { + chomp; + + my $ignore = `git config submodule.$_.ignore`; + chomp $ignore; + if ($ignore eq 'all') + { + print <<EOM; +Error: Your git configuration has submodule.$_.ignore set to 'all'. + +This is dangerous and can lead to accidentally pushing unwanted changes to +submodules. + +To fix it, please do: + + git config --unset submodule.$_.ignore + +EOM + exit(1); + } + + my $diff = `git diff --cached --name-only -z $h -- $_`; + chomp $diff; + if ($diff ne '') + { + print <<EOM; +Error: You are trying to commit changes to submodule $_ from the main repo. + +Please do not do that, commit only to the submodule, the git hook on the +server will make sure the appropriate change is mirrored in the main repo. + +To remove the change, you can do: + + git submodule update $_ + +EOM + exit(1); + } + } +} + # Do the work :-) # Initial commit: diff against an empty tree object @@ -282,6 +333,9 @@ check_style($against); # catch missing author info check_author(); +# catch commits to the submodules +check_submodules($against); + # all OK exit( 0 ); # vi:set shiftwidth=4 expandtab: _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits