Commit d448392e5d030d40114b92d1261b72f3b3ab3e16

nulltoken 2012-07-15T00:46:01

revparse: extend test coverage

diff --git a/tests-clar/refs/revparse.c b/tests-clar/refs/revparse.c
index 56d57b2..05a9565 100644
--- a/tests-clar/refs/revparse.c
+++ b/tests-clar/refs/revparse.c
@@ -74,7 +74,11 @@ void test_refs_revparse__shas(void)
 
 void test_refs_revparse__head(void)
 {
+	test_object("", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750");
 	test_object("HEAD", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750");
+	test_object("HEAD^0", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750");
+	test_object("HEAD~0", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750");
+	test_object("master", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750");
 }
 
 void test_refs_revparse__full_refs(void)
@@ -99,12 +103,18 @@ void test_refs_revparse__describe_output(void)
 
 void test_refs_revparse__nth_parent(void)
 {
+	cl_git_fail(git_revparse_single(&g_obj, g_repo, "be3563a^-1"));
+	cl_git_fail(git_revparse_single(&g_obj, g_repo, "^"));
+	cl_git_fail(git_revparse_single(&g_obj, g_repo, "be3563a^{tree}^"));
+
 	test_object("be3563a^1", "9fd738e8f7967c078dceed8190330fc8648ee56a");
 	test_object("be3563a^", "9fd738e8f7967c078dceed8190330fc8648ee56a");
 	test_object("be3563a^2", "c47800c7266a2be04c571c04d5a6614691ea99bd");
 	test_object("be3563a^1^1", "4a202b346bb0fb0db7eff3cffeb3c70babbd2045");
+	test_object("be3563a^^", "4a202b346bb0fb0db7eff3cffeb3c70babbd2045");
 	test_object("be3563a^2^1", "5b5b025afb0b4c913b4c338a42934a3863bf3644");
 	test_object("be3563a^0", "be3563ae3f795b2b4353bcce3a527ad0a4f7f644");
+	test_object("be3563a^{commit}^", "9fd738e8f7967c078dceed8190330fc8648ee56a");
 
 	test_object("be3563a^42", NULL);
 }
@@ -113,34 +123,56 @@ void test_refs_revparse__not_tag(void)
 {
 	test_object("point_to_blob^{}", "1385f264afb75a56a5bec74243be9b367ba4ca08");
 	test_object("wrapped_tag^{}", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750");
+	test_object("master^{}", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750");
+	test_object("master^{tree}^{}", "944c0f6e4dfa41595e6eb3ceecdb14f50fe18162");
+	test_object("e90810b^{}", "e90810b8df3e80c413d903f631643c716887138d");
+	test_object("tags/e90810b^{}", "e90810b8df3e80c413d903f631643c716887138d");
+	test_object("e908^{}", "e90810b8df3e80c413d903f631643c716887138d");
 }
 
 void test_refs_revparse__to_type(void)
 {
+	cl_git_fail(git_revparse_single(&g_obj, g_repo, "wrapped_tag^{blob}"));
+	cl_git_fail(git_revparse_single(&g_obj, g_repo, "wrapped_tag^{trip}"));
+
 	test_object("wrapped_tag^{commit}", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750");
 	test_object("wrapped_tag^{tree}", "944c0f6e4dfa41595e6eb3ceecdb14f50fe18162");
 	test_object("point_to_blob^{blob}", "1385f264afb75a56a5bec74243be9b367ba4ca08");
-
-	cl_git_fail(git_revparse_single(&g_obj, g_repo, "wrapped_tag^{blob}"));
+	test_object("master^{commit}^{commit}", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750");
 }
 
 void test_refs_revparse__linear_history(void)
 {
+	cl_git_fail(git_revparse_single(&g_obj, g_repo, "~"));
 	cl_git_fail(git_revparse_single(&g_obj, g_repo, "foo~bar"));
 	cl_git_fail(git_revparse_single(&g_obj, g_repo, "master~bar"));
+	cl_git_fail(git_revparse_single(&g_obj, g_repo, "master~-1"));
+	cl_git_fail(git_revparse_single(&g_obj, g_repo, "master~0bar"));
 
 	test_object("master~0", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750");
 	test_object("master~1", "be3563ae3f795b2b4353bcce3a527ad0a4f7f644");
 	test_object("master~2", "9fd738e8f7967c078dceed8190330fc8648ee56a");
 	test_object("master~1~1", "9fd738e8f7967c078dceed8190330fc8648ee56a");
+	test_object("master~~", "9fd738e8f7967c078dceed8190330fc8648ee56a");
 }
 
 void test_refs_revparse__chaining(void)
 {
+	cl_git_fail(git_revparse_single(&g_obj, g_repo, "master@{0}@{0}"));
+	cl_git_fail(git_revparse_single(&g_obj, g_repo, "@{u}@{-1}"));
+	cl_git_fail(git_revparse_single(&g_obj, g_repo, "@{-1}@{-1}"));
+	cl_git_fail(git_revparse_single(&g_obj, g_repo, "@{-3}@{0}"));
+
+	test_object("master@{0}~1^1", "9fd738e8f7967c078dceed8190330fc8648ee56a");
+	test_object("@{u}@{0}", "be3563ae3f795b2b4353bcce3a527ad0a4f7f644");
+	test_object("@{-1}@{0}", "a4a7dce85cf63874e984719f4fdd239f5145052f");
+	test_object("@{-4}@{1}", "be3563ae3f795b2b4353bcce3a527ad0a4f7f644");
 	test_object("master~1^1", "9fd738e8f7967c078dceed8190330fc8648ee56a");
 	test_object("master~1^2", "c47800c7266a2be04c571c04d5a6614691ea99bd");
 	test_object("master^1^2~1", "5b5b025afb0b4c913b4c338a42934a3863bf3644");
+	test_object("master^^2^", "5b5b025afb0b4c913b4c338a42934a3863bf3644");
 	test_object("master^1^1^1^1^1", "8496071c1b46c854b31185ea97743be6a8774479");
+	test_object("master^^1^2^1", NULL);
 }
 
 void test_refs_revparse__upstream(void)
@@ -158,6 +190,10 @@ void test_refs_revparse__upstream(void)
 void test_refs_revparse__ordinal(void)
 {
 	cl_git_fail(git_revparse_single(&g_obj, g_repo, "master@{-2}"));
+	
+	/* TODO: make the test below actually fail
+	 * cl_git_fail(git_revparse_single(&g_obj, g_repo, "master@{1a}"));
+	 */
 
 	test_object("nope@{0}", NULL);
 	test_object("master@{31415}", NULL);
@@ -177,6 +213,7 @@ void test_refs_revparse__previous_head(void)
 {
 	cl_git_fail(git_revparse_single(&g_obj, g_repo, "@{-xyz}"));
 	cl_git_fail(git_revparse_single(&g_obj, g_repo, "@{-0}"));
+	cl_git_fail(git_revparse_single(&g_obj, g_repo, "@{-1b}"));
 
 	test_object("@{-42}", NULL);
 
@@ -353,6 +390,7 @@ void test_refs_revparse__colon(void)
 	test_object(":/one", "c47800c7266a2be04c571c04d5a6614691ea99bd");
 	test_object(":/packed commit t", "41bc8c69075bbdb46c5c6f0566cc8cc5b46e8bd9");
 	test_object("test/master^2:branch_file.txt", "45b983be36b73c0788dc9cbcb76cbb80fc7bb057");
+	test_object("test/master@{1}:branch_file.txt", "3697d64be941a53d4ae8f6a271e4e3fa56b022cc");
 }
 
 void test_refs_revparse__disambiguation(void)