From 704e87ee8cf8f903aaaeaf12080ecc69703a7512 Mon Sep 17 00:00:00 2001 From: Craig Scott Date: Mon, 21 Feb 2022 18:28:07 +1100 Subject: Help: Clarify behavior of REBASE_CHECKOUT when switching branches Issue: #23216 --- Modules/ExternalProject.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 14864d5..292333d 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -353,6 +353,10 @@ External Project Definition When ``GIT_REMOTE_UPDATE_STRATEGY`` is not present, this is the default strategy unless the default has been overridden with ``CMAKE_EP_GIT_REMOTE_UPDATE_STRATEGY`` (see below). + Note that if the branch specified in ``GIT_TAG`` is different to + the upstream branch currently being tracked, it is not safe to + perform a rebase. In that situation, ``REBASE`` will silently be + treated as ``CHECKOUT`` instead. ``REBASE_CHECKOUT`` Same as ``REBASE`` except if the rebase fails, an annotated tag will -- cgit v0.12 From dec997f04e70f02c69dbe601542a4061c0bfabb1 Mon Sep 17 00:00:00 2001 From: Craig Scott Date: Mon, 21 Feb 2022 18:19:16 +1100 Subject: ExternalProject: Remove extra quotes in for-each-ref update step The --format=... argument to git for-each-ref was using a stray pair of single quotes around the format string. These were then part of the output, which caused it to never match the checkout_name. The end result was that a REBASE_CHECKOUT always became a CHECKOUT in all scenarios. Fixes: #23216 --- Modules/ExternalProject/gitupdate.cmake.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/ExternalProject/gitupdate.cmake.in b/Modules/ExternalProject/gitupdate.cmake.in index 0de2372..7896f62 100644 --- a/Modules/ExternalProject/gitupdate.cmake.in +++ b/Modules/ExternalProject/gitupdate.cmake.in @@ -128,7 +128,7 @@ if(git_update_strategy MATCHES "^REBASE(_CHECKOUT)?$") else() execute_process( - COMMAND "@git_EXECUTABLE@" for-each-ref "--format='%(upstream:short)'" "${current_branch}" + COMMAND "@git_EXECUTABLE@" for-each-ref "--format=%(upstream:short)" "${current_branch}" WORKING_DIRECTORY "@work_dir@" OUTPUT_VARIABLE upstream_branch OUTPUT_STRIP_TRAILING_WHITESPACE -- cgit v0.12