Re: [PATCH v4 2/2] shallow: handling fetch relative-deepen
- From
Samo Pogačnik <samo_pogacnik@t-2.net>
- Date
- Feb 14, 2026, 09:40 UTC
- Message-ID
- <c55447544d68c3f98532b1d32183465c8f175ff8.camel@t-2.net>
- In-Reply-To
- <aYyGTmS6fEb2QfBU@pks.im>
On Wed, 2026-02-11 at 14:38 +0100, Patrick Steinhardt wrote:
Show 49 quoted lines
> On Fri, Jan 16, 2026 at 10:31:01PM +0000, Samo Pogačnik via GitGitGadget
> wrote:
>
> > @@ -881,29 +838,14 @@ static void deepen(struct upload_pack_data *data, int
> > depth)
> > struct object *object = data-
> > >shallows.objects[i].item;
> > object->flags |= NOT_SHALLOW;
> > }
> > - } else if (data->deepen_relative) {
> > - struct object_array reachable_shallows = OBJECT_ARRAY_INIT;
> > - struct commit_list *result;
> > -
> > - /*
> > - * Checking for reachable shallows requires that our refs
> > be
> > - * marked with OUR_REF.
> > - */
> > -
> > refs_head_ref_namespaced(get_main_ref_store(the_repository),
> > - check_ref, data);
> > - for_each_namespaced_ref_1(check_ref, data);
> > -
> > - get_reachable_list(data, &reachable_shallows);
> > - result = get_shallow_commits(&reachable_shallows,
> > - depth + 1,
> > - SHALLOW, NOT_SHALLOW);
> > - send_shallow(data, result);
> > - free_commit_list(result);
> > - object_array_clear(&reachable_shallows);
> > } else {
> > struct commit_list *result;
> >
> > - result = get_shallow_commits(&data->want_obj, depth,
> > + if (data->deepen_relative)
> > + get_shallows_depth(data);
>
> Okay, so here we now essentially call `get_shallow_commits()` twice. The
> first time we compute `data->deepen_relative`, only to then pass it back
> to `get_shallow_commits()` a second time. That feels quite strange to
> me. Can't we have `get_shallow_commits()` handle this for us directly in
> a single call?
>
> > + result = get_shallow_commits(&data->want_obj, NULL, NULL,
> > + data->deepen_relative + depth,
> > SHALLOW, NOT_SHALLOW);
> > send_shallow(data, result);
> > free_commit_list(result);
> I have additional dilemma regarding handling this in a single call. Wouldn't it be generally good/useful to have a separate function in shallow.c just for measuring current absolute depth instead of blending the measurement into get_shallow_commits()?
Thanks, Samo