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
7186d7ba
Commit
7186d7ba
authored
Sep 21, 2022
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
revparse: don't assume SHA1
parent
e56f3507
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
5 deletions
+12
-5
src/libgit2/revparse.c
+12
-5
No files found.
src/libgit2/revparse.c
View file @
7186d7ba
...
...
@@ -15,21 +15,28 @@
#include "git2.h"
static
int
maybe_sha_or_abbrev
(
git_object
**
out
,
git_repository
*
repo
,
const
char
*
spec
,
size_t
speclen
)
static
int
maybe_sha_or_abbrev
(
git_object
**
out
,
git_repository
*
repo
,
const
char
*
spec
,
size_t
speclen
)
{
git_oid
oid
;
if
(
git_oid__fromstrn
(
&
oid
,
spec
,
speclen
,
GIT_OID_SHA1
)
<
0
)
if
(
git_oid__fromstrn
(
&
oid
,
spec
,
speclen
,
repo
->
oid_type
)
<
0
)
return
GIT_ENOTFOUND
;
return
git_object_lookup_prefix
(
out
,
repo
,
&
oid
,
speclen
,
GIT_OBJECT_ANY
);
}
static
int
maybe_sha
(
git_object
**
out
,
git_repository
*
repo
,
const
char
*
spec
)
static
int
maybe_sha
(
git_object
**
out
,
git_repository
*
repo
,
const
char
*
spec
)
{
size_t
speclen
=
strlen
(
spec
);
if
(
speclen
!=
GIT_OID_SHA1_HEXSIZE
)
if
(
speclen
!=
git_oid_hexsize
(
repo
->
oid_type
)
)
return
GIT_ENOTFOUND
;
return
maybe_sha_or_abbrev
(
out
,
repo
,
spec
,
speclen
);
...
...
@@ -110,7 +117,7 @@ static int revparse_lookup_object(
if
(
error
!=
GIT_ENOTFOUND
)
return
error
;
if
((
strlen
(
spec
)
<
GIT_OID_SHA1_HEXSIZE
)
&&
if
((
strlen
(
spec
)
<
git_oid_hexsize
(
repo
->
oid_type
)
)
&&
((
error
=
maybe_abbrev
(
object_out
,
repo
,
spec
))
!=
GIT_ENOTFOUND
))
return
error
;
...
...
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