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

Re: [PATCH v2] object-file: reprepare alternates when necessary

From
JTJonathan Tan <jonathantanmy@google.com>
Date
Mar 10, 2023, 21:29 UTC
Message-ID
<20230310212916.4138690-1-jonathantanmy@google.com>
In-Reply-To
<pull.1490.v2.git.1678301252360.gitgitgadget@gmail.com>
"Derrick Stolee via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 5 quoted lines
>     Update in v2
>     ============
>     
>      * Instead of creating a new public reprepare_alt_odb() method, inline
>        its implementation inside reprepare_packed_git().
[snip]
Show 17 quoted lines
> diff --git a/packfile.c b/packfile.c
> index 79e21ab18e7..06419c8e8ca 100644
> --- a/packfile.c
> +++ b/packfile.c
> @@ -1008,6 +1008,16 @@ void reprepare_packed_git(struct repository *r)
>  	struct object_directory *odb;
>  
>  	obj_read_lock();
> +
> +	/*
> +	 * Reprepare alt odbs, in case the alternates file was modified
> +	 * during the course of this process. This only _adds_ odbs to
> +	 * the linked list, so existing odbs will continue to exist for
> +	 * the lifetime of the process.
> +	 */
> +	r->objects->loaded_alternates = 0;
> +	prepare_alt_odb(r);

I understand that the change to inline what was originally reprepare_alt_odb() was in response to a reviewer comment, but I would prefer the original version, since this assumes that prepare_alt_odb() only adds to what's there instead of first clearing the odb linked list and odb_by_path hashmap.

But I guess clearing a linked list and hashmap can be a bit cumbersome in C, so maybe it would be reasonable to assume that this behavior would not change. In any case, maybe a comment should be added to prepare_alt_odb() saying that if an update of the alternates is needed, one can do so by clearing loaded_alternates and re- invoking prepare_alt_odb() (at least so that a developer changing prepare_alt_odb() can see the comment and understand what behaviors this function needs to preserve).

Everything else (the new functionality, the commit message etc.) looks good, of course.

Previous: Eric WongNext: Junio C Hamano
Message 17 of 19 in “object-file: reprepare alternates when necessary”
  1. object-file: reprepare alternates when necessaryDerrick Stolee via GitGitGadget, Mar 6, 2023
  2. Junio C HamanoMar 6, 2023
  3. Taylor BlauMar 7, 2023
  4. Derrick StoleeMar 7, 2023
  5. Junio C HamanoMar 7, 2023
  6. Taylor BlauMar 8, 2023
  7. Derrick StoleeMar 8, 2023
  8. Ævar Arnfjörð BjarmasonMar 7, 2023
  9. Junio C HamanoMar 7, 2023
  10. Junio C HamanoMar 7, 2023
  11. Derrick StoleeMar 8, 2023
  12. object-file: reprepare alternates when necessaryDerrick Stolee via GitGitGadget, Mar 8, 2023
  13. Junio C HamanoMar 8, 2023
  14. Taylor BlauMar 8, 2023
  15. Jeff KingMar 9, 2023
  16. Eric WongMar 9, 2023
  17. Jonathan TanMar 10, 2023
  18. Junio C HamanoMar 11, 2023
  19. Jonathan TanMar 11, 2023

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.