From 21218316dabca5ffd02e5d10793fb1894e3870ae Mon Sep 17 00:00:00 2001 From: mrambacher Date: Mon, 1 Feb 2021 21:04:22 -0800 Subject: [PATCH] Fix build_version.cc generation error if GIT not found (#7916) Summary: (Fixes a regression introduced in the build_version generation PR https://github.com/facebook/rocksdb/issues/7866 ) In the Makefile case, needed to ignore stderr on the tag (everywhere else was fine). In the CMAKE case, no GIT implies "changes" so that we use the system date rather than the empty GIT date. Pull Request resolved: https://github.com/facebook/rocksdb/pull/7916 Test Plan: Built in a tree that did not contain the ".git" directory. Validated that no errors appeared during the build process and that the build version date was not empty. Reviewed By: jay-zhuang Differential Revision: D26169203 Pulled By: mrambacher fbshipit-source-id: 3288a23b48d97efed5e5b38c9aefb3ef1153fa16 --- CMakeLists.txt | 2 +- Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c9006668b..bc8abe9bb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -185,7 +185,7 @@ if(GIT_FOUND AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git") endif() else() set(GIT_SHA 0) - set(GIT_MOD 0) + set(GIT_MOD 1) endif() string(REGEX REPLACE "[^0-9a-fA-F]+" "" GIT_SHA "${GIT_SHA}") string(REGEX REPLACE "[^0-9: /-]+" "" GIT_DATE "${GIT_DATE}") diff --git a/Makefile b/Makefile index fbb2f6034..3a15364c3 100644 --- a/Makefile +++ b/Makefile @@ -853,7 +853,7 @@ ifdef FORCE_GIT_SHA git_date := $(build_date) else git_sha := $(shell git rev-parse HEAD 2>/dev/null) - git_tag := $(shell git symbolic-ref -q --short HEAD || git describe --tags --exact-match 2>/dev/null) + git_tag := $(shell git symbolic-ref -q --short HEAD 2> /dev/null || git describe --tags --exact-match 2>/dev/null) git_mod := $(shell git diff-index HEAD --quiet 2>/dev/null; echo $$?) git_date := $(shell git log -1 --date=format:"%Y-%m-%d %T" --format="%ad" 2>/dev/null) endif