aboutsummaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2026-03-10 14:23:22 -0700
committerJunio C Hamano <gitster@pobox.com>2026-03-10 14:23:22 -0700
commit015cf12578691d77638c7b99f27c15f4d73446e4 (patch)
tree17a9dd45b8344ac985b008a1a7f037e7d0b7fb24 /diff.c
parent0f34e8c17441685159c5c0ea5b742bd8257e10ce (diff)
parentb0ddc7947cc6f0a077543204a96710c53daa48a5 (diff)
downloadgit-015cf12578691d77638c7b99f27c15f4d73446e4.tar.xz
Merge branch 'mm/diff-no-index-find-object'
"git diff --no-index --find-object=<object-name>" outside a repository of course wouldn't be able to find the object and died while parsing the command line, which is made to die in a bit more user-friendly way. * mm/diff-no-index-find-object: diff: fix crash with --find-object outside repository
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/diff.c b/diff.c
index da6e9e7f49..e87847fa4b 100644
--- a/diff.c
+++ b/diff.c
@@ -5224,6 +5224,8 @@ static int diff_opt_find_object(const struct option *option,
struct object_id oid;
BUG_ON_OPT_NEG(unset);
+ if (!startup_info->have_repository)
+ return error(_("--find-object requires a git repository"));
if (repo_get_oid(the_repository, arg, &oid))
return error(_("unable to resolve '%s'"), arg);