diff --git a/CMakeLists.txt b/CMakeLists.txt index 48315d7cb..7e5290fa0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -383,6 +383,7 @@ if(GIT_FOUND AND NOT ${GIT_EXECUTABLE} STREQUAL "") ecbuild_info("Found git: ${GIT_EXECUTABLE} (found version \"${GIT_VERSION_STRING}\")") execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD OUTPUT_VARIABLE eccodes_GIT_BRANCH + RESULT_VARIABLE nok ERROR_VARIABLE error OUTPUT_STRIP_TRAILING_WHITESPACE WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" ) ecbuild_info("ecCodes branch = ${eccodes_GIT_BRANCH}" ) diff --git a/tools/codes_info.cc b/tools/codes_info.cc index 17529017c..e6841e511 100644 --- a/tools/codes_info.cc +++ b/tools/codes_info.cc @@ -40,8 +40,13 @@ static void print_debug_info(grib_context* context) #ifdef HAVE_AEC aec = 1; #endif - grib_context_log(context, GRIB_LOG_DEBUG, "Git branch: %s", grib_get_git_branch()); - grib_context_log(context, GRIB_LOG_DEBUG, "Git SHA1: %s", grib_get_git_sha1()); + const char* git_branch = grib_get_git_branch(); + const char* git_sha1 = grib_get_git_sha1(); + if (strlen(git_branch) > 0) + grib_context_log(context, GRIB_LOG_DEBUG, "Git branch: %s", git_branch); + if (strlen(git_sha1) > 0) + grib_context_log(context, GRIB_LOG_DEBUG, "Git SHA1: %s", git_sha1); + grib_context_log(context, GRIB_LOG_DEBUG, "Build date: %s", codes_get_build_date()); grib_context_log(context, GRIB_LOG_DEBUG, "Features:"); grib_context_log(context, GRIB_LOG_DEBUG, " HAVE_AEC=%d", aec);