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

Re: [PATCH 0/2] fixing parse_object() check for type mismatch

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Nov 22, 2022, 00:05 UTC
Message-ID
<221122.86h6yrc0o6.gmgdl@evledraar.gmail.com>
In-Reply-To
<Y3vQ/6QcTEFfpjLt@coredump.intra.peff.net>
On Mon, Nov 21 2022, Jeff King wrote:
Show 29 quoted lines
> On Fri, Nov 18, 2022 at 02:05:04PM -0500, Taylor Blau wrote:
>
>> On Thu, Nov 17, 2022 at 05:37:29PM -0500, Jeff King wrote:
>> > I'm adding Taylor to the cc as the author of t6102, when we were
>> > tracking down all of these "oops, it's not really a blob" cases. This
>> > fixes one of the lingering cases from that test script.
>> >
>> >   [1/2]: parse_object(): drop extra "has" check before checking object type
>> >   [2/2]: parse_object(): check on-disk type of suspected blob
>> >
>> >  object.c                               | 5 ++---
>> >  t/t6102-rev-list-unexpected-objects.sh | 4 ++--
>> >  2 files changed, 4 insertions(+), 5 deletions(-)
>> 
>> A blast from the past :-).
>> 
>> I took a careful look at both of these patches and they looked good to
>> me, so let's start merging them down.
>
> I saw this hit 'next', but I think Ævar's simplification suggestion is
> worth taking. So here is a patch on top to do so (the original branch is
> jk/parse-object-type-mismatch for the benefit of any newly-returned
> maintainers).
>
> I was going to do a "helped-by", but since the only thing in the patch
> is the suggested change, I just handed over authorship. :)
>
> I didn't forge a signoff, and I think mine is sufficient under DCO's
> part (b), but Ævar please indicate if that's OK.

This looks good to me, thanks for following up. In case my SOB is needed feel free to add it, but it's fine without that too as far as I'm concerned.

Show 32 quoted lines
> -- >8 --
> From: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
> Subject: [PATCH] parse_object(): simplify blob conditional
>
> Commit 8db2dad7a0 (parse_object(): check on-disk type of suspected blob,
> 2022-11-17) simplified the conditional for checking if we might have a
> blob. But we can simplify it further. In:
>
>   !obj || (obj && obj->type == OBJ_BLOB)
>
> the short-circuit "OR" means "obj" will always be true on the right-hand
> side. The compiler almost certainly optimized that out anyway, but
> dropping it makes the conditional easier to understand for humans.
>
> Signed-off-by: Jeff King <peff@peff.net>
> ---
>  object.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/object.c b/object.c
> index fad1a5af4a..682b852a46 100644
> --- a/object.c
> +++ b/object.c
> @@ -286,7 +286,7 @@ struct object *parse_object_with_flags(struct repository *r,
>  			return &commit->object;
>  	}
>  
> -	if ((!obj || (obj && obj->type == OBJ_BLOB)) &&
> +	if ((!obj || obj->type == OBJ_BLOB) &&
>  	    oid_object_info(r, oid, NULL) == OBJ_BLOB) {
>  		if (!skip_hash && stream_object_signature(r, repl) < 0) {
>  			error(_("hash mismatch %s"), oid_to_hex(oid));
Previous: Jeff King
Message 22 of 22 in “object.c: use has_object() instead of repo_has_object_file()”
  1. Kousik SanagavarapuNov 16, 2022
  2. Jeff KingNov 16, 2022
  3. Jonathan TanNov 16, 2022
  4. 0/2 fixing parse_object() check for type mismatchJeff King, Nov 17, 2022
  5. 1/2 parse_object(): drop extra "has" check before checking object typeJeff King, Nov 17, 2022
  6. 2/2 parse_object(): check on-disk type of suspected blobJeff King, Nov 17, 2022
  7. Ævar Arnfjörð BjarmasonNov 18, 2022
  8. Jeff KingNov 21, 2022
  9. 0/4 tag: don't misreport type of tagged objects in errorsÆvar Arnfjörð Bjarmason, Nov 18, 2022
  10. 1/4 object-file.c: free the "t.tag" in check_tag()Ævar Arnfjörð Bjarmason, Nov 18, 2022
  11. 2/4 object tests: add test for unexpected objects in tagsÆvar Arnfjörð Bjarmason, Nov 18, 2022
  12. 4/4 tag: don't emit potentially incorrect "object is a X, not a Y"Ævar Arnfjörð Bjarmason, Nov 18, 2022
  13. 3/4 tag: don't misreport type of tagged objects in errorsÆvar Arnfjörð Bjarmason, Nov 18, 2022
  14. 0/3 tag: don't misreport type of tagged objects in errorsÆvar Arnfjörð Bjarmason, Dec 30, 2022
  15. 1/3 object tests: add test for unexpected objects in tagsÆvar Arnfjörð Bjarmason, Dec 30, 2022
  16. Junio C HamanoDec 30, 2022
  17. 3/3 tag: don't emit potentially incorrect "object is a X, not a Y"Ævar Arnfjörð Bjarmason, Dec 30, 2022
  18. 2/3 tag: don't misreport type of tagged objects in errorsÆvar Arnfjörð Bjarmason, Dec 30, 2022
  19. Junio C HamanoDec 30, 2022
  20. Taylor BlauNov 18, 2022
  21. Jeff KingNov 21, 2022
  22. Ævar Arnfjörð BjarmasonNov 22, 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.