From b4b02b77235da1f0e6135f3ae07d6859aa5df5e5 Mon Sep 17 00:00:00 2001 From: Michael Gibney Date: Thu, 18 Mar 2021 17:44:47 -0400 Subject: [PATCH 1/3] document merge-based approach to updating existing PRs --- PRs.md | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/PRs.md b/PRs.md index 1ec168874157..8b82810247b3 100644 --- a/PRs.md +++ b/PRs.md @@ -64,3 +64,43 @@ Look at the PR and create it if it looks good. # This example's PR was at: https://github.com/apache/lucene/pull/2 ``` +3. Instead of rebasing, you can `git merge` the upstream `main` branch from the new +project into your existing PR branch, push the result to your own fork of the new +project, and use that as the basis for creating a PR against the new upstream project. + +This approach works cleanly because the `main` branch on each of the new projects is +a direct descendant of the merge-base (with `lucene-solr/master`) of all existing +PR branches against the legacy joint `lucene-solr` project. + +A benefit of a `merge`-based approach (as opposed to rebasing or applying a patch) is +that commit history (including commit hashes) is preserved, and remains compatible +across projects (and in some multi-commit cases, a merge-based approach can also +avoid the need to "re-resolve" related conflicts in multiple rebased commits). + +NOTE: PRs updated in this way, if merged back into the `main` branch, could result +in an undesirably convoluted (if "correct") commit history. In many cases it may be +preferable to "squash-merge" such PRs (already a common general practice for merging +feature branches in this project). + +``` +# clone new upstream project (optionally supplying remote name "apache" instead +# of "origin") +git clone --origin apache https://github.com/apache/lucene.git +cd lucene +# in Github UI, create [user]'s fork of new project (as in the "rebase" example) +# add [user]'s fork of the new project +git remote add mynewfork https://github.com/[user]/lucene.git +git fetch mynewfork +# add [user]'s fork of the legacy (joint) project +git remote add mylegacyfork https://github.com/[user]/lucene-solr.git +git fetch mylegacyfork +# get the legacy PR's branch: +git checkout --no-track mylegacyfork/LUCENE-XXXX -b LUCENE-XXXX +# merge upstream main branch +git merge apache/main +# after resolving any conflicts and committing the merge, +# push to [user]'s new fork +git push -u mynewfork LUCENE-XXXX +# in Github UI, create PR from mynewfork/LUCENE-XXXX (against apache/main) +# as in the "rebase" example +``` From b7038440eaa6b99128c0ec4f45487a978de84e4f Mon Sep 17 00:00:00 2001 From: Michael Gibney Date: Fri, 19 Mar 2021 09:33:44 -0400 Subject: [PATCH 2/3] add/document setting a higher one-time merge.renameLimit --- PRs.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/PRs.md b/PRs.md index 8b82810247b3..6308909c6d85 100644 --- a/PRs.md +++ b/PRs.md @@ -80,7 +80,7 @@ avoid the need to "re-resolve" related conflicts in multiple rebased commits). NOTE: PRs updated in this way, if merged back into the `main` branch, could result in an undesirably convoluted (if "correct") commit history. In many cases it may be preferable to "squash-merge" such PRs (already a common general practice for merging -feature branches in this project). +feature branches in these projects). ``` # clone new upstream project (optionally supplying remote name "apache" instead @@ -96,8 +96,10 @@ git remote add mylegacyfork https://github.com/[user]/lucene-solr.git git fetch mylegacyfork # get the legacy PR's branch: git checkout --no-track mylegacyfork/LUCENE-XXXX -b LUCENE-XXXX -# merge upstream main branch -git merge apache/main +# merge upstream main branch (a higher `merge.renameLimit` allows `git merge` to +# complete without the warning that it would otherwise print due to the large +# number of files deleted across the TLP split) +git -c merge.renameLimit=7000 merge apache/main # after resolving any conflicts and committing the merge, # push to [user]'s new fork git push -u mynewfork LUCENE-XXXX From e6c9c2d584757cc581f3f3ba846e8a3d9b6ba624 Mon Sep 17 00:00:00 2001 From: Michael Gibney Date: Mon, 22 Mar 2021 09:41:20 -0400 Subject: [PATCH 3/3] adopt @cpoerschke's suggestion for variable-substitution syntax --- PRs.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/PRs.md b/PRs.md index 6308909c6d85..9b0698ddcb70 100644 --- a/PRs.md +++ b/PRs.md @@ -87,12 +87,12 @@ feature branches in these projects). # of "origin") git clone --origin apache https://github.com/apache/lucene.git cd lucene -# in Github UI, create [user]'s fork of new project (as in the "rebase" example) -# add [user]'s fork of the new project -git remote add mynewfork https://github.com/[user]/lucene.git +# in Github UI, create ${user}'s fork of new project (as in the "rebase" example) +# add ${user}'s fork of the new project +git remote add mynewfork https://github.com/${user}/lucene.git git fetch mynewfork -# add [user]'s fork of the legacy (joint) project -git remote add mylegacyfork https://github.com/[user]/lucene-solr.git +# add ${user}'s fork of the legacy (joint) project +git remote add mylegacyfork https://github.com/${user}/lucene-solr.git git fetch mylegacyfork # get the legacy PR's branch: git checkout --no-track mylegacyfork/LUCENE-XXXX -b LUCENE-XXXX @@ -101,7 +101,7 @@ git checkout --no-track mylegacyfork/LUCENE-XXXX -b LUCENE-XXXX # number of files deleted across the TLP split) git -c merge.renameLimit=7000 merge apache/main # after resolving any conflicts and committing the merge, -# push to [user]'s new fork +# push to ${user}'s new fork git push -u mynewfork LUCENE-XXXX # in Github UI, create PR from mynewfork/LUCENE-XXXX (against apache/main) # as in the "rebase" example