[PATCH] D53414: Add instructions for migrating branches from one git repository to another.

Fedor Sergeev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 24 05:13:29 PDT 2018


fedor.sergeev added inline comments.


================
Comment at: llvm/docs/Proposals/GitHubMove.rst:934-935
+  $ git log -n1 --pretty="%aD %at" $(git merge-base origin/master my-branch)
+  $ git log -n1 --since <date from old-base-commit> \
+      --author <author from old-base-commit>
+  $ git merge <new-base-commit>
----------------
fedor.sergeev wrote:
> danilaml wrote:
> > jlebar wrote:
> > > fedor.sergeev wrote:
> > > > I'm afraid this wont work. --since sets a bottom limit for the commits shown with git-log, but git-log starts from the top (HEAD), so in most cases it will be equivalent to git log -n1 --author <xxx>, which is absolutely not whats needed here.
> > > > 
> > > > Perhaps doing both --since/--until can do the trick. And if we find the times of commits reliable enough then we can automate it:
> > > > 
> > > > merge_base=$(git merge-base origin/master my-branch)
> > > > merge_time=$(git log -n1 --pretty=%at $merge_base)
> > > > merge_author=$(git log -n1 --pretty="%an <%ae>" $merge_base)
> > > > git log -n1 --since="@$merge-time" --until="@$merge_time" --author="$merge_author"
> > > Added --until.  I decided not to script it because this is not 100% sound, and so I'd rather encourage a human to be in the loop.
> > How would that deal with multiple merges (not necessarily only with origin/master) with many conflicts? Would that essentially require to manually redo all merges?
> Then you still need to add %an <%ae> to the merge-base description format, e.g.:
>   git log -n1 --pretty="format:Date-Time: %aD %at%nAuthor: %an <%ae>%nDescription:%s" $(git merge-base origin/master my-branch)
> so users have something to copy-paste from.
> How would that deal with multiple merges (not necessarily only with origin/master) 
This is not trying to recreate all the merges.
It just a single *additional* merge (done right below this thread of comments).
This merge will essentially join two disjoint histories (having a lot of duplication there for all the upstream
commits that happened to be in your own monorepo).

Recreating merges without duplicating upstream commits requires substantial complications in history rewrite ala git filter-branch and are not for the faint of heart...


https://reviews.llvm.org/D53414





More information about the llvm-commits mailing list