From: Luca Stefani Date: Sat, 04 Apr 2026 17:28:17 GMT Subject: [PATCH] object-file: don't use object database without a repository Message-ID: <20260404172817.2995133-1-luca.stefani.ge1@gmail.com> When running `git diff -- $file1 $file2' on large enough files, index_fd() attempts to use 'the_repository->objects', assuming it is initialized, but that's not the case for non-repository usecases. When git diff is invoked without a backing repository, INDEX_WRITE_OBJECT is never set in flags, meaning only the hash is needed and nothing should be written to the object store. Enforce the use of index_core() in this case. Signed-off-by: Luca Stefani --- object-file.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 { -- 2.54.0.rc0.dirty