diff options
| author | Ben Straub <bstraub@github.com> | 2012-05-10 13:39:34 -0700 |
|---|---|---|
| committer | Ben Straub <bstraub@github.com> | 2012-05-11 11:35:50 -0700 |
| commit | 46c2ead05d289b4ed1ad96c63b75a228f02dd74c (patch) | |
| tree | d5873ec9ebb8ce1ff41a6ac4f8e103de3944ec5d | |
| parent | ec6a632a1bdc5e14c14964005946f35ad61c0259 (diff) | |
| download | libgit2-46c2ead05d289b4ed1ad96c63b75a228f02dd74c.tar.gz | |
Now properly handling branches with "-g" in their names.
| -rw-r--r-- | src/revparse.c | 6 | ||||
| -rw-r--r-- | tests-clar/refs/revparse.c | 1 | ||||
| -rw-r--r-- | tests/resources/testrepo.git/refs/heads/not-good | 1 |
3 files changed, 5 insertions, 3 deletions
diff --git a/src/revparse.c b/src/revparse.c index 4c03fdf38..c22bd98d8 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 d7affafe9..4c9eeb4c3 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 000000000..3d8f0a402 --- /dev/null +++ b/tests/resources/testrepo.git/refs/heads/not-good @@ -0,0 +1 @@ +a65fedf39aefe402d3bb6e24df4d4f5fe4547750 |
