Skip to content

Commit 4fd7f85

Browse files
committed
auto merge of #9748 : klutzy/rust/print-git-revision, r=alexcrichton
Fixes a bug that `rustc.exe -v` didn't show git revision hash. The bug is caused by that `$(wildcard $(CFG_GIT))` requires space-escaped inputs while `$(CFG_GIT)` is usually `C:\Program Files (x86)\Git�in\git.exe`.
2 parents 2e64a71 + 6434d0b commit 4fd7f85

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

Makefile.in

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,17 @@ CFG_VERSION = $(CFG_RELEASE)
147147
# numbers and dots here
148148
CFG_VERSION_WIN = 0.9
149149

150-
ifneq ($(wildcard $(CFG_GIT)),)
151-
ifneq ($(wildcard $(CFG_GIT_DIR)),)
152-
CFG_VERSION += $(shell git --git-dir=$(CFG_GIT_DIR) log -1 \
150+
# since $(CFG_GIT) may contain spaces (especially on Windows),
151+
# we need to escape them. (" " to r"\ ")
152+
# Note that $(subst ...) ignores space after `subst`,
153+
# so we use a hack: define $(SPACE) which contains space character.
154+
SPACE :=
155+
SPACE +=
156+
ifneq ($(wildcard $(subst $(SPACE),\$(SPACE),$(CFG_GIT))),)
157+
ifneq ($(wildcard $(subst $(SPACE),\$(SPACE),$(CFG_GIT_DIR))),)
158+
CFG_VERSION += $(shell git --git-dir='$(CFG_GIT_DIR)' log -1 \
153159
--pretty=format:'(%h %ci)')
154-
CFG_VER_HASH = $(shell git --git-dir=$(CFG_GIT_DIR) rev-parse HEAD)
160+
CFG_VER_HASH = $(shell git --git-dir='$(CFG_GIT_DIR)' rev-parse HEAD)
155161
endif
156162
endif
157163

0 commit comments

Comments
 (0)