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

Re: [PATCH 17/19] submodule: use submodule repos for object lookup

From
JTJonathan Tan <jonathantanmy@google.com>
Date
Oct 11, 2018, 22:40 UTC
Message-ID
<20181011224052.191281-1-jonathantanmy@google.com>
In-Reply-To
<20181011211754.31369-18-sbeller@google.com>
Show 6 quoted lines
> +/*
> + * Initialize 'out' based on the provided submodule path.
> + *
> + * Unlike repo_submodule_init, this tolerates submodules not present
> + * in .gitmodules. NEEDSWORK: The repo_submodule_init behavior is
> + * preferrable. This function exists only to preserve historical behavior.

What do you mean by "The repo_submodule_init behavior is preferable"? If we need to preserve historical behavior, then it seems that the most preferable one is something that meets our needs (like open_submodule() in this patch).

Show 10 quoted lines
> +static int open_submodule(struct repository *out, const char *path)
> +{
> +	struct strbuf sb = STRBUF_INIT;
> +
> +	if (submodule_to_gitdir(&sb, path) || repo_init(out, sb.buf, NULL)) {
> +		strbuf_release(&sb);
> +		return -1;
> +	}
> +
> +	out->submodule_prefix = xstrdup(path);
Do we need to set submodule_prefix?
Show 6 quoted lines
> @@ -507,7 +533,7 @@ static void show_submodule_header(struct diff_options *o, const char *path,
>  	else if (is_null_oid(two))
>  		message = "(submodule deleted)";
>  
> -	if (add_submodule_odb(path)) {
> +	if (open_submodule(sub, path) < 0) {

This function, as a side effect, writes the open repository to "sub" for its caller to use. I think it's better if its callers open "sub" and then pass it to show_submodule_header() if successful. If opening the submodule is expected to fail sometimes (like it seems here), then we can allow callers to also pass NULL, and document what happens when NULL is passed.

Also, repositories open in this way should also be freed.
Previous: Stefan BellerNext: Stefan Beller
Message 25 of 37 in “Bring more repository handles into our code base”
  1. 00/19 Bring more repository handles into our code baseStefan Beller, Oct 11, 2018
  2. 01/19 sha1_file: allow read_object to read objects in arbitrary repositoriesStefan Beller, Oct 11, 2018
  3. 02/19 packfile: allow has_packed_and_bad to handle arbitrary repositoriesStefan Beller, Oct 11, 2018
  4. 03/19 object-store: allow read_object_file_extended to read from arbitrary repositoriesStefan Beller, Oct 11, 2018
  5. Jonathan TanOct 11, 2018
  6. 04/19 object-store: prepare read_object_file to deal with arbitrary repositoriesStefan Beller, Oct 11, 2018
  7. Jonathan TanOct 11, 2018
  8. Stefan BellerOct 11, 2018
  9. 05/19 object: parse_object to honor its repository argumentStefan Beller, Oct 11, 2018
  10. Jonathan TanOct 11, 2018
  11. Stefan BellerOct 13, 2018
  12. 06/19 commit: allow parse_commit* to handle arbitrary repositoriesStefan Beller, Oct 11, 2018
  13. 07/19 commit.c: allow paint_down_to_common to handle arbitrary repositoriesStefan Beller, Oct 11, 2018
  14. 08/19 commit.c: allow merge_bases_many to handle arbitrary repositoriesStefan Beller, Oct 11, 2018
  15. 09/19 commit.c: allow remove_redundant to handle arbitrary repositoriesStefan Beller, Oct 11, 2018
  16. 10/19 commit: allow get_merge_bases_many_0 to handle arbitrary repositoriesStefan Beller, Oct 11, 2018
  17. 11/19 commit: prepare get_merge_bases to handle arbitrary repositoriesStefan Beller, Oct 11, 2018
  18. 12/19 commit: prepare get_commit_buffer to handle arbitrary repositoriesStefan Beller, Oct 11, 2018
  19. 13/19 commit: prepare in_merge_bases[_many] to handle arbitrary repositoriesStefan Beller, Oct 11, 2018
  20. 14/19 commit: prepare repo_unuse_commit_buffer to handle arbitrary repositoriesStefan Beller, Oct 11, 2018
  21. 15/19 commit: prepare logmsg_reencode to handle arbitrary repositoriesStefan Beller, Oct 11, 2018
  22. 16/19 pretty: prepare format_commit_message to handle arbitrary repositoriesStefan Beller, Oct 11, 2018
  23. Jonathan TanOct 11, 2018
  24. 17/19 submodule: use submodule repos for object lookupStefan Beller, Oct 11, 2018
  25. Jonathan TanOct 11, 2018
  26. Stefan BellerOct 13, 2018
  27. Stefan BellerOct 16, 2018
  28. Jonathan TanOct 16, 2018
  29. Stefan BellerOct 16, 2018
  30. 18/19 submodule: don't add submodule as odb for pushStefan Beller, Oct 11, 2018
  31. Jonathan TanOct 11, 2018
  32. Stefan BellerOct 11, 2018
  33. 19/19 Apply semantic patches from previous patchesStefan Beller, Oct 11, 2018
  34. Jonathan TanOct 11, 2018
  35. Junio C HamanoOct 11, 2018
  36. Jonathan NiederOct 12, 2018
  37. Stefan BellerOct 13, 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.