Skip to content

Commit

Permalink
Rebase the pull request in a worktree
Browse files Browse the repository at this point in the history
A pull request based on an old commit may rewind too many files,
even if unnecessary.  As rewinding some files, e.g., common header
files, configure.ac, will result in full-rebuild, rebase in a
separate directory to get rid of such rewind.
  • Loading branch information
nobu committed Apr 25, 2019
1 parent d0ba4ab commit 09ce223
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions defs/gmake.mk
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,12 @@ fetch-github:

.PHONY: merge-github
merge-github: fetch-github
$(Q) $(eval GITHUB_MERGE_BASE := $(shell git -C "$(srcdir)" log -1 --format=format:%H))
git -C "$(srcdir)" checkout "gh-$(PR)"
git -C "$(srcdir)" rebase -
git -C "$(srcdir)" checkout -
$(eval GITHUB_MERGE_BASE := $(shell git -C "$(srcdir)" log -1 --format=format:%H))
$(eval GITHUB_MERGE_BRANCH := $(shell git -C "$(srcdir)" symbolic-ref --short HEAD))
$(eval GITHUB_MERGE_WORKTREE := $(shell mktemp -d gh-$(PR)-XXXXXX))
git -C "$(srcdir)" worktree add $(GITHUB_MERGE_WORKTREE) "gh-$(PR)"
git -C "$(GITHUB_MERGE_WORKTREE)" rebase $(GITHUB_MERGE_BRANCH)
git -C "$(srcdir)" worktree remove "$(GITHUB_MERGE_WORKTREE)"
git -C "$(srcdir)" merge --ff-only "gh-$(PR)"
git -C "$(srcdir)" branch -D "gh-$(PR)"
git -C "$(srcdir)" filter-branch -f \
Expand Down

0 comments on commit 09ce223

Please sign in to comment.