diff options
author | Thorsten Behrens <Thorsten.Behrens@CIB.de> | 2020-07-10 22:49:06 +0200 |
---|---|---|
committer | Thorsten Behrens <Thorsten.Behrens@CIB.de> | 2020-07-10 22:52:07 +0200 |
commit | 0724c35c2886a9e85400f383b0663208fb24b6fa (patch) | |
tree | 2f716bc7e0b72382fba569572e6d57dd3d75ccd0 /.git-hooks | |
parent | da91b2fd8e7c980973240340c3cdfcd473c1b233 (diff) |
Fixup pre-commit hook to work with worktrees
For git worktree setups, the hooks sit with the original repo
(usually the initial clone). Worktrees with older version checkouts
then miss the blacklist->excludelist rename, and consequently fail.
Change-Id: I5f60fabc7d5856c74d93c4ada54f57574e0fd1a9
Diffstat (limited to '.git-hooks')
-rwxr-xr-x | .git-hooks/pre-commit | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/.git-hooks/pre-commit b/.git-hooks/pre-commit index 27fba7e487a3..c7d51a1bcb2e 100755 --- a/.git-hooks/pre-commit +++ b/.git-hooks/pre-commit @@ -134,9 +134,15 @@ sub check_style($) my ($h) = @_; my $src = ClangFormat::get_extension_regex(); my @bad_names = (); - my $excluded_list_names = ClangFormat::get_excludelist(); my $clang_format = ClangFormat::find(); + ## Check if ClangFormat has get_excludelist or the old + ## get_blacklist + my $excluded_list_names; + eval { ClangFormat::get_excludelist() }; + if ($@) { $excluded_list_names = ClangFormat::get_blacklist(); } + else { $excluded_list_names = ClangFormat::get_excludelist(); } + # Get a list of non-deleted changed files. open (FILES, "git diff-index --cached --diff-filter=AM --name-only $h |") || die "Cannot run git diff."; while (my $filename = <FILES>) |