CMake: Support reading git ref with git-worktree
Support reading the git ref and commit hash when git-worktree is being used.
Differential Revision: https://phabricator.kde.org/D9172