Skip to content

Commit a284923

Browse files
committed
Expect git -C <path> to work
This option is available since git 1.8.5 that was released in 2013.
1 parent 9711740 commit a284923

4 files changed

Lines changed: 37 additions & 34 deletions

File tree

common.mk

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ RUBYLIB = $(PATH_SEPARATOR)
4444
RUBYOPT = -
4545
RUN_OPTS = --disable-gems
4646

47+
GIT_IN_SRC = $(GIT) -C $(srcdir)
48+
GIT_LOG = $(GIT_IN_SRC) log
49+
GIT_LOG_FORMAT = $(GIT_LOG) --pretty=format:
50+
4751
# GITPULLOPTIONS = --no-tags
4852

4953
PRISM_SRCDIR = $(srcdir)/prism
@@ -1514,8 +1518,8 @@ update-bundled_gems: PHONY
15141518
$(tooldir)/update-bundled_gems.rb \
15151519
"$(srcdir)/gems/bundled_gems" | \
15161520
$(IFCHANGE) "$(srcdir)/gems/bundled_gems" -
1517-
$(GIT) -C "$(srcdir)" diff --no-ext-diff --ignore-submodules --exit-code || \
1518-
$(GIT) -C "$(srcdir)" commit -m "Update bundled_gems" gems/bundled_gems
1521+
$(GIT_IN_SRC) diff --no-ext-diff --ignore-submodules --exit-code || \
1522+
$(GIT_IN_SRC) commit -m "Update bundled_gems" gems/bundled_gems
15191523

15201524
PRECHECK_BUNDLED_GEMS = yes
15211525
test-bundled-gems-precheck: $(TEST_RUNNABLE)-test-bundled-gems-precheck
@@ -1899,8 +1903,8 @@ nightly: yesterday $(DOT_WAIT) install
18991903
yesterday: rewindable
19001904

19011905
rewindable:
1902-
$(GIT) -C $(srcdir) status --porcelain
1903-
$(GIT) -C $(srcdir) diff --quiet
1906+
$(GIT_IN_SRC) status --porcelain
1907+
$(GIT_IN_SRC) diff --quiet
19041908

19051909
HELP_EXTRA_TASKS = ""
19061910

defs/gmake.mk

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,8 @@ post-commit: $(if $(DOT_WAIT),,do-commit)
220220
GITHUB_RUBY_URL = https://github.com/ruby/ruby
221221
PR =
222222

223-
COMMIT_GPG_SIGN = $(shell $(GIT) -C "$(srcdir)" config commit.gpgsign)
224-
REMOTE_GITHUB_URL = $(shell $(GIT) -C "$(srcdir)" config remote.github.url)
223+
COMMIT_GPG_SIGN = $(shell $(GIT_IN_SRC) config commit.gpgsign)
224+
REMOTE_GITHUB_URL = $(shell $(GIT_IN_SRC) config remote.github.url)
225225
COMMITS_NOTES = commits
226226

227227
.PHONY: fetch-github
@@ -236,19 +236,19 @@ define fetch-github
236236
$(eval REMOTE_GITHUB_URL := $(REMOTE_GITHUB_URL))
237237
$(if $(REMOTE_GITHUB_URL),,
238238
echo adding $(GITHUB_RUBY_URL) as remote github
239-
$(GIT) -C "$(srcdir)" remote add github $(GITHUB_RUBY_URL)
240-
$(GIT) -C "$(srcdir)" config --add remote.github.fetch +refs/notes/$(COMMITS_NOTES):refs/notes/$(COMMITS_NOTES)
239+
$(GIT_IN_SRC) remote add github $(GITHUB_RUBY_URL)
240+
$(GIT_IN_SRC) config --add remote.github.fetch +refs/notes/$(COMMITS_NOTES):refs/notes/$(COMMITS_NOTES)
241241
$(eval REMOTE_GITHUB_URL := $(GITHUB_RUBY_URL))
242242
)
243-
$(if $(shell $(GIT) -C "$(srcdir)" rev-parse "github/pull/$(1)/head" -- 2> /dev/null),
244-
$(GIT) -C "$(srcdir)" branch -f "gh-$(1)" "github/pull/$(1)/head",
245-
$(GIT) -C "$(srcdir)" fetch -f github "pull/$(1)/head:gh-$(1)"
243+
$(if $(shell $(GIT_IN_SRC) rev-parse "github/pull/$(1)/head" -- 2> /dev/null),
244+
$(GIT_IN_SRC) branch -f "gh-$(1)" "github/pull/$(1)/head",
245+
$(GIT_IN_SRC) fetch -f github "pull/$(1)/head:gh-$(1)"
246246
)
247247
endef
248248

249249
.PHONY: checkout-github
250250
checkout-github: fetch-github
251-
$(GIT) -C "$(srcdir)" checkout "gh-$(PR)"
251+
$(GIT_IN_SRC) checkout "gh-$(PR)"
252252

253253
.PHONY: update-github
254254
update-github: fetch-github
@@ -261,25 +261,25 @@ update-github: fetch-github
261261
$(eval PR_BRANCH := $(word 2,$(PULL_REQUEST_FORK_BRANCH)))
262262

263263
$(eval GITHUB_UPDATE_WORKTREE := $(shell mktemp -d "$(srcdir)/gh-$(PR)-XXXXXX"))
264-
$(GIT) -C "$(srcdir)" worktree add $(notdir $(GITHUB_UPDATE_WORKTREE)) "gh-$(PR)"
264+
$(GIT_IN_SRC) worktree add $(notdir $(GITHUB_UPDATE_WORKTREE)) "gh-$(PR)"
265265
$(GIT) -C "$(GITHUB_UPDATE_WORKTREE)" merge master --no-edit
266266
@$(BASERUBY) -e 'print "Are you sure to push this to PR=$(PR)? [Y/n]: "; exit(gets.chomp != "n")'
267-
$(GIT) -C "$(srcdir)" remote add fork-$(PR) git@github.com:$(FORK_REPO).git
267+
$(GIT_IN_SRC) remote add fork-$(PR) git@github.com:$(FORK_REPO).git
268268
$(GIT) -C "$(GITHUB_UPDATE_WORKTREE)" push fork-$(PR) gh-$(PR):$(PR_BRANCH)
269-
$(GIT) -C "$(srcdir)" remote rm fork-$(PR)
270-
$(GIT) -C "$(srcdir)" worktree remove $(notdir $(GITHUB_UPDATE_WORKTREE))
271-
$(GIT) -C "$(srcdir)" branch -D gh-$(PR)
269+
$(GIT_IN_SRC) remote rm fork-$(PR)
270+
$(GIT_IN_SRC) worktree remove $(notdir $(GITHUB_UPDATE_WORKTREE))
271+
$(GIT_IN_SRC) branch -D gh-$(PR)
272272

273273
.PHONY: pull-github
274274
pull-github: fetch-github
275275
$(call pull-github,$(PR))
276276

277277
define pull-github
278-
$(eval GITHUB_MERGE_BASE := $(shell $(GIT) -C "$(srcdir)" log -1 --format=format:%H))
279-
$(eval GITHUB_MERGE_BRANCH := $(shell $(GIT) -C "$(srcdir)" symbolic-ref --short HEAD))
278+
$(eval GITHUB_MERGE_BASE := $(shell $(GIT_LOG_FORMAT):%H -1)
279+
$(eval GITHUB_MERGE_BRANCH := $(shell $(GIT_IN_SRC) symbolic-ref --short HEAD))
280280
$(eval GITHUB_MERGE_WORKTREE := $(shell mktemp -d "$(srcdir)/gh-$(1)-XXXXXX"))
281-
$(GIT) -C "$(srcdir)" worktree prune
282-
$(GIT) -C "$(srcdir)" worktree add $(notdir $(GITHUB_MERGE_WORKTREE)) "gh-$(1)"
281+
$(GIT_IN_SRC) worktree prune
282+
$(GIT_IN_SRC) worktree add $(notdir $(GITHUB_MERGE_WORKTREE)) "gh-$(1)"
283283
$(GIT) -C "$(GITHUB_MERGE_WORKTREE)" rebase $(GITHUB_MERGE_BRANCH)
284284
$(eval COMMIT_GPG_SIGN := $(COMMIT_GPG_SIGN))
285285
$(if $(filter true,$(COMMIT_GPG_SIGN)), \
@@ -294,7 +294,7 @@ fetch-github-%:
294294
295295
.PHONY: checkout-github-%
296296
checkout-github-%: fetch-github-%
297-
$(GIT) -C "$(srcdir)" checkout "gh-$*"
297+
$(GIT_IN_SRC) checkout "gh-$*"
298298
299299
.PHONY: pr-% pull-github-%
300300
pr-% pull-github-%: fetch-github-%
@@ -433,7 +433,7 @@ ifneq ($(DOT_WAIT),)
433433
endif
434434

435435
ifeq ($(HAVE_GIT),yes)
436-
REVISION_LATEST := $(shell $(CHDIR) $(srcdir) && $(GIT) log -1 --format=%H 2>/dev/null)
436+
REVISION_LATEST := $(shell $(GIT_LOG_FORMAT)%H -1 2>/dev/null)
437437
else
438438
REVISION_LATEST := update
439439
endif
@@ -495,7 +495,7 @@ endif
495495
update-deps:
496496
$(eval update_deps := $(shell date +update-deps-%Y%m%d))
497497
$(eval deps_dir := $(shell mktemp -d)/$(update_deps))
498-
$(eval GIT_DIR := $(shell $(GIT) -C $(srcdir) rev-parse --absolute-git-dir))
498+
$(eval GIT_DIR := $(shell $(GIT_IN_SRC) rev-parse --absolute-git-dir))
499499
$(GIT) --git-dir=$(GIT_DIR) worktree add $(deps_dir)
500500
cp $(tooldir)/config.guess $(tooldir)/config.sub $(deps_dir)/tool
501501
[ -f config.status ] && cp config.status $(deps_dir)
@@ -543,13 +543,13 @@ matz: up
543543
$(eval NEW := $(MAJOR).$(MINOR).0)
544544
$(eval message := Development of $(NEW) started.)
545545
$(eval files := include/ruby/version.h include/ruby/internal/abi.h)
546-
$(GIT) -C $(srcdir) mv -f NEWS.md doc/NEWS/NEWS-$(OLD).md
547-
$(GIT) -C $(srcdir) commit -m "[DOC] Flush NEWS.md"
546+
$(GIT_IN_SRC) mv -f NEWS.md doc/NEWS/NEWS-$(OLD).md
547+
$(GIT_IN_SRC) commit -m "[DOC] Flush NEWS.md"
548548
sed -i~ \
549549
-e "s/^\(#define RUBY_API_VERSION_MINOR\) .*/\1 $(MINOR)/" \
550550
-e "s/^\(#define RUBY_ABI_VERSION\) .*/\1 0/" \
551551
$(files:%=$(srcdir)/%)
552-
$(GIT) -C $(srcdir) add $(files)
552+
$(GIT_IN_SRC) add $(files)
553553
$(BASERUBY) -C $(srcdir) -p -00 \
554554
-e 'BEGIN {old, new = ARGV.shift(2); STDOUT.reopen("NEWS.md")}' \
555555
-e 'case $$.' \
@@ -559,8 +559,8 @@ matz: up
559559
-e 'next if /^[\[ *]/ =~ $$_' \
560560
-e '$$_.sub!(/\n{2,}\z/, "\n\n")' \
561561
$(OLD) $(NEW) doc/NEWS/NEWS-$(OLD).md
562-
$(GIT) -C $(srcdir) add NEWS.md
563-
$(GIT) -C $(srcdir) commit -m "$(message)"
562+
$(GIT_IN_SRC) add NEWS.md
563+
$(GIT_IN_SRC) commit -m "$(message)"
564564

565565
tags:
566566
$(MAKE) GIT="$(GIT)" -C "$(srcdir)" -f defs/tags.mk

template/Makefile.in

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -748,5 +748,4 @@ yes-test-syntax-suggest: $(PREPARE_SYNTAX_SUGGEST)
748748
no-test-syntax-suggest:
749749

750750
yesterday:
751-
$(GIT) -C $(srcdir) reset --hard \
752-
`$(GIT) -C $(srcdir) log -1 --before=00:00+0900 --format=%H`
751+
$(GIT_IN_SRC) reset --hard `$(GIT_LOG_FORMAT):%H -1 --before=00:00+0900`

win32/Makefile.sub

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,7 +1336,7 @@ $(RCFILES): $(RBCONFIG) $(srcdir)/revision.h $(srcdir)/win32/resource.rb
13361336

13371337
update-benchmark-driver:
13381338
$(GIT) clone https://github.com/benchmark-driver/benchmark-driver $(srcdir)/benchmark/benchmark-driver || \
1339-
$(GIT) -C $(srcdir)/benchmark/benchmark-driver pull origin master
1339+
$(GIT_IN_SRC)/benchmark/benchmark-driver pull origin master
13401340

13411341
$(ruby_pc): $(RBCONFIG)
13421342
@$(BOOTSTRAPRUBY) $(tooldir)/expand-config.rb \
@@ -1507,5 +1507,5 @@ exts: rubyspec-capiext
15071507

15081508
yesterday:
15091509
for /f "usebackq" %H in \
1510-
(`$(GIT) -C $(srcdir) log -1 "--before=00:00+0900" "--format=%H"`) do \
1511-
$(GIT) -C $(srcdir) reset --hard %%H
1510+
(`$(GIT_LOG_FORMAT):%H -1 "--before=00:00+0900"`) do \
1511+
$(GIT_IN_SRC) reset --hard %%H

0 commit comments

Comments
 (0)