Skip to content

Commit bb0acfa

Browse files
authored
Do not apply patches if repo is a not a git repo. (#544)
1 parent 373460f commit bb0acfa

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

cmake/modules/CMakeFunctions.cmake

Lines changed: 9 additions & 8 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,10 +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) # The target branch doesn't exist
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")
106+
return()
107+
endif()
108+
if(patches_needed EQUAL 1) # The target branch doesn't exist
108109
list(SORT patches)
109110
is_valid_revision(${repo_dir} ${base_revision} exists_base_rev)
110111

@@ -114,7 +115,6 @@ function(apply_patches repo_dir patches_dir base_revision target_branch)
114115
WORKING_DIRECTORY ${repo_dir}
115116
OUTPUT_VARIABLE repo_head
116117
OUTPUT_STRIP_TRAILING_WHITESPACE
117-
ERROR_QUIET
118118
)
119119
message(STATUS "[OPENCL-CLANG] ref ${base_revision} not exists in repository, using current HEAD:${repo_head}")
120120
set(base_revision ${repo_head})
@@ -137,19 +137,20 @@ function(apply_patches repo_dir patches_dir base_revision target_branch)
137137
COMMAND ${GIT_EXECUTABLE} am --3way --ignore-whitespace ${patch}
138138
WORKING_DIRECTORY ${repo_dir}
139139
OUTPUT_VARIABLE patching_log
140-
ERROR_QUIET
141140
)
142141
message(STATUS "[OPENCL-CLANG] Not present - ${patching_log}")
143142
endif()
144143
endforeach(patch)
145-
else() # The target branch already exists
144+
elsef(patches_needed EQUAL 0) # The target branch already exists
146145
execute_process( # Check it out
147146
COMMAND ${GIT_EXECUTABLE} checkout ${target_branch}
148147
WORKING_DIRECTORY ${repo_dir}
149-
ERROR_QUIET
150148
OUTPUT_QUIET
151149
)
152150
endif()
151+
if (ret_check_out OR ret_apply_patch)
152+
message(FATAL_ERROR "[OPENCL-CLANG] Failed to apply patch!")
153+
endif()
153154
endfunction()
154155

155156
# Usage

0 commit comments

Comments
 (0)