From 50608f224a0dd481f06d52d54cd2c25b21a710af Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 15 Oct 2026 18:35:42 +0900 Subject: [PATCH] Fix `lastrev` invoking in non-git directory --- common.mk | 6 +++--- tool/lastrev | 7 +++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/common.mk b/common.mk index fab4ba937c5..8b6416810b7 100644 --- a/common.mk +++ b/common.mk @@ -20,8 +20,8 @@ mflags = $(MFLAGS) gnumake_recursive = sequential = $(gnumake:yes=-sequential) enable_shared = $(ENABLE_SHARED:no=) -yes_git = $(WITH_GIT:no=) -no_git = $(WITH_GIT:yes=) +yes_git = $(HAVE_GIT:no=) +no_git = $(HAVE_GIT:yes=) UNICODE_VERSION = 17.0.0 UNICODE_EMOJI_VERSION_0 = $(UNICODE_VERSION)/// @@ -1360,7 +1360,7 @@ clean-build-tool: $(srcdir)/revision.h$(no_git:no=~disabled~): $(REVISION_H) -REVISION_H_CMD = $(LASTREV) | $(IFCHANGE) --timestamp=.revision.time revision.h - +REVISION_H_CMD = $(LASTREV) $(srcdir) | $(IFCHANGE) --empty --timestamp=.revision.time revision.h - $(REVISION_H)$(no_git:no=~disabled~): $(Q) $(REVISION_H_CMD) diff --git a/tool/lastrev b/tool/lastrev index 1caf6081e26..34689e4022e 100644 --- a/tool/lastrev +++ b/tool/lastrev @@ -60,8 +60,11 @@ shift $((OPTIND-1)) gitdir="${1-.}" head="${2-HEAD}" branch=`${git} -C "${gitdir}" symbolic-ref --short "${head}" 2>/dev/null` || branch="$head" -set `${git} -C "${gitdir}" log -1 --no-show-signature "--abbrev=${width}" \ - "--date=format-local:%FT%TZ %Y %m %d" "--format=%h %H %${date_type}" "${head}" --` +set _ `${git} -C "${gitdir}" log -1 --no-show-signature "--abbrev=${width}" \ + "--date=format-local:%FT%TZ %Y %m %d" "--format=%h %H %${date_type}" "${head}" -- 2>/dev/null` +shift + +[ -z ${1+set} ] && exit echo "#define RUBY_REVISION \"$1\"" echo "#define RUBY_FULL_REVISION \"${2}\""