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

Re: [PATCH 1/6] sha1-file.c: remove the_repo from read_object_with_reference()

From
Duy Nguyen <pclouds@gmail.com>
Date
Jun 27, 2019, 13:12 UTC
Message-ID
<CACsJy8Avw0hh61Rr-xAWpOT_J8GKwFq=e4BYtFOfXHvpfpR0rw@mail.gmail.com>
In-Reply-To
<nycvar.QRO.7.76.6.1906271448290.44@tvgsbejvaqbjf.bet>

On Thu, Jun 27, 2019 at 7:54 PM Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:

Show 35 quoted lines
>
> Hi Duy,
>
> On Mon, 24 Jun 2019, Nguyễn Thái Ngọc Duy wrote:
>
> > diff --git a/builtin/grep.c b/builtin/grep.c
> > index 580fd38f41..85da7ee542 100644
> > --- a/builtin/grep.c
> > +++ b/builtin/grep.c
> > @@ -458,7 +458,8 @@ static int grep_submodule(struct grep_opt *opt,
> >               object = parse_object_or_die(oid, oid_to_hex(oid));
> >
> >               grep_read_lock();
> > -             data = read_object_with_reference(&object->oid, tree_type,
> > +             data = read_object_with_reference(opt->repo,
> > +                                               &object->oid, tree_type,
>
> Junio's hunch was absolutely spot on. This conversion is incorrect. If you
> replace this `opt->repo` and...
>
> >                                                 &size, NULL);
> >               grep_read_unlock();
> >
> > @@ -623,7 +624,8 @@ static int grep_object(struct grep_opt *opt, const struct pathspec *pathspec,
> >               int hit, len;
> >
> >               grep_read_lock();
> > -             data = read_object_with_reference(&obj->oid, tree_type,
> > +             data = read_object_with_reference(opt->repo,
>
> ... this one with `the_repository`, t7814 starts passing again.
>
> It makes me very wary of this patch series that this bug has only been
> caught by a CI build. You probably did not run the test suite before
> sending this patch series.

I did. After Junio reported, I've ran a lot more and had the same pass/fail-sometimes behavior.

> I also wonder what the rationale was to deviate from the strategy used in
> the remainder of the call sites, where no attempt was made to use an
> already-available repository pointer that might, or might not, be the
> correct one.

My strategy has always been "use the right repo if available, fall back to the_repo otherwise". This code path has struct repo, my mistake was not realize soon enough that there are two repos, not once (Ironically I made the conversion to add subrepo here).

> It strikes me as a pretty important goal of this patch series to _not_
> change any behavior, and this bug makes me dubious that all diligence has
> been done to assure that.

Sooner or later all the_repo must be converted, what makes _this_ series different from other conversion series? Yes I slipped, I should have been more careful to the parts related to submodule.

-- 
Duy
Previous: Johannes SchindelinNext: Nguyễn Thái Ngọc Duy
Message 4 of 31 in “Kill the_repository in tree-walk.c”
  1. 0/6 Kill the_repository in tree-walk.cNguyễn Thái Ngọc Duy, Jun 24, 2019
  2. 1/6 sha1-file.c: remove the_repo from read_object_with_reference()Nguyễn Thái Ngọc Duy, Jun 24, 2019
  3. Johannes SchindelinJun 27, 2019
  4. Duy NguyenJun 27, 2019
  5. 2/6 tree-walk.c: remove the_repo from fill_tree_descriptor()Nguyễn Thái Ngọc Duy, Jun 24, 2019
  6. Derrick StoleeJun 24, 2019
  7. Junio C HamanoJun 26, 2019
  8. Derrick StoleeJun 26, 2019
  9. 3/6 tree-walk.c: remove the_repo from get_tree_entry()Nguyễn Thái Ngọc Duy, Jun 24, 2019
  10. Derrick StoleeJun 24, 2019
  11. Duy NguyenJun 24, 2019
  12. 4/6 tree-walk.c: remove the_repo from get_tree_entry_follow_symlinks()Nguyễn Thái Ngọc Duy, Jun 24, 2019
  13. 5/6 match-trees.c: remove the_repo from shift_tree*()Nguyễn Thái Ngọc Duy, Jun 24, 2019
  14. 6/6 Use the right 'struct repository' instead of the_repositoryNguyễn Thái Ngọc Duy, Jun 24, 2019
  15. Derrick StoleeJun 24, 2019
  16. Duy NguyenJun 24, 2019
  17. Johannes SchindelinJun 27, 2019
  18. Junio C HamanoJun 26, 2019
  19. Johannes SchindelinJun 27, 2019
  20. Derrick StoleeJun 27, 2019
  21. 0/6 Kill the_repository in tree-walk.cNguyễn Thái Ngọc Duy, Jun 27, 2019
  22. 1/6 sha1-file.c: remove the_repo from read_object_with_reference()Nguyễn Thái Ngọc Duy, Jun 27, 2019
  23. Johannes SchindelinJun 28, 2019
  24. 2/6 tree-walk.c: remove the_repo from fill_tree_descriptor()Nguyễn Thái Ngọc Duy, Jun 27, 2019
  25. 3/6 tree-walk.c: remove the_repo from get_tree_entry()Nguyễn Thái Ngọc Duy, Jun 27, 2019
  26. 4/6 tree-walk.c: remove the_repo from get_tree_entry_follow_symlinks()Nguyễn Thái Ngọc Duy, Jun 27, 2019
  27. 5/6 match-trees.c: remove the_repo from shift_tree*()Nguyễn Thái Ngọc Duy, Jun 27, 2019
  28. 6/6 Use the right 'struct repository' instead of the_repositoryNguyễn Thái Ngọc Duy, Jun 27, 2019
  29. Junio C HamanoJun 27, 2019
  30. 7/6 t7814: do not generate same commits in different reposNguyễn Thái Ngọc Duy, Jun 28, 2019
  31. Junio C HamanoJun 28, 2019

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.