diff options
author | William Bain <bain.william.a@gmail.com> | 2017-05-03 11:20:57 -0600 |
---|---|---|
committer | William Bain <bain.william.a@gmail.com> | 2017-05-05 09:46:56 -0600 |
commit | 8b107dc5e1cd0745628e2bfb473477342c719f25 (patch) | |
tree | f8a8de71ab98716613135cc1497c43876165e232 /tests/refs | |
parent | 7849e467579f64ccbbfdc4463af97a215d1ac8e3 (diff) | |
download | libgit2-8b107dc5e1cd0745628e2bfb473477342c719f25.tar.gz |
revparse: support open-ended ranges
Support '..' and '...' ranges where one side is not specified.
The unspecified side defaults to HEAD.
Closes #4223
Diffstat (limited to 'tests/refs')
-rw-r--r-- | tests/refs/revparse.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/refs/revparse.c b/tests/refs/revparse.c index c22c30440..459188cf7 100644 --- a/tests/refs/revparse.c +++ b/tests/refs/revparse.c @@ -122,6 +122,14 @@ static void test_id( test_id_inrepo(spec, expected_left, expected_right, expected_flags, g_repo); } +static void test_invalid_revspec(const char* invalid_spec) +{ + git_revspec revspec; + + cl_assert_equal_i( + GIT_EINVALIDSPEC, git_revparse(&revspec, g_repo, invalid_spec)); +} + void test_refs_revparse__initialize(void) { cl_git_pass(git_repository_open(&g_repo, cl_fixture("testrepo.git"))); @@ -749,6 +757,33 @@ void test_refs_revparse__parses_range_operator(void) "4a202b346bb0fb0db7eff3cffeb3c70babbd2045", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750", GIT_REVPARSE_RANGE | GIT_REVPARSE_MERGE_BASE); + + test_id("HEAD~3..", + "4a202b346bb0fb0db7eff3cffeb3c70babbd2045", + "a65fedf39aefe402d3bb6e24df4d4f5fe4547750", + GIT_REVPARSE_RANGE); + + test_id("HEAD~3...", + "4a202b346bb0fb0db7eff3cffeb3c70babbd2045", + "a65fedf39aefe402d3bb6e24df4d4f5fe4547750", + GIT_REVPARSE_RANGE | GIT_REVPARSE_MERGE_BASE); + + test_id("..HEAD~3", + "a65fedf39aefe402d3bb6e24df4d4f5fe4547750", + "4a202b346bb0fb0db7eff3cffeb3c70babbd2045", + GIT_REVPARSE_RANGE); + + test_id("...HEAD~3", + "a65fedf39aefe402d3bb6e24df4d4f5fe4547750", + "4a202b346bb0fb0db7eff3cffeb3c70babbd2045", + GIT_REVPARSE_RANGE | GIT_REVPARSE_MERGE_BASE); + + test_id("...", + "a65fedf39aefe402d3bb6e24df4d4f5fe4547750", + "a65fedf39aefe402d3bb6e24df4d4f5fe4547750", + GIT_REVPARSE_RANGE | GIT_REVPARSE_MERGE_BASE); + + test_invalid_revspec(".."); } void test_refs_revparse__ext_retrieves_both_the_reference_and_its_target(void) |