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

From:
Stefan Sperling <stsp@stsp.name>
Subject:
Re: make got fetch default to work tree's current branch
To:
Mark Jamsek <mark@jamsek.com>
Cc:
Game of Trees <gameoftrees@openbsd.org>
Date:
Wed, 1 Feb 2023 16:23:24 +0100

Download raw body.

Thread
On Thu, Feb 02, 2023 at 12:53:45AM +1100, Mark Jamsek wrote:
> I thought I'd check the recent todo updates before zzz and noticed
> stsp's new 'got fetch' item. I'm not entirely sure, but it seems to be
> as simple as this: if in a work tree and -b is not specified, make the
> work tree's current branch the wanted branch.
> 
> A potential downside to this behaviour is that, if in a branch that is
> not on the remote, fetch will now fail where previously it would
> succeed.

Yes, ok for this diff. Let's try it and see.

I think the new behaviour is better especially because it mirrors
how 'got send' behaves.

Also, with the current behaviour, I have observed 'got fetch' downloading
a pack file but not updating any references, which looks weird. Refs were
updated only when I ran 'got fetch -b branchname', and this time no pack
file was fetched. This seems like a trap for new users to fall into.

I'd rather be forced to use 'fetch -b' if I want to fetch a branch that is
not currently checked out. If this turns out to be bad for usabilty for
some other reasons, we can reconsider.
 
> diffstat /home/mark/src/got
>  M  got/got.1  |  4+  2-
>  M  got/got.c  |  6+  0-
> 
> 2 files changed, 10 insertions(+), 2 deletions(-)
> 
> diff /home/mark/src/got
> commit - d627976f5ceada12169aa74630bbc0fd9ce071b7
> path + /home/mark/src/got
> blob - fdb4ef70a58be2c0ebaee1bc320ee9ba9a5c82fe
> file + got/got.1
> --- got/got.1
> +++ got/got.1
> @@ -396,8 +396,10 @@ If this option is not specified, a branch resolved via
>  reference namespace.
>  This option may be specified multiple times to build a list of branches
>  to fetch.
> -If this option is not specified, a branch resolved via the remote
> -repository's HEAD reference will be fetched.
> +If this option is not specified, the work tree's current branch
> +will be fetched if invoked within a work tree,
> +otherwise a branch resolved via the remote repository's HEAD reference
> +will be fetched.
>  Cannot be used together with the
>  .Fl a
>  option.
> blob - 29a58f762f6daee7971bdeac8f303124c5d6f1f2
> file + got/got.c
> --- got/got.c
> +++ got/got.c
> @@ -2443,6 +2443,12 @@ cmd_fetch(int argc, char *argv[])
>  				}
>  			}
>  		}
> +		if (TAILQ_EMPTY(&wanted_branches)) {
> +			error = got_pathlist_append(&wanted_branches,
> +			    got_worktree_get_head_ref_name(worktree), NULL);
> +			if (error)
> +				goto done;
> +		}
>  	}
>  	if (remote == NULL) {
>  		repo_conf = got_repo_get_gotconfig(repo);
> 
> -- 
> Mark Jamsek <fnc.bsdbox.org>
> GPG: F2FF 13DE 6A06 C471 CA80  E6E2 2930 DC66 86EE CF68