+\r
+execute_process(\r
+ COMMAND "C:/Program Files/Git/cmd/git.exe" rev-list --max-count=1 HEAD\r
+ WORKING_DIRECTORY "C:/Users/Patrick/Documents/Studium/master/sem2/projekt/toc/antlr4-cpp-runtime-4.9.2-source/runtime/build/runtime/thirdparty/utfcpp"\r
+ RESULT_VARIABLE error_code\r
+ OUTPUT_VARIABLE head_sha\r
+ OUTPUT_STRIP_TRAILING_WHITESPACE\r
+ )\r
+if(error_code)\r
+ message(FATAL_ERROR "Failed to get the hash for HEAD")\r
+endif()\r
+\r
+execute_process(\r
+ COMMAND "C:/Program Files/Git/cmd/git.exe" show-ref v3.1.1\r
+ WORKING_DIRECTORY "C:/Users/Patrick/Documents/Studium/master/sem2/projekt/toc/antlr4-cpp-runtime-4.9.2-source/runtime/build/runtime/thirdparty/utfcpp"\r
+ OUTPUT_VARIABLE show_ref_output\r
+ )\r
+# If a remote ref is asked for, which can possibly move around,\r
+# we must always do a fetch and checkout.\r
+if("${show_ref_output}" MATCHES "remotes")\r
+ set(is_remote_ref 1)\r
+else()\r
+ set(is_remote_ref 0)\r
+endif()\r
+\r
+# Tag is in the form <remote>/<tag> (i.e. origin/master) we must strip\r
+# the remote from the tag.\r
+if("${show_ref_output}" MATCHES "refs/remotes/v3.1.1")\r
+ string(REGEX MATCH "^([^/]+)/(.+)$" _unused "v3.1.1")\r
+ set(git_remote "${CMAKE_MATCH_1}")\r
+ set(git_tag "${CMAKE_MATCH_2}")\r
+else()\r
+ set(git_remote "origin")\r
+ set(git_tag "v3.1.1")\r
+endif()\r
+\r
+# This will fail if the tag does not exist (it probably has not been fetched\r
+# yet).\r
+execute_process(\r
+ COMMAND "C:/Program Files/Git/cmd/git.exe" rev-list --max-count=1 v3.1.1\r
+ WORKING_DIRECTORY "C:/Users/Patrick/Documents/Studium/master/sem2/projekt/toc/antlr4-cpp-runtime-4.9.2-source/runtime/build/runtime/thirdparty/utfcpp"\r
+ RESULT_VARIABLE error_code\r
+ OUTPUT_VARIABLE tag_sha\r
+ OUTPUT_STRIP_TRAILING_WHITESPACE\r
+ )\r
+\r
+# Is the hash checkout out that we want?\r
+if(error_code OR is_remote_ref OR NOT ("${tag_sha}" STREQUAL "${head_sha}"))\r
+ execute_process(\r
+ COMMAND "C:/Program Files/Git/cmd/git.exe" fetch\r
+ WORKING_DIRECTORY "C:/Users/Patrick/Documents/Studium/master/sem2/projekt/toc/antlr4-cpp-runtime-4.9.2-source/runtime/build/runtime/thirdparty/utfcpp"\r
+ RESULT_VARIABLE error_code\r
+ )\r
+ if(error_code)\r
+ message(FATAL_ERROR "Failed to fetch repository 'git://github.com/nemtrif/utfcpp'")\r
+ endif()\r
+\r
+ if(is_remote_ref)\r
+ # Check if stash is needed\r
+ execute_process(\r
+ COMMAND "C:/Program Files/Git/cmd/git.exe" status --porcelain\r
+ WORKING_DIRECTORY "C:/Users/Patrick/Documents/Studium/master/sem2/projekt/toc/antlr4-cpp-runtime-4.9.2-source/runtime/build/runtime/thirdparty/utfcpp"\r
+ RESULT_VARIABLE error_code\r
+ OUTPUT_VARIABLE repo_status\r
+ )\r
+ if(error_code)\r
+ message(FATAL_ERROR "Failed to get the status")\r
+ endif()\r
+ string(LENGTH "${repo_status}" need_stash)\r
+\r
+ # If not in clean state, stash changes in order to be able to be able to\r
+ # perform git pull --rebase\r
+ if(need_stash)\r
+ execute_process(\r
+ COMMAND "C:/Program Files/Git/cmd/git.exe" stash save --all;--quiet\r
+ WORKING_DIRECTORY "C:/Users/Patrick/Documents/Studium/master/sem2/projekt/toc/antlr4-cpp-runtime-4.9.2-source/runtime/build/runtime/thirdparty/utfcpp"\r
+ RESULT_VARIABLE error_code\r
+ )\r
+ if(error_code)\r
+ message(FATAL_ERROR "Failed to stash changes")\r
+ endif()\r
+ endif()\r
+\r
+ # Pull changes from the remote branch\r
+ execute_process(\r
+ COMMAND "C:/Program Files/Git/cmd/git.exe" rebase ${git_remote}/${git_tag}\r
+ WORKING_DIRECTORY "C:/Users/Patrick/Documents/Studium/master/sem2/projekt/toc/antlr4-cpp-runtime-4.9.2-source/runtime/build/runtime/thirdparty/utfcpp"\r
+ RESULT_VARIABLE error_code\r
+ )\r
+ if(error_code)\r
+ # Rebase failed: Restore previous state.\r
+ execute_process(\r
+ COMMAND "C:/Program Files/Git/cmd/git.exe" rebase --abort\r
+ WORKING_DIRECTORY "C:/Users/Patrick/Documents/Studium/master/sem2/projekt/toc/antlr4-cpp-runtime-4.9.2-source/runtime/build/runtime/thirdparty/utfcpp"\r
+ )\r
+ if(need_stash)\r
+ execute_process(\r
+ COMMAND "C:/Program Files/Git/cmd/git.exe" stash pop --index --quiet\r
+ WORKING_DIRECTORY "C:/Users/Patrick/Documents/Studium/master/sem2/projekt/toc/antlr4-cpp-runtime-4.9.2-source/runtime/build/runtime/thirdparty/utfcpp"\r
+ )\r
+ endif()\r
+ message(FATAL_ERROR "\nFailed to rebase in: 'C:/Users/Patrick/Documents/Studium/master/sem2/projekt/toc/antlr4-cpp-runtime-4.9.2-source/runtime/build/runtime/thirdparty/utfcpp/'.\nYou will have to resolve the conflicts manually")\r
+ endif()\r
+\r
+ if(need_stash)\r
+ execute_process(\r
+ COMMAND "C:/Program Files/Git/cmd/git.exe" stash pop --index --quiet\r
+ WORKING_DIRECTORY "C:/Users/Patrick/Documents/Studium/master/sem2/projekt/toc/antlr4-cpp-runtime-4.9.2-source/runtime/build/runtime/thirdparty/utfcpp"\r
+ RESULT_VARIABLE error_code\r
+ )\r
+ if(error_code)\r
+ # Stash pop --index failed: Try again dropping the index\r
+ execute_process(\r
+ COMMAND "C:/Program Files/Git/cmd/git.exe" reset --hard --quiet\r
+ WORKING_DIRECTORY "C:/Users/Patrick/Documents/Studium/master/sem2/projekt/toc/antlr4-cpp-runtime-4.9.2-source/runtime/build/runtime/thirdparty/utfcpp"\r
+ RESULT_VARIABLE error_code\r
+ )\r
+ execute_process(\r
+ COMMAND "C:/Program Files/Git/cmd/git.exe" stash pop --quiet\r
+ WORKING_DIRECTORY "C:/Users/Patrick/Documents/Studium/master/sem2/projekt/toc/antlr4-cpp-runtime-4.9.2-source/runtime/build/runtime/thirdparty/utfcpp"\r
+ RESULT_VARIABLE error_code\r
+ )\r
+ if(error_code)\r
+ # Stash pop failed: Restore previous state.\r
+ execute_process(\r
+ COMMAND "C:/Program Files/Git/cmd/git.exe" reset --hard --quiet ${head_sha}\r
+ WORKING_DIRECTORY "C:/Users/Patrick/Documents/Studium/master/sem2/projekt/toc/antlr4-cpp-runtime-4.9.2-source/runtime/build/runtime/thirdparty/utfcpp"\r
+ )\r
+ execute_process(\r
+ COMMAND "C:/Program Files/Git/cmd/git.exe" stash pop --index --quiet\r
+ WORKING_DIRECTORY "C:/Users/Patrick/Documents/Studium/master/sem2/projekt/toc/antlr4-cpp-runtime-4.9.2-source/runtime/build/runtime/thirdparty/utfcpp"\r
+ )\r
+ message(FATAL_ERROR "\nFailed to unstash changes in: 'C:/Users/Patrick/Documents/Studium/master/sem2/projekt/toc/antlr4-cpp-runtime-4.9.2-source/runtime/build/runtime/thirdparty/utfcpp/'.\nYou will have to resolve the conflicts manually")\r
+ endif()\r
+ endif()\r
+ endif()\r
+ else()\r
+ execute_process(\r
+ COMMAND "C:/Program Files/Git/cmd/git.exe" checkout v3.1.1\r
+ WORKING_DIRECTORY "C:/Users/Patrick/Documents/Studium/master/sem2/projekt/toc/antlr4-cpp-runtime-4.9.2-source/runtime/build/runtime/thirdparty/utfcpp"\r
+ RESULT_VARIABLE error_code\r
+ )\r
+ if(error_code)\r
+ message(FATAL_ERROR "Failed to checkout tag: 'v3.1.1'")\r
+ endif()\r
+ endif()\r
+\r
+ set(init_submodules TRUE)\r
+ if(init_submodules)\r
+ execute_process(\r
+ COMMAND "C:/Program Files/Git/cmd/git.exe" submodule update --recursive --init \r
+ WORKING_DIRECTORY "C:/Users/Patrick/Documents/Studium/master/sem2/projekt/toc/antlr4-cpp-runtime-4.9.2-source/runtime/build/runtime/thirdparty/utfcpp/"\r
+ RESULT_VARIABLE error_code\r
+ )\r
+ endif()\r
+ if(error_code)\r
+ message(FATAL_ERROR "Failed to update submodules in: 'C:/Users/Patrick/Documents/Studium/master/sem2/projekt/toc/antlr4-cpp-runtime-4.9.2-source/runtime/build/runtime/thirdparty/utfcpp/'")\r
+ endif()\r
+endif()\r
+\r