Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 4 Oct 2021 10:32:01 -0600
From:      Tom Russo <russo@bogodyn.org>
To:        freebsd-questions@freebsd.org
Subject:   Re: manually patching a port gets overwritten when the tree updates
Message-ID:  <YVssgaHrRm/lXtsW@bogodyn.org>
In-Reply-To: <YVsZ8HLs1AWzXxdw@ceres.zyxst.net>
References:  <YVsZ8HLs1AWzXxdw@ceres.zyxst.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Oct 04, 2021 at 04:12:48PM +0100, we recorded a bogon-computron collision of the <tech-lists@zyxst.net> flavor, containing:
> Hi,
> 
> I thought 'git stash' would take care of this but it doesn't.
> 
> Sometimes a port breaks then a PR is raised and then sometimes someone
> posts a patch. I'll apply it to my ports tree 'default' in poudriere and
> build the port. If it builds ok I'll run 'git stash' then 'poudriere
> ports -u -v' and the ports tree updates.

Git stash takes all the current changes, records them so they can be reapplied 
later, and undoes them, leaving the repo in its state prior to your local
changes.

> If I don't run 'git stash' the update will fail.

So stashing your local changes puts the git repo back in the state it was
before you changed anything, and the update works.

> But if I try to build the affected port again, after successfully
> updating the tree, it's as if the patch was never applied. The same sort
> of thing happens with the usual ports tree (in other words, without
> poudriere in the equation)

That is absolutely the correct behavior.  Problem is you haven't reapplied
the changes out of the stash afterwards.

If you do a "git stash list" you'll find that there is a stash entry for
every change you stashed.  You can "git stash pop" them one at a time to 
reapply them (this will remove the stash entry at the same time it's reapplied).

Think of the stash as a stack where you store changes that won't be committed
and pushed to the repo, and where they can be retrieved as needed.

You might want to look at https://git-scm.com/book/en/v2/Git-Tools-Stashing-and-Cleaning
if you want to understand the stash better.

> I want manually applied patches to remain applied, and I want my ports
> tree to stay as current as possible. How is this accomplished?

Using git stash is a reasonable way to do it, you just have to remember to 
pop after you update.  And later remember to stash all local changes again 
before you update the tree.

Another option is to maintain your local patches on a branch and keep that 
branch rebased to main.  That's what I do to keep around a handful of patches
that I know work for me but that haven't yet made it into the main repo
because the package maintainer hasn't accepted them yet.  That might require
more git play than you're interested in.

-- 
Tom Russo    KM5VY
Tijeras, NM  

 echo "prpv_a'rfg_cnf_har_cvcr" | sed -e 's/_/ /g' | tr [a-m][n-z] [n-z][a-m]




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?YVssgaHrRm/lXtsW>