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
93e55a02
Commit
93e55a02
authored
Apr 05, 2023
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
object: sha256 lookups
parent
27e29472
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
12 deletions
+22
-12
src/libgit2/object.c
+22
-12
No files found.
src/libgit2/object.c
View file @
93e55a02
...
...
@@ -181,6 +181,7 @@ int git_object_lookup_prefix(
git_object
*
object
=
NULL
;
git_odb
*
odb
=
NULL
;
git_odb_object
*
odb_obj
=
NULL
;
size_t
oid_hexsize
;
int
error
=
0
;
GIT_ASSERT_ARG
(
repo
);
...
...
@@ -196,10 +197,12 @@ int git_object_lookup_prefix(
if
(
error
<
0
)
return
error
;
if
(
len
>
GIT_OID_SHA1_HEXSIZE
)
len
=
GIT_OID_SHA1_HEXSIZE
;
oid_hexsize
=
git_oid_hexsize
(
repo
->
oid_type
);
if
(
len
==
GIT_OID_SHA1_HEXSIZE
)
{
if
(
len
>
oid_hexsize
)
len
=
oid_hexsize
;
if
(
len
==
oid_hexsize
)
{
git_cached_obj
*
cached
=
NULL
;
/* We want to match the full id : we can first look up in the cache,
...
...
@@ -233,8 +236,9 @@ int git_object_lookup_prefix(
error
=
git_odb_read
(
&
odb_obj
,
odb
,
id
);
}
}
else
{
git_oid
short_oid
=
GIT_OID_SHA1_ZERO
;
git_oid
short_oid
;
git_oid_clear
(
&
short_oid
,
repo
->
oid_type
);
git_oid__cpy_prefix
(
&
short_oid
,
id
,
len
);
/* If len < GIT_OID_SHA1_HEXSIZE (a strict short oid was given), we have
...
...
@@ -262,7 +266,8 @@ int git_object_lookup_prefix(
}
int
git_object_lookup
(
git_object
**
object_out
,
git_repository
*
repo
,
const
git_oid
*
id
,
git_object_t
type
)
{
return
git_object_lookup_prefix
(
object_out
,
repo
,
id
,
GIT_OID_SHA1_HEXSIZE
,
type
);
return
git_object_lookup_prefix
(
object_out
,
repo
,
id
,
git_oid_hexsize
(
repo
->
oid_type
),
type
);
}
void
git_object_free
(
git_object
*
object
)
...
...
@@ -503,31 +508,36 @@ cleanup:
static
int
git_object__short_id
(
git_str
*
out
,
const
git_object
*
obj
)
{
git_repository
*
repo
;
int
len
=
GIT_ABBREV_DEFAULT
,
error
;
git_oid
id
=
GIT_OID_SHA1_ZERO
;
git_oid
id
;
git_odb
*
odb
;
size_t
oid_hexsize
;
int
len
=
GIT_ABBREV_DEFAULT
,
error
;
GIT_ASSERT_ARG
(
out
);
GIT_ASSERT_ARG
(
obj
);
repo
=
git_object_owner
(
obj
);
git_oid_clear
(
&
id
,
repo
->
oid_type
);
oid_hexsize
=
git_oid_hexsize
(
repo
->
oid_type
);
if
((
error
=
git_repository__configmap_lookup
(
&
len
,
repo
,
GIT_CONFIGMAP_ABBREV
))
<
0
)
return
error
;
if
(
len
<
0
||
(
size_t
)
len
>
oid_hexsize
)
{
git_error_set
(
GIT_ERROR_CONFIG
,
"invalid oid abbreviation setting: '%d'"
,
len
);
return
-
1
;
}
if
((
error
=
git_repository_odb
(
&
odb
,
repo
))
<
0
)
return
error
;
while
(
len
<
GIT_OID_SHA1_HEXSIZE
)
{
while
(
(
size_t
)
len
<
oid_hexsize
)
{
/* set up short oid */
memcpy
(
&
id
.
id
,
&
obj
->
cached
.
oid
.
id
,
(
len
+
1
)
/
2
);
if
(
len
&
1
)
id
.
id
[
len
/
2
]
&=
0xf0
;
#ifdef GIT_EXPERIMENTAL_SHA256
id
.
type
=
GIT_OID_SHA1
;
#endif
error
=
git_odb_exists_prefix
(
NULL
,
odb
,
&
id
,
len
);
if
(
error
!=
GIT_EAMBIGUOUS
)
break
;
...
...
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