Skip to content

Commit 4e17f3b

Browse files
committed
Do not apply patches if repo is a not a git repo.
Also backports fb75598
1 parent 221fc35 commit 4e17f3b

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

cmake/modules/CMakeFunctions.cmake

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ function(is_backport_patch_present patch_path repo_dir patch_in_branch)
5656
WORKING_DIRECTORY ${repo_dir}
5757
RESULT_VARIABLE patch_not_in_branches
5858
OUTPUT_QUIET
59-
ERROR_QUIET
6059
)
6160
if(patch_not_in_branches)
6261
set(patch_in_branch False PARENT_SCOPE) # The patch is not present in local branch
@@ -73,7 +72,6 @@ function(is_valid_revision repo_dir revision return_val)
7372
COMMAND ${GIT_EXECUTABLE} log -1 ${revision}
7473
WORKING_DIRECTORY ${repo_dir}
7574
RESULT_VARIABLE output_var
76-
ERROR_QUIET
7775
OUTPUT_QUIET
7876
)
7977
if(${output_var} EQUAL 0)
@@ -101,14 +99,13 @@ function(apply_patches repo_dir patches_dir base_revision target_branch)
10199
COMMAND ${GIT_EXECUTABLE} rev-parse --verify --no-revs -q ${target_branch}
102100
WORKING_DIRECTORY ${repo_dir}
103101
RESULT_VARIABLE patches_needed
104-
ERROR_QUIET
105102
OUTPUT_QUIET
106103
)
107-
if(patches_needed EQUAL "128")
108-
message(STATUS "[OPENCL-CLANG] ${repo_dir} is not a git repository")
104+
if(patches_needed EQUAL 128)
105+
message(STATUS "[OPENCL-CLANG][Warning] ${repo_dir} is not a git repository, therefore, local patches are not applied")
109106
return()
110107
endif()
111-
if(patches_needed EQUAL "1") # The target branch doesn't exist
108+
if(patches_needed EQUAL 1) # The target branch doesn't exist
112109
list(SORT patches)
113110
is_valid_revision(${repo_dir} ${base_revision} exists_base_rev)
114111

@@ -118,7 +115,6 @@ function(apply_patches repo_dir patches_dir base_revision target_branch)
118115
WORKING_DIRECTORY ${repo_dir}
119116
OUTPUT_VARIABLE repo_head
120117
OUTPUT_STRIP_TRAILING_WHITESPACE
121-
ERROR_QUIET
122118
)
123119
message(STATUS "[OPENCL-CLANG] ref ${base_revision} not exists in repository, using current HEAD:${repo_head}")
124120
set(base_revision ${repo_head})
@@ -141,19 +137,20 @@ function(apply_patches repo_dir patches_dir base_revision target_branch)
141137
COMMAND ${GIT_EXECUTABLE} am --3way --ignore-whitespace ${patch}
142138
WORKING_DIRECTORY ${repo_dir}
143139
OUTPUT_VARIABLE patching_log
144-
ERROR_QUIET
145140
)
146141
message(STATUS "[OPENCL-CLANG] Not present - ${patching_log}")
147142
endif()
148143
endforeach(patch)
149-
elsef(patches_needed EQUAL "0") # The target branch already exists
144+
elsef(patches_needed EQUAL 0) # The target branch already exists
150145
execute_process( # Check it out
151146
COMMAND ${GIT_EXECUTABLE} checkout ${target_branch}
152147
WORKING_DIRECTORY ${repo_dir}
153-
ERROR_QUIET
154148
OUTPUT_QUIET
155149
)
156150
endif()
151+
if (ret_check_out OR ret_apply_patch)
152+
message(FATAL_ERROR "[OPENCL-CLANG] Failed to apply patch!")
153+
endif()
157154
endfunction()
158155

159156
# Usage

0 commit comments

Comments
 (0)