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

From:
Stefan Sperling <stsp@stsp.name>
Subject:
Re: git add equivalent – add only selected files
To:
sylvain@saboua.me
Cc:
gameoftrees@openbsd.org
Date:
Thu, 6 Mar 2025 16:47:44 +0100

Download raw body.

Thread
On Thu, Mar 06, 2025 at 12:41:05PM +0100, sylvain@saboua.me wrote:
> I incepted my worktree by following some reddit's user advice
> which had worked for me a few years ago when I started rfdupes:
> https://www.reddit.com/r/openbsd/comments/1b7wl8h/
> 
> The trouble is very simple, for a start : how is `got' supposed to
> know where to look for a repository to add the files to ?
> 
> The error is the following:
> 
> $ pwd
> /var/www/got/public/saboua.xyz
> $ got add /var/www/htdocs/saboua.xyz/doc/*.css
> got: 'got add'needs a work tree in addition to a git repository
> Work trees can be checked out from this Git repository with 'got checkout'.
> The got(1) manual page contains more information.

Got infers a work tree path from the current working directory.

In your case 'got add' tries to find a work tree by checking whether any
of these directories contain a valid .got directory:

  /var/www/got/public/saboua.xyz
  /var/www/got/public/
  /var/www/got/
  /var/www/
  /var/

None of these contain a .got directory so no work tree is found and
the above error is raised.

Assuming you have previously checked out a work tree at the path
/var/www/htdocs/saboua.xyz/ then using this sequence instead should work:

 $ cd /var/www/got/public/saboua.xyz
 $ got add doc/*.css
 $ got commit 

It seems we have a documentation problem. Some commands require a Git
repository while other commands require a Got work tree.

For commands which require a repository we have the -r option and we
document how a repository will be found if this option is omitted.

However, we do not document how commands such as 'got add' will find
their work tree,

Except in the section of 'got info', where the got(1) manual says:

               The work tree to use is resolved implicitly by walking upwards
               from the current working directory.
	
Would having this sentence in the documentation of 'got add' have helped you?