mirror of
https://git.proxmox.com/git/libgit2
synced 2025-07-13 14:30:29 +00:00
revparse: fix disambiguation of refs and abbrev oids
This commit is contained in:
parent
bb89cf9478
commit
d1b7921a48
@ -147,13 +147,6 @@ static int revparse_lookup_object(git_object **out, git_repository *repo, const
|
|||||||
if (error < 0 && error != GIT_ENOTFOUND)
|
if (error < 0 && error != GIT_ENOTFOUND)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
error = maybe_sha_or_abbrev(out, repo, spec);
|
|
||||||
if (!error)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (error < 0 && error != GIT_ENOTFOUND)
|
|
||||||
return error;
|
|
||||||
|
|
||||||
error = disambiguate_refname(&ref, repo, spec);
|
error = disambiguate_refname(&ref, repo, spec);
|
||||||
if (!error) {
|
if (!error) {
|
||||||
error = git_object_lookup(out, repo, git_reference_oid(ref), GIT_OBJ_ANY);
|
error = git_object_lookup(out, repo, git_reference_oid(ref), GIT_OBJ_ANY);
|
||||||
@ -161,6 +154,13 @@ static int revparse_lookup_object(git_object **out, git_repository *repo, const
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (error < 0 && error != GIT_ENOTFOUND)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
error = maybe_sha_or_abbrev(out, repo, spec);
|
||||||
|
if (!error)
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (error < 0 && error != GIT_ENOTFOUND)
|
if (error < 0 && error != GIT_ENOTFOUND)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
|
@ -354,3 +354,52 @@ void test_refs_revparse__colon(void)
|
|||||||
test_object(":/packed commit t", "41bc8c69075bbdb46c5c6f0566cc8cc5b46e8bd9");
|
test_object(":/packed commit t", "41bc8c69075bbdb46c5c6f0566cc8cc5b46e8bd9");
|
||||||
test_object("test/master^2:branch_file.txt", "45b983be36b73c0788dc9cbcb76cbb80fc7bb057");
|
test_object("test/master^2:branch_file.txt", "45b983be36b73c0788dc9cbcb76cbb80fc7bb057");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void test_refs_revparse__disambiguation(void)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* $ git show e90810b
|
||||||
|
* tag e90810b
|
||||||
|
* Tagger: Vicent Marti <tanoku@gmail.com>
|
||||||
|
* Date: Thu Aug 12 03:59:17 2010 +0200
|
||||||
|
*
|
||||||
|
* This is a very simple tag.
|
||||||
|
*
|
||||||
|
* commit e90810b8df3e80c413d903f631643c716887138d
|
||||||
|
* Author: Vicent Marti <tanoku@gmail.com>
|
||||||
|
* Date: Thu Aug 5 18:42:20 2010 +0200
|
||||||
|
*
|
||||||
|
* Test commit 2
|
||||||
|
*
|
||||||
|
* diff --git a/readme.txt b/readme.txt
|
||||||
|
* index 6336846..0266163 100644
|
||||||
|
* --- a/readme.txt
|
||||||
|
* +++ b/readme.txt
|
||||||
|
* @@ -1 +1,2 @@
|
||||||
|
* Testing a readme.txt
|
||||||
|
* +Now we add a single line here
|
||||||
|
*
|
||||||
|
* $ git show-ref e90810b
|
||||||
|
* 7b4384978d2493e851f9cca7858815fac9b10980 refs/tags/e90810b
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
test_object("e90810b", "7b4384978d2493e851f9cca7858815fac9b10980");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* $ git show e90810
|
||||||
|
* commit e90810b8df3e80c413d903f631643c716887138d
|
||||||
|
* Author: Vicent Marti <tanoku@gmail.com>
|
||||||
|
* Date: Thu Aug 5 18:42:20 2010 +0200
|
||||||
|
*
|
||||||
|
* Test commit 2
|
||||||
|
*
|
||||||
|
* diff --git a/readme.txt b/readme.txt
|
||||||
|
* index 6336846..0266163 100644
|
||||||
|
* --- a/readme.txt
|
||||||
|
* +++ b/readme.txt
|
||||||
|
* @@ -1 +1,2 @@
|
||||||
|
* Testing a readme.txt
|
||||||
|
* +Now we add a single line here
|
||||||
|
*/
|
||||||
|
test_object("e90810", "e90810b8df3e80c413d903f631643c716887138d");
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user