Re: manually patching a port gets overwritten when the tree updates

From: Matthew Seaman <matthew_at_FreeBSD.org>
Date: Mon, 04 Oct 2021 15:42:15 UTC
On 04/10/2021 16:12, tech-lists wrote:
> 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.
> 
> If I don't run 'git stash' the update will fail.
> 
> 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)
> 
> I want manually applied patches to remain applied, and I want my ports
> tree to stay as current as possible. How is this accomplished?

One workflow that should do what you want is:

Create a branch to apply the patches to, and commit them locally (ie. 
something like `git checkout -b new-branch-name`; `git add 
{patched-files}`; `git commit`).  Then whenever you pull updates down 
against main, you can either merge them to your branch, or rebase your 
branch to the current tip of main.

Otherwise, if you're using 'git stash' that saves your uncommitted 
changes, and reverts your tree to the last committed state.  Which then 
allows you to pull and update to the latest.  But then you have to run 
`git stash pop` to re-apply your uncommitted changes.  Running `git 
status` and `git diff` before and after `git stash` and `git stash pop` 
should make it clear what's going on.

	Cheers,

	Matthew