diff --git a/lib/git/lib.rb b/lib/git/lib.rb index 7d9cbc3c..b62d69c1 100644 --- a/lib/git/lib.rb +++ b/lib/git/lib.rb @@ -333,7 +333,7 @@ def full_log_commits(opts = {}) def rev_parse(revision) assert_args_are_not_options('rev', revision) - command('rev-parse', revision) + command('rev-parse', '--revs-only', '--end-of-options', revision, '--') end # For backwards compatibility with the old method name diff --git a/tests/units/test_lib.rb b/tests/units/test_lib.rb index fb319be8..af613d1f 100644 --- a/tests/units/test_lib.rb +++ b/tests/units/test_lib.rb @@ -199,7 +199,7 @@ def test_rev_parse_with_bad_revision end def test_rev_parse_with_unknown_revision - assert_raise(Git::FailedError) do + assert_raise_with_message(Git::FailedError, /exit 128, stderr: "fatal: bad revision 'NOTFOUND'"/) do @lib.rev_parse('NOTFOUND') end end