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
e78d2ac9
Commit
e78d2ac9
authored
Mar 09, 2016
by
Vicent Marti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
odb: Refactor `git_odb_expand_ids`
parent
4416aa77
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
21 deletions
+26
-21
src/odb.c
+26
-21
No files found.
src/odb.c
View file @
e78d2ac9
...
@@ -782,37 +782,42 @@ int git_odb_expand_ids(
...
@@ -782,37 +782,42 @@ int git_odb_expand_ids(
for
(
i
=
0
;
i
<
count
;
i
++
)
{
for
(
i
=
0
;
i
<
count
;
i
++
)
{
git_odb_expand_id
*
query
=
&
ids
[
i
];
git_odb_expand_id
*
query
=
&
ids
[
i
];
git_oid
actual_id
;
git_otype
query_type
=
(
query
->
type
==
GIT_OBJ_ANY
)
?
0
:
query
->
type
;
git_otype
actual_type
=
0
;
int
error
=
GIT_EAMBIGUOUS
;
int
error
=
GIT_EAMBIGUOUS
;
/* if we were given a full object ID, simply look it up */
if
(
!
query
->
type
)
if
(
query
->
length
>=
GIT_OID_HEXSZ
)
{
query
->
type
=
GIT_OBJ_ANY
;
error
=
odb_otype_fast
(
&
actual_type
,
db
,
&
query
->
id
);
git_oid_cpy
(
&
actual_id
,
&
query
->
id
);
/* if we have a short OID, expand it first */
if
(
query
->
length
>=
GIT_OID_MINPREFIXLEN
&&
query
->
length
<
GIT_OID_HEXSZ
)
{
git_oid
actual_id
;
error
=
odb_exists_prefix_1
(
&
actual_id
,
db
,
&
query
->
id
,
query
->
length
,
false
);
if
(
!
error
)
{
git_oid_cpy
(
&
query
->
id
,
&
actual_id
);
query
->
length
=
GIT_OID_HEXSZ
;
}
}
}
/*
/*
*
otherwise, resolve the short id to full if it's long enough, then
*
now we ought to have a 40-char OID, either because we've expanded it
*
(optionally) read the header
*
or because the user passed a full OID. Ensure its type is right.
*/
*/
else
if
(
query
->
length
>=
GIT_OID_MINPREFIXLEN
)
{
if
(
query
->
length
>=
GIT_OID_HEXSZ
)
{
error
=
odb_exists_prefix_1
(
&
actual_id
,
db
,
&
query
->
id
,
query
->
length
,
false
);
git_otype
actual_type
;
if
(
!
error
)
error
=
odb_otype_fast
(
&
actual_type
,
db
,
&
actual_id
);
}
/* Ensure that the looked up type matches the type we were expecting */
error
=
odb_otype_fast
(
&
actual_type
,
db
,
&
query
->
id
);
if
(
query_type
&&
query_type
!=
actual_type
)
if
(
!
error
)
{
error
=
GIT_ENOTFOUND
;
if
(
query
->
type
!=
GIT_OBJ_ANY
&&
query
->
type
!=
actual_type
)
error
=
GIT_ENOTFOUND
;
else
query
->
type
=
actual_type
;
}
}
switch
(
error
)
{
switch
(
error
)
{
/* no errors, so we've successfully expanded the OID */
case
0
:
case
0
:
git_oid_cpy
(
&
query
->
id
,
&
actual_id
);
continue
;
query
->
length
=
GIT_OID_HEXSZ
;
query
->
type
=
actual_type
;
break
;
/* the object is missing or ambiguous */
/* the object is missing or ambiguous */
case
GIT_ENOTFOUND
:
case
GIT_ENOTFOUND
:
...
...
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