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
440b1995
Commit
440b1995
authored
Apr 06, 2023
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fetch: support SHA256 refs
parent
d16731e4
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
11 deletions
+13
-11
src/libgit2/fetch.c
+2
-2
src/libgit2/fetchhead.c
+11
-9
No files found.
src/libgit2/fetch.c
View file @
440b1995
...
@@ -76,7 +76,7 @@ static int maybe_want_oid(git_remote *remote, git_refspec *spec)
...
@@ -76,7 +76,7 @@ static int maybe_want_oid(git_remote *remote, git_refspec *spec)
oid_head
=
git__calloc
(
1
,
sizeof
(
git_remote_head
));
oid_head
=
git__calloc
(
1
,
sizeof
(
git_remote_head
));
GIT_ERROR_CHECK_ALLOC
(
oid_head
);
GIT_ERROR_CHECK_ALLOC
(
oid_head
);
git_oid__fromstr
(
&
oid_head
->
oid
,
spec
->
src
,
GIT_OID_SHA1
);
git_oid__fromstr
(
&
oid_head
->
oid
,
spec
->
src
,
remote
->
repo
->
oid_type
);
if
(
spec
->
dst
)
{
if
(
spec
->
dst
)
{
oid_head
->
name
=
git__strdup
(
spec
->
dst
);
oid_head
->
name
=
git__strdup
(
spec
->
dst
);
...
@@ -137,7 +137,7 @@ static int filter_wants(git_remote *remote, const git_fetch_options *opts)
...
@@ -137,7 +137,7 @@ static int filter_wants(git_remote *remote, const git_fetch_options *opts)
/* Handle explicitly specified OID specs */
/* Handle explicitly specified OID specs */
git_vector_foreach
(
&
remote
->
active_refspecs
,
i
,
spec
)
{
git_vector_foreach
(
&
remote
->
active_refspecs
,
i
,
spec
)
{
if
(
!
git_oid__is_hexstr
(
spec
->
src
,
GIT_OID_SHA1
))
if
(
!
git_oid__is_hexstr
(
spec
->
src
,
remote
->
repo
->
oid_type
))
continue
;
continue
;
if
(
!
(
remote_caps
&
oid_mask
))
{
if
(
!
(
remote_caps
&
oid_mask
))
{
...
...
src/libgit2/fetchhead.c
View file @
440b1995
...
@@ -105,15 +105,14 @@ static int fetchhead_ref_write(
...
@@ -105,15 +105,14 @@ static int fetchhead_ref_write(
git_filebuf
*
file
,
git_filebuf
*
file
,
git_fetchhead_ref
*
fetchhead_ref
)
git_fetchhead_ref
*
fetchhead_ref
)
{
{
char
oid
[
GIT_OID_
SHA1
_HEXSIZE
+
1
];
char
oid
[
GIT_OID_
MAX
_HEXSIZE
+
1
];
const
char
*
type
,
*
name
;
const
char
*
type
,
*
name
;
int
head
=
0
;
int
head
=
0
;
GIT_ASSERT_ARG
(
file
);
GIT_ASSERT_ARG
(
file
);
GIT_ASSERT_ARG
(
fetchhead_ref
);
GIT_ASSERT_ARG
(
fetchhead_ref
);
git_oid_fmt
(
oid
,
&
fetchhead_ref
->
oid
);
git_oid_tostr
(
oid
,
GIT_OID_MAX_HEXSIZE
+
1
,
&
fetchhead_ref
->
oid
);
oid
[
GIT_OID_SHA1_HEXSIZE
]
=
'\0'
;
if
(
git__prefixcmp
(
fetchhead_ref
->
ref_name
,
GIT_REFS_HEADS_DIR
)
==
0
)
{
if
(
git__prefixcmp
(
fetchhead_ref
->
ref_name
,
GIT_REFS_HEADS_DIR
)
==
0
)
{
type
=
"branch "
;
type
=
"branch "
;
...
@@ -174,7 +173,8 @@ static int fetchhead_ref_parse(
...
@@ -174,7 +173,8 @@ static int fetchhead_ref_parse(
git_str
*
ref_name
,
git_str
*
ref_name
,
const
char
**
remote_url
,
const
char
**
remote_url
,
char
*
line
,
char
*
line
,
size_t
line_num
)
size_t
line_num
,
git_oid_t
oid_type
)
{
{
char
*
oid_str
,
*
is_merge_str
,
*
desc
,
*
name
=
NULL
;
char
*
oid_str
,
*
is_merge_str
,
*
desc
,
*
name
=
NULL
;
const
char
*
type
=
NULL
;
const
char
*
type
=
NULL
;
...
@@ -196,13 +196,13 @@ static int fetchhead_ref_parse(
...
@@ -196,13 +196,13 @@ static int fetchhead_ref_parse(
*
is_merge
=
1
;
*
is_merge
=
1
;
}
}
if
(
strlen
(
oid_str
)
!=
GIT_OID_SHA1_HEXSIZE
)
{
if
(
strlen
(
oid_str
)
!=
git_oid_hexsize
(
oid_type
)
)
{
git_error_set
(
GIT_ERROR_FETCHHEAD
,
git_error_set
(
GIT_ERROR_FETCHHEAD
,
"invalid object ID in FETCH_HEAD line %"
PRIuZ
,
line_num
);
"invalid object ID in FETCH_HEAD line %"
PRIuZ
,
line_num
);
return
-
1
;
return
-
1
;
}
}
if
(
git_oid__fromstr
(
oid
,
oid_str
,
GIT_OID_SHA1
)
<
0
)
{
if
(
git_oid__fromstr
(
oid
,
oid_str
,
oid_type
)
<
0
)
{
const
git_error
*
oid_err
=
git_error_last
();
const
git_error
*
oid_err
=
git_error_last
();
const
char
*
err_msg
=
oid_err
?
oid_err
->
message
:
"invalid object ID"
;
const
char
*
err_msg
=
oid_err
?
oid_err
->
message
:
"invalid object ID"
;
...
@@ -269,7 +269,8 @@ static int fetchhead_ref_parse(
...
@@ -269,7 +269,8 @@ static int fetchhead_ref_parse(
return
error
;
return
error
;
}
}
int
git_repository_fetchhead_foreach
(
git_repository
*
repo
,
int
git_repository_fetchhead_foreach
(
git_repository
*
repo
,
git_repository_fetchhead_foreach_cb
cb
,
git_repository_fetchhead_foreach_cb
cb
,
void
*
payload
)
void
*
payload
)
{
{
...
@@ -296,8 +297,9 @@ int git_repository_fetchhead_foreach(git_repository *repo,
...
@@ -296,8 +297,9 @@ int git_repository_fetchhead_foreach(git_repository *repo,
while
((
line
=
git__strsep
(
&
buffer
,
"
\n
"
))
!=
NULL
)
{
while
((
line
=
git__strsep
(
&
buffer
,
"
\n
"
))
!=
NULL
)
{
++
line_num
;
++
line_num
;
if
((
error
=
fetchhead_ref_parse
(
if
((
error
=
fetchhead_ref_parse
(
&
oid
,
&
is_merge
,
&
name
,
&
oid
,
&
is_merge
,
&
name
,
&
remote_url
,
line
,
line_num
))
<
0
)
&
remote_url
,
line
,
line_num
,
repo
->
oid_type
))
<
0
)
goto
done
;
goto
done
;
if
(
git_str_len
(
&
name
)
>
0
)
if
(
git_str_len
(
&
name
)
>
0
)
...
...
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