diff --git a/CMakeLists.txt b/CMakeLists.txt index 5d478326..4d1628bf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,10 +40,26 @@ if (GIT_FOUND) if ((NOT GIT_COMMIT_RESULT EQUAL 0) OR (GIT_COMMIT STREQUAL "")) set(GIT_COMMIT "unknown") endif () + + execute_process( + COMMAND ${GIT_EXECUTABLE} status --porcelain + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE GIT_DIRTY_OUTPUT + OUTPUT_STRIP_TRAILING_WHITESPACE + RESULT_VARIABLE GIT_DIRTY_RESULT + ) + if ((NOT GIT_DIRTY_RESULT EQUAL 0)) + set(GIT_DIRTY "unknown") + elseif (GIT_DIRTY_OUTPUT STREQUAL "") + set(GIT_DIRTY "clean") + else () + set(GIT_DIRTY "dirty") + endif () else () set(GIT_COMMIT "unknown") set(GIT_BRANCH "unknown") set(GIT_TAG "unknown") + set(GIT_DIRTY "unknown") endif () if (UA2F_VERSION_STR) @@ -56,6 +72,7 @@ endif () add_compile_definitions(UA2F_GIT_COMMIT="${GIT_COMMIT}") add_compile_definitions(UA2F_GIT_BRANCH="${GIT_BRANCH}") add_compile_definitions(UA2F_GIT_TAG="${GIT_TAG}") +add_compile_definitions(UA2F_GIT_DIRTY="${GIT_DIRTY}") add_compile_definitions(UA2F_VERSION="${UA2F_VERSION_STR}") if (DEFINED ENV{UA2F_ENABLE_ASAN}) diff --git a/src/cli.c b/src/cli.c index ebf981e7..c6ad287e 100644 --- a/src/cli.c +++ b/src/cli.c @@ -27,6 +27,7 @@ void try_print_info(const int argc, char *argv[]) { printf("Git commit: %s\n", UA2F_GIT_COMMIT); printf("Git branch: %s\n", UA2F_GIT_BRANCH); printf("Git tag: %s\n", UA2F_GIT_TAG); + printf("Git dirty: %s\n", UA2F_GIT_DIRTY); #ifdef UA2F_CUSTOM_UA printf("Embed UA: %s\n", UA2F_CUSTOM_UA); #else