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

Re: [PATCH 1/2] unpack-trees: lose USE_THE_REPOSITORY

From
Patrick Steinhardt <ps@pks.im>
Date
Nov 10, 2026, 07:04 UTC
Message-ID
<avLCDTHuScp4iLyj@pks.im>
In-Reply-To
<xmqqecctzttt.fsf@gitster.g>
On Mon, Nov 09, 2026 at 11:30:06AM -0800, Junio C Hamano wrote:
Show 16 quoted lines
> Patrick Steinhardt <ps@pks.im> writes:
> >> @@ -345,15 +394,16 @@ static void load_gitmodules_file(struct index_state *index,
> >>  				 struct checkout *state)
> >>  {
> >>  	int pos = index_name_pos(index, GITMODULES_FILE, strlen(GITMODULES_FILE));
> >> +	struct repository *repo = unpack_repo(index, NULL);
> >
> > This conversion here raises the question what we want to do in the case
> > where the caller has both structures available, but we don't end up
> > passing them to the pointer. This could in theory hide a bug where we
> > have mismatching repositories when the entry points don't verify that
> > property.
> 
> Puzzled.  Here we do have an istate but have no unpack_trees_options
> available, so it is natural to pass NULL for the latter to tell the
> validator "we do not have unpack_trees_options".

It is natural, but the calling context _does_ have options available. It's just that the caller of this function here decided to not pass it down because we previously didn't need it. In fact, every new callsite of `unpack_repo()` does have options available in their call stack.

> Are you worried about a case where a programmer who writes an
> unpack_repo() call passes NULL by mistake efven when istate or
> unpack_trees_options are available?

All I'm pointing out is that there are cases where we could be as defensive as everywhere else if we started passing down the options to calling contexts that don't have it yet. I wouldn't say I'm "worried" though. The proposed patch is very defensive overall, and I'm not overly concerned about us missing that defense in some cases.

Patrick
Previous: Junio C HamanoNext: Junio C Hamano
Message 6 of 15 in “unpack-trees: lose USE_THE_REPOSITORY”
  1. 1/2 unpack-trees: lose USE_THE_REPOSITORYJunio C Hamano, Nov 7, 2026
  2. 2/2 unpack-trees: consistently use "struct index_state *istate"Junio C Hamano, Nov 7, 2026
  3. Derrick StoleeNov 9, 2026
  4. Patrick SteinhardtNov 9, 2026
  5. Junio C HamanoNov 9, 2026
  6. Patrick SteinhardtNov 10, 2026
  7. Junio C HamanoNov 10, 2026
  8. Patrick SteinhardtNov 10, 2026
  9. Derrick StoleeNov 9, 2026
  10. 0/2 unpack-trees.c w/o the_repositoryJunio C Hamano, Nov 9, 2026
  11. 1/2 unpack-trees: lose USE_THE_REPOSITORYJunio C Hamano, Nov 9, 2026
  12. 2/2 unpack-trees: consistently use "struct index_state *istate"Junio C Hamano, Nov 9, 2026
  13. Derrick StoleeNov 10, 2026
  14. Junio C HamanoNov 10, 2026
  15. Patrick SteinhardtNov 11, 2026

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.