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

From:
Stefan Sperling <stsp@stsp.name>
Subject:
Re: got patch vs unchanged files
To:
Omar Polo <op@omarpolo.com>
Cc:
gameoftrees@openbsd.org
Date:
Fri, 18 Mar 2022 20:59:37 +0100

Download raw body.

Thread
On Fri, Mar 18, 2022 at 06:47:06PM +0100, Omar Polo wrote:
> While testing a diff for an unrelated thing I noticed that `got patch'
> fails to handle the case of a patch that tries to add a file already
> versioned.
> 
> Long story short, I'm using got_worktree_status to check the status of a
> file before applying the patch.  got_worktree_status calls
> worktree_status with report_unchanged=0, so the `can_add' callback in
> lib/patch.c doesn't get called and check_file_status assumes that it's
> possible to add the file.
> 
> Patch below adds another argument to got_worktree_status so the caller
> can decide to have also unchanged files reported to the callback.  If we
> don't want to change got_worktree_status I have another idea to solve
> this issue locally in patch.c, but I thought this was the easiest way.

Alternatively, you could move worktree-specific functionality from patch.c
into worktree.c. Then you would get direct access to the static function
worktree_status() from your new worktree.c function which patch.c would call.

FWIW, this is also how other commands like rebase and histedit check
their work tree preconditions.