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
598ec303
Commit
598ec303
authored
Jul 29, 2022
by
yuangli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
eliminate build warnings
parent
73d25f0e
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
27 additions
and
24 deletions
+27
-24
src/libgit2/fetch.c
+0
-2
src/libgit2/grafts.c
+2
-5
src/libgit2/grafts.h
+1
-1
src/libgit2/repository.c
+13
-5
src/libgit2/transports/smart_pkt.c
+2
-2
tests/libgit2/clone/shallow.c
+9
-9
No files found.
src/libgit2/fetch.c
View file @
598ec303
...
...
@@ -202,8 +202,6 @@ int git_fetch_negotiate(git_remote *remote, const git_fetch_options *opts)
int
git_fetch_download_pack
(
git_remote
*
remote
)
{
git_transport
*
t
=
remote
->
transport
;
git_indexer_progress_cb
progress
=
NULL
;
void
*
payload
=
NULL
;
int
error
;
if
(
!
remote
->
need_pack
)
...
...
src/libgit2/grafts.c
View file @
598ec303
...
...
@@ -220,9 +220,8 @@ int git_grafts_get(git_commit_graft **out, git_grafts *grafts, const git_oid *oi
return
0
;
}
int
git_grafts_get_oids
(
git_
oidarray
*
out
,
git_grafts
*
grafts
)
int
git_grafts_get_oids
(
git_
array_oid_t
*
out
,
git_grafts
*
grafts
)
{
git_array_oid_t
oids
=
GIT_ARRAY_INIT
;
const
git_oid
*
oid
;
size_t
i
=
0
;
int
error
;
...
...
@@ -230,13 +229,11 @@ int git_grafts_get_oids(git_oidarray *out, git_grafts *grafts)
assert
(
out
&&
grafts
);
while
((
error
=
git_oidmap_iterate
(
NULL
,
grafts
->
commits
,
&
i
,
&
oid
))
==
0
)
{
git_oid
*
cpy
=
git_array_alloc
(
oids
);
git_oid
*
cpy
=
git_array_alloc
(
*
out
);
GIT_ERROR_CHECK_ALLOC
(
cpy
);
git_oid_cpy
(
cpy
,
oid
);
}
git_oidarray__from_array
(
out
,
&
oids
);
return
0
;
}
...
...
src/libgit2/grafts.h
View file @
598ec303
...
...
@@ -31,7 +31,7 @@ int git_grafts_parse(git_grafts *grafts, const char *content, size_t contentlen)
int
git_grafts_add
(
git_grafts
*
grafts
,
const
git_oid
*
oid
,
git_array_oid_t
parents
);
int
git_grafts_remove
(
git_grafts
*
grafts
,
const
git_oid
*
oid
);
int
git_grafts_get
(
git_commit_graft
**
out
,
git_grafts
*
grafts
,
const
git_oid
*
oid
);
int
git_grafts_get_oids
(
git_
oidarray
*
out
,
git_grafts
*
grafts
);
int
git_grafts_get_oids
(
git_
array_oid_t
*
out
,
git_grafts
*
grafts
);
size_t
git_grafts_size
(
git_grafts
*
grafts
);
#endif
src/libgit2/repository.c
View file @
598ec303
...
...
@@ -3341,12 +3341,20 @@ int git_repository_state_cleanup(git_repository *repo)
}
int
git_repository__shallow_roots
(
git_array_oid_t
*
out
,
git_repository
*
repo
)
{
int
error
=
0
;
if
(
!
repo
->
shallow_grafts
)
load_grafts
(
repo
);
int
error
=
0
;
if
(
!
repo
->
shallow_grafts
&&
(
error
=
load_grafts
(
repo
))
<
0
)
return
error
;
if
((
error
=
git_grafts_refresh
(
repo
->
shallow_grafts
))
<
0
)
{
return
error
;
}
git_grafts_refresh
(
repo
->
shallow_grafts
);
return
git_grafts_get_oids
(
out
,
repo
->
shallow_grafts
);
if
((
error
=
git_grafts_get_oids
(
out
,
repo
->
shallow_grafts
))
<
0
)
{
return
error
;
}
return
0
;
}
int
git_repository__shallow_roots_write
(
git_repository
*
repo
,
git_array_oid_t
roots
)
...
...
src/libgit2/transports/smart_pkt.c
View file @
598ec303
...
...
@@ -675,7 +675,7 @@ int git_pkt_buffer_wants(
/* Tell the server about our shallow objects */
for
(
i
=
0
;
i
<
git_shallowarray_count
(
wants
->
shallow_roots
);
i
++
)
{
char
oid
[
GIT_OID_HEXSZ
];
git_
buf
shallow_buf
=
GIT_BUF
_INIT
;
git_
str
shallow_buf
=
GIT_STR
_INIT
;
git_oid_fmt
(
oid
,
git_shallowarray_get
(
wants
->
shallow_roots
,
i
));
git_str_puts
(
&
shallow_buf
,
"shallow "
);
...
...
@@ -689,7 +689,7 @@ int git_pkt_buffer_wants(
}
if
(
wants
->
depth
>
0
)
{
git_
buf
deepen_buf
=
GIT_BUF
_INIT
;
git_
str
deepen_buf
=
GIT_STR
_INIT
;
git_str_printf
(
&
deepen_buf
,
"deepen %d
\n
"
,
wants
->
depth
);
git_str_printf
(
buf
,
"%04x%s"
,
(
unsigned
int
)
git_str_len
(
&
deepen_buf
)
+
4
,
git_str_cstr
(
&
deepen_buf
));
...
...
tests/clone/shallow.c
→
tests/
libgit2/
clone/shallow.c
View file @
598ec303
...
...
@@ -24,21 +24,21 @@ static int remote_single_branch(git_remote **out, git_repository *repo, const ch
void
test_clone_shallow__clone_depth_one
(
void
)
{
git_
buf
path
=
GIT_BUF
_INIT
;
git_
str
path
=
GIT_STR
_INIT
;
git_repository
*
repo
;
git_revwalk
*
walk
;
git_clone_options
clone_opts
=
GIT_CLONE_OPTIONS_INIT
;
git_oid
oid
;
git_oidarray
roots
;
roots
;
size_t
num_commits
=
0
;
int
error
=
0
;
clone_opts
.
fetch_opts
.
depth
=
1
;
clone_opts
.
remote_cb
=
remote_single_branch
;
git_
buf
_joinpath
(
&
path
,
clar_sandbox_path
(),
"shallowclone_1"
);
git_
str
_joinpath
(
&
path
,
clar_sandbox_path
(),
"shallowclone_1"
);
cl_git_pass
(
git_clone
(
&
repo
,
"https://github.com/libgit2/TestGitRepository"
,
git_
buf
_cstr
(
&
path
),
&
clone_opts
));
cl_git_pass
(
git_clone
(
&
repo
,
"https://github.com/libgit2/TestGitRepository"
,
git_
str
_cstr
(
&
path
),
&
clone_opts
));
cl_assert_equal_b
(
true
,
git_repository_is_shallow
(
repo
));
...
...
@@ -57,14 +57,14 @@ void test_clone_shallow__clone_depth_one(void)
cl_assert_equal_i
(
num_commits
,
1
);
cl_assert_equal_i
(
error
,
GIT_ITEROVER
);
git_
buf
_dispose
(
&
path
);
git_
str
_dispose
(
&
path
);
git_revwalk_free
(
walk
);
git_repository_free
(
repo
);
}
void
test_clone_shallow__clone_depth_five
(
void
)
{
git_
buf
path
=
GIT_BUF
_INIT
;
git_
str
path
=
GIT_STR
_INIT
;
git_repository
*
repo
;
git_revwalk
*
walk
;
git_clone_options
clone_opts
=
GIT_CLONE_OPTIONS_INIT
;
...
...
@@ -76,9 +76,9 @@ void test_clone_shallow__clone_depth_five(void)
clone_opts
.
fetch_opts
.
depth
=
5
;
clone_opts
.
remote_cb
=
remote_single_branch
;
git_
buf
_joinpath
(
&
path
,
clar_sandbox_path
(),
"shallowclone_5"
);
git_
str
_joinpath
(
&
path
,
clar_sandbox_path
(),
"shallowclone_5"
);
cl_git_pass
(
git_clone
(
&
repo
,
"https://github.com/libgit2/TestGitRepository"
,
git_
buf
_cstr
(
&
path
),
&
clone_opts
));
cl_git_pass
(
git_clone
(
&
repo
,
"https://github.com/libgit2/TestGitRepository"
,
git_
str
_cstr
(
&
path
),
&
clone_opts
));
cl_assert_equal_b
(
true
,
git_repository_is_shallow
(
repo
));
...
...
@@ -99,7 +99,7 @@ void test_clone_shallow__clone_depth_five(void)
cl_assert_equal_i
(
num_commits
,
13
);
cl_assert_equal_i
(
error
,
GIT_ITEROVER
);
git_
buf
_dispose
(
&
path
);
git_
str
_dispose
(
&
path
);
git_revwalk_free
(
walk
);
git_repository_free
(
repo
);
}
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