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

Re: [PATCH 2/2] odb/source-loose: fix existence checks for newly written objects

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 4, 2026, 17:47 UTC
Message-ID
<xmqqfqxg32uy.fsf@gitster.g>
In-Reply-To
<20261104-pks-odb-loose-stale-cache-v1-2-a00d5cdb5e7d@pks.im>
Patrick Steinhardt <ps@pks.im> writes:
Show 32 quoted lines
> @@ -824,8 +837,13 @@ static int write_loose_object(struct odb_source_loose *loose,
>  			warning_errno(_("failed utime() on %s"), tmp_file.buf);
>  	}
>  
> -	return finalize_object_file_flags(loose->base.odb->repo, tmp_file.buf, filename.buf,
> -					  FOF_SKIP_COLLISION_CHECK);
> +	ret = finalize_object_file_flags(loose->base.odb->repo, tmp_file.buf, filename.buf,
> +					 FOF_SKIP_COLLISION_CHECK);
> +	if (ret < 0)
> +		return ret;
> +
> +	loose_cache_mark_seen(loose, oid);
> +	return 0;
>  }
>  
>  static int odb_source_loose_write_object(struct odb_source *source,
> @@ -967,8 +985,14 @@ static int odb_source_loose_write_object_stream(struct odb_source *source,
>  
>  	err = finalize_object_file_flags(loose->base.odb->repo, tmp_file.buf, filename.buf,
>  					 FOF_SKIP_COLLISION_CHECK);
> -	if (!err && compat)
> +	if (err < 0)
> +		goto cleanup;
> +
> +	loose_cache_mark_seen(loose, oid);
> +
> +	if (compat)
>  		err = repo_add_loose_object_map(loose, oid, &compat_oid);
> +
>  cleanup:
>  	strbuf_release(&tmp_file);
>  	strbuf_release(&filename);

Not about this change but the lack of "if (compat)" stuff in the previous hunk puzzled me. It turns out that the logic to write a single loose object is so big that write_loose_object(), which is the subject of the previous hunk, helps another function, odb_source_loose_write_object(), by being its helper function, and this caller has the corresponding "if (compat)" logic to produce the hash interoperability data.

Looking very good.
Previous: Patrick SteinhardtNext: Kristofer Karlsson
Message 4 of 7 in “odb/source-loose: fix failing existence checks caused by stale cache”
  1. 0/2 odb/source-loose: fix failing existence checks caused by stale cachePatrick Steinhardt, Nov 4, 2026
  2. 1/2 odb/source-loose: extract logic to retrieve subdirectory bitmapPatrick Steinhardt, Nov 4, 2026
  3. 2/2 odb/source-loose: fix existence checks for newly written objectsPatrick Steinhardt, Nov 4, 2026
  4. Junio C HamanoNov 4, 2026
  5. Kristofer KarlssonNov 4, 2026
  6. Derrick StoleeNov 4, 2026
  7. Junio C HamanoNov 5, 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.