git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/2] refs: switch for_each_replace_ref back to use a ref_store

From
Stefan Beller <sbeller@google.com>
Date
Jul 31, 2018, 00:41 UTC
Message-ID
<CAGZ79kbwt2RGo2Z2ARSzfHOZdL_VWF1sR+=EE=QWx1ibLL+KwQ@mail.gmail.com>
In-Reply-To
<20180731001858.122968-1-jonathantanmy@google.com>
On Mon, Jul 30, 2018 at 5:19 PM Jonathan Tan <jonathantanmy@google.com> wrote:
Show 5 quoted lines
>
> > So let's go back to the clean API, just requiring a ref_store as an
> > argument.
>
> Here, you say that we want ref_store as an argument...
I do.
Show 14 quoted lines
>
> > -int for_each_replace_ref(struct repository *r, each_ref_fn fn, void *cb_data)
> > +int for_each_replace_ref(each_ref_fn fn, void *cb_data)
> >  {
> > -     return do_for_each_ref(get_main_ref_store(r),
> > +     return do_for_each_ref(get_main_ref_store(the_repository),
> >                              git_replace_ref_base, fn,
> >                              strlen(git_replace_ref_base),
> >                              DO_FOR_EACH_INCLUDE_BROKEN, cb_data);
>
> ...but there is no ref_store as an argument here - instead, the
> repository argument is deleted with no replacement. I presume you meant
> to replace it with a ref_store instead? (This will also fix the issue
> that for_each_replace_ref only works on the_repository.)

Yes, I would want to pass in a ref_store and use that as the first argument in do_for_each_ref for now.

That would reduce the API uncleanliness to have to pass the repository twice.
> Taking a step back, was there anything that prompted these patches?
I am flailing around on how to approach the ref store and the repository:
* I dislike having to pass a repository 'r' twice. (current situation after
  patch 1. That patch itself is part of Stolees larger series to address
  commit graphs and replace refs, so we will have that one way or another)
* So I sent out some RFC patches to have the_repository in the ref store
  and pass the repo through to all the call backs to make it easy for
  users inside the callback to do basic things like looking up commits.
* both Duy (on list) and Brandon (privately) expressed their dislike for
  having the refs API bloated with the repository, as the repository is
  not needed per se in the ref store.
* After some reflection I agreed with their concerns, which let me
  to re-examine the refs API: all but a few select functions take a
  ref_store as the first argument (or imply to work on the ref store
  in the_repository, then neither a repo nor a ref store argument is
  there)
* I want to bring back the cleanliness of the API, which is to take a
  ref store when needed instead of the repository, which is rather
  bloated.
> Maybe at least the 2nd one should wait until we have a situation that
> warrants it (for example, if we want to for_each_replace_ref(), but we
> only have a ref_store, not a repository).

okay, then let's drop this series for now and I'll re-examine what is needed to have submodule handling in-core.

Thanks, Stefan

Previous: Jonathan TanNext: Duy Nguyen
Message 12 of 14 in “Migrate the refs API to take the repository argument”
  1. 0/3 Migrate the refs API to take the repository argumentStefan Beller, Jul 27, 2018
  2. 1/3 refs.c: migrate internal ref iteration to pass thru repository argumentStefan Beller, Jul 27, 2018
  3. 2/3 refs: introduce new API, wrap old API shallowly around new APIStefan Beller, Jul 27, 2018
  4. Duy NguyenJul 27, 2018
  5. Brandon WilliamsJul 27, 2018
  6. Stefan BellerJul 27, 2018
  7. Duy NguyenJul 27, 2018
  8. 0/2 Cleanup refs API [WAS: Re: [PATCH 2/3] refs: introduce new API, wrap old API shallowly around new API]Stefan Beller, Jul 30, 2018
  9. 1/2 replace-objects: use arbitrary repositoriesStefan Beller, Jul 30, 2018
  10. 2/2 refs: switch for_each_replace_ref back to use a ref_storeStefan Beller, Jul 30, 2018
  11. Jonathan TanJul 31, 2018
  12. Stefan BellerJul 31, 2018
  13. Duy NguyenJul 31, 2018
  14. 3/3 replace: migrate to for_each_replace_repo_refStefan Beller, Jul 27, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.