Skip to content

Commit 77dae89

Browse files
committed
Fix argument passing when overcommit-hook updated
This was a nasty one. In a nutshell, any post-checkout hook would fail seemingly at random due to command-line arguments not being passed to it (which should _never_ happen with `post-checkout` hooks). It turns out that this was caused by the code in `overcommit-hook` which re-`exec`s the master hook if it was updated before the run. Since we were passing `$0` (i.e. the master hook script) to `exec` instead of `$0 $*` (i.e. the master hook script along with all command line arguments) those arguments were getting lost, causing the post-checkout hook to fail. Change-Id: I5a7946c43b772d4a2c0bd68a70e3efc225cd8798 Reviewed-on: http://gerrit.causes.com/40970 Tested-by: jenkins <jenkins@causes.com> Reviewed-by: Shane da Silva <shane.dasilva@brigade.com>
1 parent 8a02e45 commit 77dae89

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* Fix bug where incorrect "hook run interrupted" message displayed when
66
hook run failed
77
* Gracefully handle `git stash` failures in pre-commit hook runs
8+
* Fix `overcommit-hook` auto-updating not passing original arguments to
9+
updated hook
810

911
## 0.14.1
1012

template-dir/hooks/overcommit-hook

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ begin
5555
# Ensure master hook is up-to-date
5656
installer = Overcommit::Installer.new(logger)
5757
if installer.run(Overcommit::Utils.repo_root, :action => :update)
58-
exec $0 # Execute the updated hook
58+
exec($0, *ARGV) # Execute the updated hook with all original arguments
5959
end
6060

6161
config = Overcommit::ConfigurationLoader.load_repo_config

0 commit comments

Comments
 (0)