Download raw body.
improve got fetch error reporting
On 23-02-07 04:00PM, Stefan Sperling wrote:
> On Tue, Feb 07, 2023 at 01:56:56PM +0100, Stefan Sperling wrote:
> > On Tue, Feb 07, 2023 at 11:16:34PM +1100, Mark Jamsek wrote:
> > > Nice! I really like the refactoring of fetch_pack(), and I very much
> > > appreciate how tricky this was! I feel like I should've studied the
> > > fetch docs and code before instigating this change so thank you :)
> > >
> > > minor nits inline but otherwise ok
> >
> > I have committed my patch.
> > Please put yours on top with my ok. Thanks!
>
> We're not quite done yet with this rabbit hole.
hehe I'm feeling really guilty! But thanks again for chipping away at
this :)
> Recall how we sometimes need to our update work tree to a reference which is
> outside the "refs/heads/" namespace, e.g. when rebasing on top of origin/main?
> Well, we don't want to fetch the work tree's branch in such cases...
Yes, makes sense! ok
> diff /home/stsp/src/got
> commit - 188f8dcf2c1c15bf37859e3b587bc6331fd5a097
> path + /home/stsp/src/got
> blob - 83d6a791c83d96ed0e79da912f70428804dfcb3a
> file + got/got.c
> --- got/got.c
> +++ got/got.c
> @@ -2297,6 +2297,7 @@ cmd_fetch(int argc, char *argv[])
> int verbosity = 0, fetch_all_branches = 0, list_refs_only = 0;
> int delete_refs = 0, replace_tags = 0, delete_remote = 0;
> int *pack_fds = NULL, have_bflag = 0;
> + const char *worktree_branch = NULL;
>
> TAILQ_INIT(&refs);
> TAILQ_INIT(&symrefs);
> @@ -2538,6 +2539,14 @@ cmd_fetch(int argc, char *argv[])
> if (error)
> goto done;
>
> + if (worktree && !have_bflag) {
> + const char *refname;
> +
> + refname = got_worktree_get_head_ref_name(worktree);
> + if (strncmp(refname, "refs/heads/", 11) == 0)
> + worktree_branch = refname;
> + }
> +
> fpa.last_scaled_size[0] = '\0';
> fpa.last_p_indexed = -1;
> fpa.last_p_resolved = -1;
> @@ -2549,9 +2558,7 @@ cmd_fetch(int argc, char *argv[])
> error = got_fetch_pack(&pack_hash, &refs, &symrefs, remote->name,
> remote->mirror_references, fetch_all_branches, &wanted_branches,
> &wanted_refs, list_refs_only, verbosity, fetchfd, repo,
> - (worktree != NULL && !have_bflag) ?
> - got_worktree_get_head_ref_name(worktree) : NULL,
> - fetch_progress, &fpa);
> + worktree_branch, fetch_progress, &fpa);
> if (error)
> goto done;
>
>
--
Mark Jamsek <fnc.bsdbox.org>
GPG: F2FF 13DE 6A06 C471 CA80 E6E2 2930 DC66 86EE CF68
improve got fetch error reporting