Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
d1b7921a
Commit
d1b7921a
authored
Jul 12, 2012
by
nulltoken
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
revparse: fix disambiguation of refs and abbrev oids
parent
bb89cf94
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
7 deletions
+56
-7
src/revparse.c
+7
-7
tests-clar/refs/revparse.c
+49
-0
No files found.
src/revparse.c
View file @
d1b7921a
...
...
@@ -147,13 +147,6 @@ static int revparse_lookup_object(git_object **out, git_repository *repo, const
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
)
return
error
;
error
=
disambiguate_refname
(
&
ref
,
repo
,
spec
);
if
(
!
error
)
{
error
=
git_object_lookup
(
out
,
repo
,
git_reference_oid
(
ref
),
GIT_OBJ_ANY
);
...
...
@@ -164,6 +157,13 @@ static int revparse_lookup_object(git_object **out, git_repository *repo, const
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
)
return
error
;
giterr_set
(
GITERR_REFERENCE
,
"Refspec '%s' not found."
,
spec
);
return
GIT_ENOTFOUND
;
}
...
...
tests-clar/refs/revparse.c
View file @
d1b7921a
...
...
@@ -354,3 +354,52 @@ void test_refs_revparse__colon(void)
test_object
(
":/packed commit t"
,
"41bc8c69075bbdb46c5c6f0566cc8cc5b46e8bd9"
);
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"
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment