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

Re: [PATCH v2 2/4] builtin/pack-objects.c: avoid redundant NULL check

From
Junio C Hamano <gitster@pobox.com>
Date
May 24, 2022, 21:44 UTC
Message-ID
<xmqq8rqqfvwa.fsf@gitster.g>
In-Reply-To
<2719d33f328e03239cdb2f5cca2fef9a4e9cbb93.1653418457.git.me@ttaylorr.com>
Taylor Blau <me@ttaylorr.com> writes:
Show 10 quoted lines
> Before calling `for_each_object_in_pack()`, the caller
> `read_packs_list_from_stdin()` loops through each of the `include_packs`
> and checks that its `->util` pointer (which is used to store the `struct
> packed_git *` itself) is non-NULL.
>
> This check is redundant, because `read_packs_list_from_stdin()` already
> checks that the included packs are non-NULL earlier on in the same
> function (and it does not add any new entries in between).
>
> Remove this check, since it is not doing anything in the meantime.
Will it start doing something soon in a later step?

Oh, did you mean that after the earlier for_each_string_list_item() iteration over include_packs that died on an item with a NULL .util member, the code did not do anything to cause this second iteration over the same list to suddenly start seeing an item with NULL .util?

I am puzzled by the mention of "in the meantime".
The patch itself looks correct, of course.
Thanks.
Show 19 quoted lines
> Co-authored-by: Victoria Dye <vdye@github.com>
> Signed-off-by: Taylor Blau <me@ttaylorr.com>
> ---
>  builtin/pack-objects.c | 2 --
>  1 file changed, 2 deletions(-)
>
> diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
> index 014dcd4bc9..ec3193fd95 100644
> --- a/builtin/pack-objects.c
> +++ b/builtin/pack-objects.c
> @@ -3369,8 +3369,6 @@ static void read_packs_list_from_stdin(void)
>  
>  	for_each_string_list_item(item, &include_packs) {
>  		struct packed_git *p = item->util;
> -		if (!p)
> -			die(_("could not find pack '%s'"), item->string);
>  		for_each_object_in_pack(p,
>  					add_object_entry_from_pack,
>  					&revs,
Previous: Taylor BlauNext: Taylor Blau
Message 17 of 29 in “pack-objects: fix a pair of MIDX bitmap-related races”
  1. 0/2 pack-objects: fix a pair of MIDX bitmap-related racesTaylor Blau, May 13, 2022
  2. 1/2 pack-bitmap: check preferred pack validity when opening MIDX bitmapTaylor Blau, May 13, 2022
  3. Junio C HamanoMay 13, 2022
  4. Taylor BlauMay 13, 2022
  5. 2/2 builtin/pack-objects.c: ensure pack validity from MIDX bitmap objectsTaylor Blau, May 13, 2022
  6. Jonathan TanMay 13, 2022
  7. Taylor BlauMay 14, 2022
  8. Jonathan TanMay 16, 2022
  9. Taylor BlauMay 14, 2022
  10. Jonathan TanMay 16, 2022
  11. 0/4 pack-objects: fix a pair of MIDX bitmap-related racesTaylor Blau, May 24, 2022
  12. 1/4 pack-bitmap.c: check preferred pack validity when opening MIDX bitmapTaylor Blau, May 24, 2022
  13. Ævar Arnfjörð BjarmasonMay 24, 2022
  14. Taylor BlauMay 24, 2022
  15. Ævar Arnfjörð BjarmasonMay 24, 2022
  16. 2/4 builtin/pack-objects.c: avoid redundant NULL checkTaylor Blau, May 24, 2022
  17. Junio C HamanoMay 24, 2022
  18. Taylor BlauMay 25, 2022
  19. 3/4 builtin/pack-objects.c: ensure included `--stdin-packs` existTaylor Blau, May 24, 2022
  20. Ævar Arnfjörð BjarmasonMay 24, 2022
  21. Taylor BlauMay 24, 2022
  22. Ævar Arnfjörð BjarmasonMay 24, 2022
  23. Junio C HamanoMay 24, 2022
  24. Taylor BlauMay 25, 2022
  25. Victoria DyeMay 26, 2022
  26. Taylor BlauMay 26, 2022
  27. 4/4 builtin/pack-objects.c: ensure pack validity from MIDX bitmap objectsTaylor Blau, May 24, 2022
  28. Junio C HamanoMay 24, 2022
  29. Taylor BlauMay 25, 2022

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.