diff --git a/test/core/ExamplesUnitTests/TribitsHelloWorld_Tests.cmake b/test/core/ExamplesUnitTests/TribitsHelloWorld_Tests.cmake index b60890fb7..c9fe109e5 100644 --- a/test/core/ExamplesUnitTests/TribitsHelloWorld_Tests.cmake +++ b/test/core/ExamplesUnitTests/TribitsHelloWorld_Tests.cmake @@ -128,12 +128,12 @@ tribits_add_advanced_test( TribitsHelloWorld_config_git_version_single_repo_two_ PASS_REGULAR_EXPRESSION_ALL "a1234tgb .Thu Sep 21 19:19:18 2023 -0400. " "This is the HEAD commit summary line" - "Parent 0:" - "b5678aop .Thu Sep 20 19:19:18 2023 -0400. " - "This is parent 0 commit summary line" "Parent 1:" - "c9101hah .Thu Sep 19 19:19:18 2023 -0400. " + "b5678aop .Thu Sep 20 19:19:18 2023 -0400. " "This is parent 1 commit summary line" + "Parent 2:" + "c9101hah .Thu Sep 19 19:19:18 2023 -0400. " + "This is parent 2 commit summary line" ALWAYS_FAIL_ON_NONZERO_RETURN TEST_4 diff --git a/test/core/ExamplesUnitTests/configure_git_mockprogram_files/TribitsHelloWorldRepoVersion.single_repo_two_parents_version.txt b/test/core/ExamplesUnitTests/configure_git_mockprogram_files/TribitsHelloWorldRepoVersion.single_repo_two_parents_version.txt index 53bb4556d..7a353a348 100644 --- a/test/core/ExamplesUnitTests/configure_git_mockprogram_files/TribitsHelloWorldRepoVersion.single_repo_two_parents_version.txt +++ b/test/core/ExamplesUnitTests/configure_git_mockprogram_files/TribitsHelloWorldRepoVersion.single_repo_two_parents_version.txt @@ -1,9 +1,9 @@ *** Base Git Repo: TribitsHelloWorld a1234tgb [Thu Sep 21 19:19:18 2023 -0400] This is the HEAD commit summary line - *** Parent 0: - b5678aop [Thu Sep 20 19:19:18 2023 -0400] - This is parent 0 commit summary line *** Parent 1: - c9101hah [Thu Sep 19 19:19:18 2023 -0400] + b5678aop [Thu Sep 20 19:19:18 2023 -0400] This is parent 1 commit summary line + *** Parent 2: + c9101hah [Thu Sep 19 19:19:18 2023 -0400] + This is parent 2 commit summary line diff --git a/test/core/ExamplesUnitTests/configure_git_mockprogram_files/mockprogram_inout.single_repo_two_parents_version.txt b/test/core/ExamplesUnitTests/configure_git_mockprogram_files/mockprogram_inout.single_repo_two_parents_version.txt index f192681d6..97bef2f75 100644 --- a/test/core/ExamplesUnitTests/configure_git_mockprogram_files/mockprogram_inout.single_repo_two_parents_version.txt +++ b/test/core/ExamplesUnitTests/configure_git_mockprogram_files/mockprogram_inout.single_repo_two_parents_version.txt @@ -12,10 +12,10 @@ MOCK_PROGRAM_RETURN: 0 MOCK_PROGRAM_OUTPUT: b5678aop [Thu Sep 20 19:19:18 2023 -0400] MOCK_PROGRAM_INPUT: log -1 --pretty=format:%s b5678aop MOCK_PROGRAM_RETURN: 0 -MOCK_PROGRAM_OUTPUT: This is parent 0 commit summary line +MOCK_PROGRAM_OUTPUT: This is parent 1 commit summary line MOCK_PROGRAM_INPUT: log -1 --pretty=format:%h [%ad] <%ae> c9101hah MOCK_PROGRAM_RETURN: 0 MOCK_PROGRAM_OUTPUT: c9101hah [Thu Sep 19 19:19:18 2023 -0400] MOCK_PROGRAM_INPUT: log -1 --pretty=format:%s c9101hah MOCK_PROGRAM_RETURN: 0 -MOCK_PROGRAM_OUTPUT: This is parent 1 commit summary line +MOCK_PROGRAM_OUTPUT: This is parent 2 commit summary line diff --git a/tribits/core/package_arch/TribitsGitRepoVersionInfo.cmake b/tribits/core/package_arch/TribitsGitRepoVersionInfo.cmake index 32d6ac9d3..9c026d4af 100644 --- a/tribits/core/package_arch/TribitsGitRepoVersionInfo.cmake +++ b/tribits/core/package_arch/TribitsGitRepoVersionInfo.cmake @@ -211,14 +211,11 @@ function(tribits_generate_single_repo_version_string gitRepoDir if (headNumParents GREATER 1) - # Is there a better way??? Range is inclusive and does not accept expressions?!? - math(EXPR loopMax "${headNumParents}-1") + set(parentIdx 1) # Parent commit indexes are 1-based by git - foreach(index RANGE ${loopMax}) + foreach(parentSha1 IN LISTS headParentList) # C.1) Get parent commit info string - - list(GET headParentList ${index} parentSha1) tribits_generate_commit_info_string( ${gitRepoDir} ${parentSha1} commitInfoString) @@ -226,12 +223,14 @@ function(tribits_generate_single_repo_version_string gitRepoDir # C.2) Format parent string to be pretty in config output string(APPEND outStringBuilder - "\n *** Parent ${index}:") + "\n *** Parent ${parentIdx}:") string(REPLACE "\n" "\n " commitInfoString "${commitInfoString}") string(CONCAT outStringBuilder "${outStringBuilder}" "\n ${commitInfoString}" ) + math(EXPR parentIdx "${parentIdx}+1") + endforeach() endif()