[llvm-dev] RFC: Dealing with out of tree changes and the LLVM git monorepo

Justin Bogner via llvm-dev llvm-dev at lists.llvm.org
Thu Nov 1 16:57:36 PDT 2018


David Greene <dag at cray.com> writes:
> Justin Bogner via llvm-dev <llvm-dev at lists.llvm.org> writes:
>
>> The layout here is not at all different, only the process by which the
>> repo is generated. I strongly believe that a history preserving
>> conversion is very important if we want to avoid making porting
>> out-of-tree work horribly disruptive.
>
> How would an out-of-tree branch be ported with this new approach?  Do
> you have scripts to do it?

I'll write up some more detailed docs on this, but all you need to do is
a subtree merge to one of the zippered commits. Given an out of tree
branch called $YourBranch, some temporary name for the result
$YourMonorepoBranch, and a remote for the zippered monorepo called
monorepo, this works:

   % merge_base=$(git merge-base $YourBranch monorepo/master)
   % monorepo_commit=$(git log --reverse --ancestry-path --format=%H \
                               $merge_base..monorepo/master | head -1)
   % git checkout $YourMonorepoBranch $monorepo_commit
   % git merge -Xsubtree=llvm $YourMonorepoBranch

Now you have a version of your repo where everything was moved into the
llvm/ folder. You can now update your bots and build scripts, push it to
your internal repo and carry on.

If you want a monorepo view for all of your branches' histories too it's
more involved, but I'm not sure anyone really needs that. In any case,
even if someone does want that the nature of the zipper approach means
it could be done later non-destructively.


More information about the llvm-dev mailing list