Commit 46c2ead05d289b4ed1ad96c63b75a228f02dd74c

Ben Straub 2012-05-10T13:39:34

Now properly handling branches with "-g" in their names.

diff --git a/src/revparse.c b/src/revparse.c
index 4c03fdf..c22bd98 100644
--- a/src/revparse.c
+++ b/src/revparse.c
@@ -56,9 +56,9 @@ static int revparse_lookup_object(git_object **out, git_repository *repo, const 
 
    /* "git describe" output; snip everything before/including "-g" */
    substr = strstr(spec, "-g");
-   if (substr) {
-      spec = substr + 2;
-      speclen = strlen(spec);
+   if (substr &&
+       !revparse_lookup_object(out, repo, substr+2)) {
+      return 0;
    }
 
    /* SHA or prefix */
diff --git a/tests-clar/refs/revparse.c b/tests-clar/refs/revparse.c
index d7affaf..4c9eeb4 100644
--- a/tests-clar/refs/revparse.c
+++ b/tests-clar/refs/revparse.c
@@ -66,6 +66,7 @@ void test_refs_revparse__partial_refs(void)
 void test_refs_revparse__describe_output(void)
 {
    test_object("blah-7-gc47800c", "c47800c7266a2be04c571c04d5a6614691ea99bd");
+   test_object("not-good", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750");
 }
 
 void test_refs_revparse__nth_parent(void)
diff --git a/tests/resources/testrepo.git/refs/heads/not-good b/tests/resources/testrepo.git/refs/heads/not-good
new file mode 100644
index 0000000..3d8f0a4
--- /dev/null
+++ b/tests/resources/testrepo.git/refs/heads/not-good
@@ -0,0 +1 @@
+a65fedf39aefe402d3bb6e24df4d4f5fe4547750