Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -5215,6 +5215,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);

Expand Down
10 changes: 10 additions & 0 deletions t/t4053-diff-no-index.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,16 @@ test_expect_success 'git diff --no-index executed outside repo gives correct err
)
'

test_expect_success 'git diff --find-object outside repo fails gracefully' '
(
GIT_CEILING_DIRECTORIES=$TRASH_DIRECTORY/non &&
export GIT_CEILING_DIRECTORIES &&
cd non/git &&
test_must_fail git diff --find-object=abc123 2>err &&
test_grep "find-object requires a git repository" err
)
'

test_expect_success 'diff D F and diff F D' '
(
cd repo &&
Expand Down
Loading