Re: git: "overlay" of own remote-branch on official freebsd-ports repo

From: FreeBSD User <freebsd_at_walstatt-de.de>
Date: Wed, 13 Oct 2021 06:18:32 UTC
On Tue, 12 Oct 2021 10:01:00 -0600
Warner Losh <imp@bsdimp.com> wrote:

> On Tue, Oct 12, 2021 at 9:32 AM FreeBSD User <freebsd@walstatt-de.de> wrote:
> 
> > I do not know whether I'm right in this list, but since the subject is
> > mutual so common
> > in development and GIT, I have the strong feeling I'm right here.
> >
> > Im quite new to git, so apologizes for any inconvenience reading my
> > question.
> >
> > Using poudriere on 14-CURRENT to create a selection of packages also
> > includes updating
> > the ports tree on a regular basis. I maintain some "special" ports not
> > official part of
> > the FreeBSD ports tree and some other ports are part of those I'm supposed
> > to maintain. I
> > keep personally track of the changes in a git repo of my own.
> >
> > Now I'd like to "overlay" the official portas repo by that of mine to
> > include changes.
> > With SVN, there was no problem to have local changes not overwritten by
> > regular updates
> > of the ports tree as long as the specific port in question wasn't updated
> > by the official
> > site. In git, this behaviour seems to have changed, any changes I made so
> > far are gone
> > after poudriere is adviced to update the tree.
> >
> > I'd like to ask how FreeBSD developers and maintainers do the trick. If
> > there is an
> > official cookbook fpr maintainers (I haven't found it yet ...), please be
> > so kind and
> > refer to it. Any advice is welcome.
> >  
> 
> tl;dr: branches are cheap and well supported in git. You just make a branch
> for your
> local changes, and update that however you see fit.
> 
> For ports I have like that, I've just created a branch in git. I rebase the
> branch forward
> each time I update. For me, though, the branch is mostly uncommitted in
> upstream
> changes that may not be ready for some reason... There's two ways to do
> this.
> You can just merge, which is OK if you aren't upstreaming the changes, or
> you can
> rebase if the changes or a subset of the changes likely will end up in
> FreeBSD.
> 
> Others might recommend stash, but I find it too unwieldy for more than a
> couple
> of things.
> 
> So the workflow would be:
> 
> git clone -o freebsd <freebsd-ports-repo-of-choice> freebsd-ports
> cd freebsd-ports
> git checkout -b hartmann-specials
> <copy over your special ports or changes to ports and commit them>
> 
> Now, you can use poudriere-ports with the -B hartmann-specials and your
> local repo as the source of truth.
> 
> to update
> 
> cd freebsd-ports
> git checkout main
> git pull --rebase                              # or --ff-only, I use
> --rebase because I push and it's habit
> git rebase -i main hartmann-specials
> 
> Note: if you need to have multiple trees with this branch you are modifying,
> then a git pull --rebase will let you cope with the forced-pushes this
> method
> would require. You can also do it with git merge on hartmann-specials if you
> don't need to keep the changes separate or you have a lot of downstreams
> that would get cranky, which doesn't sound like the case here.
> 
> Warner

As I wrote, I'm quite new to git and always surprised. Thanks for the help and
the neat tip. I'll try.

Kind regards and thanks,

Oliver