Skip to content

Commit b30da55

Browse files
committed
Do not apply patches if repo is a not a git repo.
Also backports fb75598
1 parent 2c7782a commit b30da55

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

cmake/modules/CMakeFunctions.cmake

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,12 @@ function(apply_patches repo_dir patches_dir base_revision target_branch)
102102
COMMAND ${GIT_EXECUTABLE} rev-parse --verify --no-revs -q ${target_branch}
103103
WORKING_DIRECTORY ${repo_dir}
104104
RESULT_VARIABLE patches_needed
105-
ERROR_QUIET
106105
OUTPUT_QUIET
107106
)
108-
if(patches_needed) # The target branch doesn't exist
107+
if(patches_needed EQUAL 128) # not a git repo
108+
message(STATUS "[OPENCL-CLANG] ${repo_dir} is not a git repository")
109+
return()
110+
elseif(patches_needed EQUAL 1) # The target branch doesn't exist
109111
list(SORT patches)
110112
is_valid_revision(${repo_dir} ${base_revision} exists_base_rev)
111113

@@ -115,7 +117,6 @@ function(apply_patches repo_dir patches_dir base_revision target_branch)
115117
WORKING_DIRECTORY ${repo_dir}
116118
OUTPUT_VARIABLE repo_head
117119
OUTPUT_STRIP_TRAILING_WHITESPACE
118-
ERROR_QUIET
119120
)
120121
message(STATUS "[OPENCL-CLANG] ref ${base_revision} not exists in repository, using current HEAD:${repo_head}")
121122
set(base_revision ${repo_head})
@@ -135,22 +136,23 @@ function(apply_patches repo_dir patches_dir base_revision target_branch)
135136
message(STATUS "[OPENCL-CLANG] Patch ${patch} is already in local branch - ignore patching")
136137
else()
137138
execute_process( # Apply the patch
138-
COMMAND ${GIT_EXECUTABLE} am --3way --ignore-whitespace ${patch}
139+
COMMAND ${GIT_EXECUTABLE} am --3way --ignore-whitespace -C0 ${patch}
139140
WORKING_DIRECTORY ${repo_dir}
140141
OUTPUT_VARIABLE patching_log
141-
ERROR_QUIET
142142
)
143143
message(STATUS "[OPENCL-CLANG] Not present - ${patching_log}")
144144
endif()
145145
endforeach(patch)
146-
else() # The target branch already exists
146+
elseif(patches_needed EQUAL 0) # The target branch already exists
147147
execute_process( # Check it out
148148
COMMAND ${GIT_EXECUTABLE} checkout ${target_branch}
149149
WORKING_DIRECTORY ${repo_dir}
150-
ERROR_QUIET
151150
OUTPUT_QUIET
152151
)
153152
endif()
153+
if (ret_check_out OR ret_apply_patch)
154+
message(FATAL_ERROR "[OPENCL-CLANG] Failed to apply patch!")
155+
endif()
154156
endfunction()
155157

156158
# Usage

0 commit comments

Comments
 (0)