mirror of
https://github.com/git/git.git
synced 2026-03-04 06:27:36 +01:00
Merge branch 'mm/diff-no-index-find-object' into jch
"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
This commit is contained in:
2
diff.c
2
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);
|
||||
|
||||
|
||||
@@ -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 &&
|
||||
|
||||
Reference in New Issue
Block a user