
#8251: Validate submodule references during pre-receive hook -------------------------------------+------------------------------------ Reporter: hvr | Owner: hvr Type: task | Status: new Priority: normal | Milestone: Component: Trac & Git | Version: 7.6.3 Resolution: | Keywords: admin git Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Comment (by hvr): Here's a sample session demonstrating the new server-side validation checks, when trying to update the `Win32` package to version 2.3.0.2 (from previously 2.3.0.1); After having synced up `libraries/Win32` to point version 2.3.0.2 of `Win32` we have the following change to commit to `ghc.git` (`git add libaries/Win32`): {{{#!diff diff --git a/libraries/Win32 b/libraries/Win32 index 1e909ad..c51e81a 160000 --- a/libraries/Win32 +++ b/libraries/Win32 @@ -1 +1 @@ -Subproject commit 1e909adb06b766e107148b8b37a4a9f9e50baf74 +Subproject commit c51e81a43cd5e9540453bd5ca6da8992245a4774 }}} 1. Pushing a commit touching a submodule ref w/o including the "`submodule`" safe-word: {{{ $ git commit -s -m "Update Win32-2.3.0.2" $ git push ... remote: performing tab-check... remote: performing submodule-ref update validations... remote: Submodule update(s) detected in ff458fc260fd05ebcb7db3294cbb1ec623e6525e: remote: *FAIL* commit message does not contain magic 'submodule' word remote: hooklet hooks/update.secondary.d/check-submodule-refs failed remote: hooks/update.secondary died remote: error: hook declined to update refs/heads/master To ssh://git@git.haskell.org/ghc.git ! [remote rejected] master -> master (hook declined) error: failed to push some refs to 'ssh://git@git.haskell.org/ghc.git' }}} 2. Rewrite the commit message to include the magic word, and try pusing again: {{{ $ git commit --amend -s -m "Update submodule to Win32-2.3.0.2" $ git push ... remote: performing tab-check... remote: performing submodule-ref update validations... remote: Submodule update(s) detected in a24ef02140dabb42dfbd2b649434017af6bb6fca: remote: libraries/Win32 => c51e81a43cd5e9540453bd5ca6da8992245a4774 remote: *FAIL* commit not found in submodule repo ('../packages/Win32.git') remote: or not reachable from persistent branches remote: hooklet hooks/update.secondary.d/check-submodule-refs failed remote: hooks/update.secondary died remote: error: hook declined to update refs/heads/master To ssh://git@git.haskell.org/ghc.git ! [remote rejected] master -> master (hook declined) error: failed to push some refs to 'ssh://git@git.haskell.org/ghc.git' }}} 3. Making sure the `Win32` sub-repo actually contains the new commit `ghc.git` is going to refer to, and try pushing again: {{{ $ (cd libraries/Win32 ; git push origin HEAD:ghc-head) ... To ssh://git@git.haskell.org/packages/Win32.git 1e909ad..c51e81a ghc-head -> ghc-head $ git push ... remote: performing tab-check... remote: performing submodule-ref update validations... remote: Submodule update(s) detected in 696bfc4ba5fce6b75cc91bcb67c5d0a3c9f29bd2: remote: libraries/Win32 => c51e81a43cd5e9540453bd5ca6da8992245a4774 remote: OK remote: mirroring ssh://git@git.haskell.org/ghc to ssh://git@github.com/ghc/ghc ... remote: To ssh://git@github.com/ghc/ghc remote: 3099e40..696bfc4 master -> master remote: running notifier To ssh://git@git.haskell.org/ghc.git 3099e40..696bfc4 master -> master }}} The last `git push` finally succeeded! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8251#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler