"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Stefan Sperling <stsp@stsp.name>
Subject:
Re: got selective import / merging
To:
Jerome Kasper <neon.king.fr@gmail.com>
Cc:
gameoftrees@openbsd.org
Date:
Wed, 20 Nov 2019 23:01:41 +0100

Download raw body.

Thread
On Wed, Nov 20, 2019 at 01:18:59AM +0100, Jerome Kasper wrote:
> Hi everyone!
> 
> I've been thinking about the fact that sometimes, when one start
> a project or extend another , one has sometime to import only
> some relevant parts of another git repo.
> 
> Let's take the example of amdgpu. linux amdgpu will be evolving
> forward and as it's the main source where hardware providers
> contribute. In order to import / update amdgpu in openbsd,
> developpers (jsg@?) will have to import / merge some specific
> parts of the linux tree which exist as a whole but that we just want
> to import / merge some specific part.

This is called "vendor branch pattern", where 3rd party vendor code
obtained in some way is integrated into a version control repository.

The term "vendor branch" comes from a time when public version control
repositories were not the norm. So when project A wanted to integrate
code from project B and track changes made to project B code, project A
would import releases of project B onto a "vendor branch".

CVS has built-in special-case branching support for this:
http://cvsbook.red-bean.com/cvsbook.html#Tracking%20Third-Party%20Sources%20(Vendor%20Branches)

SVN documents the concept as well:
http://svnbook.red-bean.com/en/1.8/svn.advanced.vendorbr.html

> What would be the right way to do it with got ? i've been thinking
> about creating something like a "got cherrypick {import|merge}"
> option with something like a regular expression that would match
> the relevant files.

> 1.Is that something that would be wanted?

Yes!

> 2.Is there already a clean way to do that?

The 'got import' command is intended to start a vendor branch.

It would be nice if 'got import' could import files into path prefix 
in the repository, rather than only into the root directory. This is
not essential but might be useful for working with vendor branches.

> 3.Am i expecting too much in the current state of things?

What is still missing is an easy way to update a vendor branch with
newer versions of vendor code.

Say you've already done an initial import of amgpu code in the repository,
and now you have a new version of amdgpu code on disk.

We could either add an "incremental mode" to 'got import' where it takes
the directory on disk and commits a new tree, which looks just like the
directory on disk, to the same branch which was used in the initial import.

Or we could have command to reconfigure a work tree to match another
directory on disk. So given a work tree of the current state of the
vendor branch, make that work tree look like the directory which contains
the new version of vendor code, with added/deleted/changed files.

The big problem for UI design is that users will almost certainly pass
the wrong arguments and commit to the wrong branch some day, or use the
wrong work tree by accident.

In any case, once both the old and new tree of vendor code are in the
repository, you can view a diff the between the two versions, and also
merge the changes to the main branch with 'got cherrypick'.

> 4. Might i help about working on something like that ?
> 5. if 4 is yes , where should i start looking in the source?

As a first step, perhaps try to create a patch to make 'got import' put
files under a path prefix instead of the root directory.

Say we had the following directory tree on disk:

.
`-- mydir
    `-- file.c

1 directory, 1 file

And we wanted to import this directory and file into a repository under
'usr/lib/' (assuming this was the desired location of the code on the main
branch), such that the committed repository tree looked like this:

.
`-- usr
    `-- lib
        `-- mydir
            `-- file.c

3 directories, 1 file

To achieve this, currently we have to create usr/lib on disk, move my
directory inside, and pass the 'usr' directory to 'got import':

  mkdir -p usr/lib
  mv mydir usr/lib
  got import -b myvendorbranch -r /var/git/myrepo.git usr

It would be nice if we could specify a path prefix in a got import
command line instead, like this:

  got import -b myvendorbranch -r /var/git/myrepo.git -p usr/lib mydir