From 369d8a0f8a29973d2d87249b26f9fc2331e5ece1 Mon Sep 17 00:00:00 2001 From: Zim Kalinowski Date: Tue, 23 May 2023 18:29:41 +0200 Subject: [PATCH] build system: more accurate error information for git_describe Closes https://github.com/espressif/esp-idf/issues/9071 See merge request espressif/esp-idf!23891 --- tools/cmake/project.cmake | 3 +-- .../cmake/third_party/GetGitRevisionDescription.cmake | 10 ++++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/tools/cmake/project.cmake b/tools/cmake/project.cmake index da4e8fdb02..e884a01799 100644 --- a/tools/cmake/project.cmake +++ b/tools/cmake/project.cmake @@ -79,8 +79,7 @@ function(__project_get_revision var) if(PROJECT_VER_GIT) set(PROJECT_VER ${PROJECT_VER_GIT}) else() - message(STATUS "Project is not inside a git repository, or git repository has no commits;" - " will not use 'git describe' to determine PROJECT_VER.") + message(STATUS "Could not use 'git describe' to determine PROJECT_VER.") set(PROJECT_VER 1) endif() endif() diff --git a/tools/cmake/third_party/GetGitRevisionDescription.cmake b/tools/cmake/third_party/GetGitRevisionDescription.cmake index 37077b3b03..53428e2cb8 100644 --- a/tools/cmake/third_party/GetGitRevisionDescription.cmake +++ b/tools/cmake/third_party/GetGitRevisionDescription.cmake @@ -53,10 +53,13 @@ function(get_git_head_revision _refspecvar _hashvar _repo_dir) res OUTPUT_VARIABLE GIT_DIR - ERROR_QUIET + ERROR_VARIABLE + error OUTPUT_STRIP_TRAILING_WHITESPACE) if(NOT res EQUAL 0) + string(STRIP "${error}" error) + message(STATUS "git rev-parse returned '${error}'") return() endif() @@ -123,9 +126,12 @@ function(git_describe _var _repo_dir) res OUTPUT_VARIABLE out - ERROR_QUIET + ERROR_VARIABLE + error OUTPUT_STRIP_TRAILING_WHITESPACE) if(NOT res EQUAL 0) + string(STRIP "${error}" error) + message(STATUS "git describe returned '${error}'") set(out "${out}-${res}-NOTFOUND") endif()