]> git.99rst.org Git - git.git/commit
diff: fix crash with --find-object outside repository
authorMichael Montalbo <redacted>
Sat, 28 Feb 2026 20:31:16 +0000 (20:31 +0000)
committerJunio C Hamano <redacted>
Mon, 2 Mar 2026 16:29:48 +0000 (08:29 -0800)
commitb0ddc7947cc6f0a077543204a96710c53daa48a5
treea75361ee03fc41ba6215da67dc284252629ca5d3
parentf368df439b31b422169975cc3c95f7db6a46eada
diff: fix crash with --find-object outside repository

When "git diff --find-object=<oid>" is run outside a git repository,
the option parsing callback eagerly resolves the OID via
repo_get_oid(), which reaches get_main_ref_store() and hits a BUG()
assertion because no repository has been set up.

Check startup_info->have_repository before attempting to resolve the
OID, and return a user-friendly error instead.

Signed-off-by: Michael Montalbo <redacted>
Signed-off-by: Junio C Hamano <redacted>
diff.c
t/t4053-diff-no-index.sh
git clone https://git.99rst.org/PROJECT