diff options
author | nulltoken <emeric.fermas@gmail.com> | 2013-07-13 15:30:23 +0400 |
---|---|---|
committer | nulltoken <emeric.fermas@gmail.com> | 2013-07-13 18:07:10 +0400 |
commit | 80fd31faf773f3f50e2b5547b7171063f38dac17 (patch) | |
tree | f266014c6f292dcbedcc1a3cc01fcefc7f69d0b9 /src | |
parent | 1662158cf98ce32827f3857fd9559a1b0e6223ed (diff) |
revparse: Don't return a reference when asked for a git object
Fix #1722
Diffstat (limited to 'src')
-rw-r--r-- | src/revparse.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/revparse.c b/src/revparse.c index bcfb0843f..d21f08b53 100644 --- a/src/revparse.c +++ b/src/revparse.c @@ -685,6 +685,8 @@ int revparse__ext( git_reference *reference = NULL; git_object *base_rev = NULL; + bool should_return_reference = true; + assert(object_out && reference_out && repo && spec); *object_out = NULL; @@ -693,6 +695,8 @@ int revparse__ext( while (spec[pos]) { switch (spec[pos]) { case '^': + should_return_reference = false; + if ((error = ensure_base_rev_loaded(&base_rev, &reference, spec, identifier_len, repo, false)) < 0) goto cleanup; @@ -725,6 +729,8 @@ int revparse__ext( { git_object *temp_object = NULL; + should_return_reference = false; + if ((error = extract_how_many(&n, spec, &pos)) < 0) goto cleanup; @@ -743,6 +749,8 @@ int revparse__ext( { git_object *temp_object = NULL; + should_return_reference = false; + if ((error = extract_path(&buf, spec, &pos)) < 0) goto cleanup; @@ -807,6 +815,11 @@ int revparse__ext( if ((error = ensure_base_rev_loaded(&base_rev, &reference, spec, identifier_len, repo, false)) < 0) goto cleanup; + if (!should_return_reference) { + git_reference_free(reference); + reference = NULL; + } + *object_out = base_rev; *reference_out = reference; *identifier_len_out = identifier_len; |