From: Luca Stefani <luca.stefani.ge1@gmail.com>
To: git@vger.kernel.org, cat@malon.dev
Cc: Luca Stefani <luca.stefani.ge1@gmail.com>
Subject: [PATCH] object-file: don't use object database without a repository
Date: Sat, 4 Apr 2026 19:28:17 +0200 [thread overview]
Message-ID: <20260404172817.2995133-1-luca.stefani.ge1@gmail.com> (raw)
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 reply other threads:[~2026-04-04 17:28 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-04 17:28 Luca Stefani [this message]
2026-04-05 6:03 ` [PATCH] object-file: don't use object database without a repository Pushkar Singh
2026-04-05 6:46 ` Jeff King
2026-04-05 16:10 ` Luca Stefani
2026-04-05 19:17 ` Jeff King
2026-04-06 18:17 ` Justin Tobler
2026-04-06 19:31 ` Luca Stefani
2026-04-06 20:31 ` Justin Tobler
2026-04-06 20:06 ` Jeff King
2026-04-06 20:38 ` Justin Tobler
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260404172817.2995133-1-luca.stefani.ge1@gmail.com \
--to=luca.stefani.ge1@gmail.com \
--cc=cat@malon.dev \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.