From bbfe241c6a4386a39ebb93cdb70a8390eab14eef Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 23 Jun 2010 09:14:43 -0400 Subject: CTest: Parse empty Git commits correctly Git's diff-tree format has no '\n'-terminated blank line at the end of its commit message body block if there are no diff lines. Instead the message body is terminated by '\0' and there is no diff section. Teach CTest to parse the format in this case. --- Tests/CTestUpdateGIT.cmake.in | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'Tests/CTestUpdateGIT.cmake.in') diff --git a/Tests/CTestUpdateGIT.cmake.in b/Tests/CTestUpdateGIT.cmake.in index 4ac1b31770..f672a524ee 100644 --- a/Tests/CTestUpdateGIT.cmake.in +++ b/Tests/CTestUpdateGIT.cmake.in @@ -131,6 +131,22 @@ run_child( COMMAND ${GIT} submodule update ) +# Save the first revision name. +execute_process( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${GIT} rev-parse HEAD + OUTPUT_VARIABLE revision1 + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + +#----------------------------------------------------------------------------- +# Create an empty commit. +message("Creating empty commit...") +run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${GIT} commit --allow-empty -m "Empty commit" + ) + #----------------------------------------------------------------------------- # Make changes in the working tree. message("Changing content...") @@ -196,7 +212,7 @@ macro(rewind_source src_dir) message("Backing up to revision 1...") run_child( WORKING_DIRECTORY ${TOP}/${src_dir} - COMMAND ${GIT} reset --hard origin/master~2 + COMMAND ${GIT} reset --hard ${revision1} ) run_child( WORKING_DIRECTORY ${TOP}/${src_dir} @@ -261,7 +277,7 @@ execute_process( ) execute_process( WORKING_DIRECTORY \"${TOP}/dash-source\" - COMMAND \"${GIT}\" reset --hard master~2 + COMMAND \"${GIT}\" reset --hard ${revision1} ) execute_process( WORKING_DIRECTORY \"${TOP}/dash-source\" -- cgit v1.2.1