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

[PATCH] object-file: don't use object database without a repository

From
Luca Stefani <luca.stefani.ge1@gmail.com>
Date
Apr 4, 2026, 17:28 UTC
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 <luca.stefani.ge1@gmail.com>
---
 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
Next: Pushkar Singh
Message 1 of 10 in “object-file: don't use object database without a repository”
  1. object-file: don't use object database without a repositoryLuca Stefani, Apr 4, 2026
  2. Pushkar SinghApr 5, 2026
  3. Jeff KingApr 5, 2026
  4. Luca StefaniApr 5, 2026
  5. Jeff KingApr 5, 2026
  6. Justin ToblerApr 6, 2026
  7. Luca StefaniApr 6, 2026
  8. Justin ToblerApr 6, 2026
  9. Jeff KingApr 6, 2026
  10. Justin ToblerApr 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.