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
2d33fe78
Commit
2d33fe78
authored
Aug 02, 2022
by
yuangli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor git_fetch_option.depth and usage
parent
e7294e87
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
2 deletions
+11
-2
include/git2/remote.h
+3
-1
src/libgit2/clone.c
+8
-1
No files found.
include/git2/remote.h
View file @
2d33fe78
...
...
@@ -744,7 +744,9 @@ typedef struct {
git_proxy_options
proxy_opts
;
/**
* Depth of the fetch to perform
* Depth of the fetch to perform, has to be a positive integer.
*
* The default is -1, which will fetch the full history.
*/
int
depth
;
...
...
src/libgit2/clone.c
View file @
2d33fe78
...
...
@@ -389,6 +389,11 @@ static int checkout_branch(git_repository *repo, git_remote *remote, const git_c
return
error
;
}
static
int
git_fetch_is_shallow
(
git_fetch_options
*
opts
)
{
return
opts
->
depth
>
0
;
}
static
int
clone_into
(
git_repository
*
repo
,
git_remote
*
_remote
,
const
git_fetch_options
*
opts
,
const
git_checkout_options
*
co_opts
,
const
char
*
branch
)
{
int
error
;
...
...
@@ -409,8 +414,10 @@ static int clone_into(git_repository *repo, git_remote *_remote, const git_fetch
memcpy
(
&
fetch_opts
,
opts
,
sizeof
(
git_fetch_options
));
fetch_opts
.
update_fetchhead
=
0
;
if
(
fetch_opts
.
depth
==
-
1
)
if
(
!
git_fetch_is_shallow
(
opts
))
fetch_opts
.
download_tags
=
GIT_REMOTE_DOWNLOAD_TAGS_ALL
;
git_str_printf
(
&
reflog_message
,
"clone: from %s"
,
git_remote_url
(
remote
));
if
((
error
=
git_remote_fetch
(
remote
,
NULL
,
&
fetch_opts
,
git_str_cstr
(
&
reflog_message
)))
!=
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