"GOT", but the "O" is a cute, smiling sun Index | Thread

From:
Stefan Sperling <stsp@stsp.name>
Subject:
Re: got: wrong order of arguments in error reported by 'got diff'
To:
Mikhail <mp39590@gmail.com>
Cc:
gameoftrees@openbsd.org
Date:
Tue, 4 Oct 2022 12:47:35 +0200

Download raw body.

On Mon, Oct 03, 2022 at 02:04:15PM +0300, Mikhail wrote:
> I've following setup:
> 
> edge:~/work/got$ got br -l
>   jk: d6267a62d388995cbc79bb58ce9db7946fda0554
>   limit: 874f083e3301c63c77340ef9263c77bcb60514e8
> * main: 47b307cd821b00964d3c5aea35c86689df2fe26d
>   origin/HEAD: refs/remotes/origin/main
>   origin/main: 47b307cd821b00964d3c5aea35c86689df2fe26d
> 
> When I try to issue 'got diff master limit' (notice, 'master' instead of
> 'main', it was a typo) I get following error:
> 
> edge:~/work/got$ got diff master limit
> got: limit: No such file or directory
> 
> I think it's misleading to parse arguments from the end for such usage,
> personally I'd prefer it to tell that 'master' not found, it could point
> me to real source of the problem. I understand that in such scenario got
> parses 'master' and 'limit' as paths, not as branches.
> 
> I also considered changes in got_worktree_resolve_path(), in branch when
> we get realpath(3), but current code deliberately ignores ENOENT error
> from it, and I don't fully understand why.
> 
> Proposed patch:

This patch breaks regress tests.
In particular, the proposed change breaks this case in diff_basic tests:
 
  # different order of arguments results in same output order

I don't see an easy way to improve the error message while also keeping
diff output consistent. This is the downside of making 'got diff' flexible
in terms of which arguments it accepts. I don't think it is a big problem.