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

Re: [BUG] git diff --no-index segfaults on large files (NULL object database)

From
Tian Yuchen <cat@malon.dev>
Date
Apr 4, 2026, 17:07 UTC
Message-ID
<4be492cf-347b-4fa5-9bdd-83e7ea8abd92@malon.dev>
In-Reply-To
<CAO0HQ0VEJsG6MYrp_bSTuU09PDsypGPrM0XazvM8er0kB32Gqg@mail.gmail.com>
On 4/5/26 00:53, Luca Stefani wrote:
Show 23 quoted lines
> Thanks for looking into it.
> Locally, I simply check against null storage and it works just fine,
> flags is always 0 in my experiments so a check against
> INDEX_WRITE_OBJECT also worked.
> 
> diff --git a/object-file.c b/object-file.c
> index f0b029ff0b..68303aa99c 100644
> --- a/object-file.c
> +++ b/object-file.c
> @@ -1654,7 +1654,8 @@ int index_fd(struct index_state *istate, struct
> object_id *oid,
>    } else if ((st->st_size >= 0 &&
>        (size_t)st->st_size <=
> repo_settings_get_big_file_threshold(istate->repo)) ||
>       type != OBJ_BLOB ||
> -    (path && would_convert_to_git(istate, path))) {
> +    (path && would_convert_to_git(istate, path)) ||
> +    !(flags & INDEX_WRITE_OBJECT)) {
>    ret = index_core(istate, oid, fd, xsize_t(st->st_size),
>    type, path, flags);
>    } else {
> 
> Luca.

That looks good, almost exactly what I was about to send. I was mistaken— there isn’t a hash_write_object flag after all ;-)

It looks like this is your first time posting on the Git mailing list. Would you consider contributing this (as a patch)?

Thanks! Yuchen
Previous: Luca StefaniNext: Jeff King
Message 4 of 9 in “[BUG] git diff --no-index segfaults on large files (NULL object database)”
  1. Luca StefaniApr 4, 2026
  2. Tian YuchenApr 4, 2026
  3. Luca StefaniApr 4, 2026
  4. Tian YuchenApr 4, 2026
  5. Jeff KingApr 4, 2026
  6. Tian YuchenApr 5, 2026
  7. Jeff KingApr 5, 2026
  8. Justin ToblerApr 6, 2026
  9. Junio C HamanoApr 6, 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.