From 927eb53580377f9460b8fc10cf3c561a31bde689 Mon Sep 17 00:00:00 2001 From: The Assassin Date: Fri, 4 Feb 2022 09:14:28 +0000 Subject: Make clang-format Git hook work in worktrees Otherwise, commits will be rejected because the hook cannot be found from the workdir root dir (there is only one .git directory in a checkout, but commands are run relative to the worktree root dir). --- kde-modules/KDEGitCommitHooks.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kde-modules/KDEGitCommitHooks.cmake b/kde-modules/KDEGitCommitHooks.cmake index c00c4c5f..b4819396 100644 --- a/kde-modules/KDEGitCommitHooks.cmake +++ b/kde-modules/KDEGitCommitHooks.cmake @@ -63,7 +63,7 @@ function(KDE_CONFIGURE_GIT_PRE_COMMIT_HOOK) if(KDE_CLANG_FORMAT_EXECUTABLE) list(FIND ARG_CHECKS "CLANG_FORMAT" _index) if (${_index} GREATER -1) - set(CLANG_FORMAT_SCRIPT "./.git/hooks/scripts/clang-format.sh") + set(CLANG_FORMAT_SCRIPT "\"$(git rev-parse --git-common-dir)\"/hooks/scripts/clang-format.sh") configure_file(${CLANG_FORMAT_UNIX} "${GIT_DIR}/hooks/scripts/clang-format.sh" @ONLY) endif() else() -- cgit v1.2.1