[Libreoffice-commits] core.git: .git-hooks/pre-commit

Thorsten Behrens (via logerrit) logerrit at kemper.freedesktop.org
Fri Jul 10 20:53:29 UTC 2020


 .git-hooks/pre-commit |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

New commits:
commit 0724c35c2886a9e85400f383b0663208fb24b6fa
Author:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
AuthorDate: Fri Jul 10 22:49:06 2020 +0200
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Fri Jul 10 22:52:07 2020 +0200

    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

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>)


More information about the Libreoffice-commits mailing list