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

Re: [PATCH/RFC] diff/read-cache: don't assume empty files will filter to empty

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 17, 2017, 19:07 UTC
Message-ID
<xmqqpocyhogz.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<CA+mMEgf1Pg0bbGesCFr6sY60PxR=ewKPqnkG1M3fO2qurqR=1g@mail.gmail.com>
Andrei Purdea <andrei@purdea.ro> writes:
Show 26 quoted lines
> diff --git a/read-cache.c b/read-cache.c
> index 2121b6e7b..ca306993c 100644
> --- a/read-cache.c
> +++ b/read-cache.c
> @@ -262,9 +262,8 @@ static int ce_match_stat_basic(const struct
> cache_entry *ce, struct stat *st)
>   changed |= match_stat_data(&ce->ce_stat_data, st);
>
>   /* Racily smudged entry? */
> - if (!ce->ce_stat_data.sd_size) {
> - if (!is_empty_blob_sha1(ce->oid.hash))
> - changed |= DATA_CHANGED;
> + if (ce->ce_stat_data.sd_size == (unsigned int)-1) {
> + changed |= DATA_CHANGED;
>   }
>
>   return changed;
> @@ -2028,7 +2027,7 @@ static void ce_smudge_racily_clean_entry(struct
> cache_entry *ce)
>   * file, and never calls us, so the cached size information
>   * for "frotz" stays 6 which does not match the filesystem.
>   */
> - ce->ce_stat_data.sd_size = 0;
> + ce->ce_stat_data.sd_size = (unsigned int)-1;
>   }
>  }

This is not a good idea. A change like this will break existing installations where a zeroed size is understood as "not verified as clean".

Is it infeasible to fix your clean-smudge filter pair to clean and/or smudge zero-sized payload to empty? After all, it does not help offloading the storing of blob that is known to be empty and read another emptiness from the network or whatever external service when the end result is known to be zero bytes anyway, no?

Previous: Andrei Purdea
Message 2 of 2 in “diff/read-cache: don't assume empty files will filter to empty”
  1. diff/read-cache: don't assume empty files will filter to emptyAndrei Purdea, Jul 17, 2017
  2. Junio C HamanoJul 17, 2017

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.