Download raw body.
got_worktree_open: always recognize locked worktree
On Tue, Sep 05, 2023 at 03:49:10PM +0200, Christian Weisgerber wrote:
> Let's say I have a worktree that is locked by some other command.
>
> $ got log
> got: worktree already locked
> $ tog
> tog: no git repository found
>
> Wait, what?
>
> That problem was introduced by
> df6221c7 use a separate .cvg meta data directory for cvg(1) work trees
>
> In got_worktree_open():
>
> + if (meta_dir == NULL) {
> + for (i = 0; i < nitems(meta_dirs); i++) {
> + err = open_worktree(worktree, worktree_path,
> + meta_dirs[i]);
> + if (err == NULL)
> + break;
> + }
>
> That ignores the GOT_ERR_WORKTREE_BUSY error from .got, proceeds
> to try .cvg, and reports the error resulting from a missing .cvg.
> It doesn't affect got(1), because that always uses the .got directory.
>
> Does this look like a sensible fix?
>
> diff /home/naddy/got
> commit - 2cafc7864a7ffed14fede7310877bc28c6e7ef8f
> path + /home/naddy/got
> blob - c3846b45dec95fcd923225f11b5f013d97fc39c0
> file + lib/worktree_open.c
> --- lib/worktree_open.c
> +++ lib/worktree_open.c
> @@ -286,7 +286,8 @@ got_worktree_open(struct got_worktree **worktree, cons
> for (i = 0; i < nitems(meta_dirs); i++) {
> err = open_worktree(worktree, worktree_path,
> meta_dirs[i]);
> - if (err == NULL)
> + if (err == NULL ||
> + err->code == GOT_ERR_WORKTREE_BUSY)
> break;
> }
> } else
Yes, this fix is ok.
Thanks, I had noticed this issue as well but did not yet get around
to debugging it.
got_worktree_open: always recognize locked worktree