Skip to content

Commit 1fc5b47

Browse files
authored
Fix proxy-verifier storage for git worktrees (#12686)
PR #12664 changed proxy-verifier storage to be in ${CMAKE_SOURCE_DIR}/.git. Sadly, this fails in git worktrees where .git is a file pointing to the actual git directory. Use git rev-parse --git-common-dir to dynamically detect the correct git directory, which works for both regular repositories and worktrees. This ensures proxy-verifier binaries are stored in a shared location accessible to all worktrees.
1 parent 775a324 commit 1fc5b47

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

cmake/proxy-verifier.cmake

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#
1616
#######################
1717

18-
# This will download and extract proxy-verifier to .git directory and setup variables to point to it.
18+
# This will download and extract proxy-verifier to git common directory and setup variables to point to it.
1919
#
2020
# Required variables:
2121
# PROXY_VERIFIER_VERSION
@@ -35,14 +35,26 @@ if(NOT PROXY_VERIFIER_HASH)
3535
message(FATAL_ERROR "PROXY_VERIFIER_HASH Required")
3636
endif()
3737

38-
# Download proxy-verifier to .git directory.
39-
set(PV_ARCHIVE ${CMAKE_SOURCE_DIR}/.git/proxy-verifier/proxy-verifier.tar.gz)
38+
# Detect the git common directory (works for both regular repos and worktrees).
39+
execute_process(
40+
COMMAND git rev-parse --git-common-dir
41+
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
42+
OUTPUT_VARIABLE GIT_COMMON_DIR
43+
OUTPUT_STRIP_TRAILING_WHITESPACE
44+
RESULT_VARIABLE GIT_RESULT
45+
)
46+
if(NOT GIT_RESULT EQUAL 0)
47+
message(FATAL_ERROR "Failed to determine git common directory")
48+
endif()
49+
50+
# Download proxy-verifier to git common directory.
51+
set(PV_ARCHIVE ${GIT_COMMON_DIR}/proxy-verifier/proxy-verifier.tar.gz)
4052
file(
4153
DOWNLOAD https://ci.trafficserver.apache.org/bintray/proxy-verifier-${PROXY_VERIFIER_VERSION}.tar.gz ${PV_ARCHIVE}
4254
EXPECTED_HASH ${PROXY_VERIFIER_HASH}
4355
SHOW_PROGRESS
4456
)
45-
file(ARCHIVE_EXTRACT INPUT ${PV_ARCHIVE} DESTINATION ${CMAKE_SOURCE_DIR}/.git)
57+
file(ARCHIVE_EXTRACT INPUT ${PV_ARCHIVE} DESTINATION ${GIT_COMMON_DIR})
4658

4759
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux")
4860
if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64"
@@ -70,7 +82,7 @@ else()
7082
message(FATAL_ERROR "Host ${CMAKE_HOST_SYSTEM_NAME} doesnt support running proxy verifier")
7183
endif()
7284

73-
set(PROXY_VERIFIER_PATH ${CMAKE_SOURCE_DIR}/.git/proxy-verifier-${PROXY_VERIFIER_VERSION}/${PV_SUBDIR})
85+
set(PROXY_VERIFIER_PATH ${GIT_COMMON_DIR}/proxy-verifier-${PROXY_VERIFIER_VERSION}/${PV_SUBDIR})
7486
set(PROXY_VERIFIER_CLIENT ${PROXY_VERIFIER_PATH}/verifier-client)
7587
set(PROXY_VERIFIER_SERVER ${PROXY_VERIFIER_PATH}/verifier-server)
7688

0 commit comments

Comments
 (0)