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

Re: [PATCH v4] cache-tree.c: remove implicit dependency on the_repository

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 8, 2021, 13:23 UTC
Message-ID
<xmqqmtu8vrk6.fsf@gitster.g>
In-Reply-To
<0df415b7-73b7-6e72-1885-3ca606acf8fd@gmail.com>
Chinmoy Chakraborty <chinmoy12c@gmail.com> writes:
> Is it safe to make this assumption?

It was the question I asked, and I didn't see a reason to believe it is safe.

> I mean to be completely sure of this, one would have to track back
> to all the callers.

Yes. If we audit the callers to make sure istate->repo always points at the right repository, add missing assignment to istate->repo as necessary, and add

	if (!istate->repo)
		BUG("caller of cache_tree_udpate() did not fill istate->repo");
then that would be an improvement.  But...
Show 7 quoted lines
> Should a check like:
>
>     if(!istate->repo)
>
>         istate->repo = the_repository;
>
> be required?

... if we add such an "if the caller did not set istate->repo, assume the_repository" code, then the resulting code explicitly assumes that the istate the caller passed to us without setting istate->repo belongs to the default repository.

I do not quite see the point of such a change---it is not all that better than "implicit dependency on the_repository" the patch tries to address, is it?

Previous: Chinmoy Chakraborty
Message 17 of 17 in “cache-tree.c: remove implicit dependency on the_repository”
  1. cache-tree.c: remove implicit dependency on the_repositoryChinmoy via GitGitGadget, Mar 25, 2021
  2. Derrick StoleeMar 25, 2021
  3. Chinmoy ChakrabortyMar 26, 2021
  4. Chinmoy ChakrabortyMar 26, 2021
  5. cache-tree.c: remove implicit dependency on the_repositoryChinmoy via GitGitGadget, Mar 26, 2021
  6. cache-tree.c: remove implicit dependency on the_repositoryChinmoy via GitGitGadget, Apr 3, 2021
  7. Junio C HamanoApr 4, 2021
  8. Chinmoy ChakrabortyApr 4, 2021
  9. Junio C HamanoApr 4, 2021
  10. Chinmoy ChakrabortyApr 4, 2021
  11. Junio C HamanoApr 4, 2021
  12. Derrick StoleeApr 5, 2021
  13. Junio C HamanoApr 5, 2021
  14. cache-tree.c: remove implicit dependency on the_repositoryChinmoy via GitGitGadget, Apr 7, 2021
  15. Junio C HamanoApr 7, 2021
  16. Chinmoy ChakrabortyApr 8, 2021
  17. Junio C HamanoApr 8, 2021

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.