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
fe3a40a4
Commit
fe3a40a4
authored
Sep 16, 2013
by
Carlos Martín Nieto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remote: add a convenience 'fetch' function.
parent
d19870d9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
20 deletions
+31
-20
include/git2/remote.h
+11
-0
src/clone.c
+2
-20
src/remote.c
+18
-0
No files found.
include/git2/remote.h
View file @
fe3a40a4
...
...
@@ -311,6 +311,17 @@ GIT_EXTERN(void) git_remote_free(git_remote *remote);
GIT_EXTERN
(
int
)
git_remote_update_tips
(
git_remote
*
remote
);
/**
* Download new data and update tips
*
* Convenience function to connect to a remote, download the data,
* disconnect and update the remote-tracking branches.
*
* @param remote the remote to fetch from
* @return 0 or an error code
*/
GIT_EXTERN
(
int
)
git_remote_fetch
(
git_remote
*
remote
);
/**
* Return whether a string is a valid remote URL
*
* @param url the url to check
...
...
src/clone.c
View file @
fe3a40a4
...
...
@@ -350,24 +350,6 @@ on_error:
return
error
;
}
static
int
do_fetch
(
git_remote
*
origin
)
{
int
retcode
;
/* Connect and download everything */
if
((
retcode
=
git_remote_connect
(
origin
,
GIT_DIRECTION_FETCH
))
<
0
)
return
retcode
;
if
((
retcode
=
git_remote_download
(
origin
))
<
0
)
return
retcode
;
/* Create "origin/foo" branches for all remote branches */
if
((
retcode
=
git_remote_update_tips
(
origin
))
<
0
)
return
retcode
;
return
0
;
}
static
int
setup_remotes_and_fetch
(
git_repository
*
repo
,
const
char
*
url
,
...
...
@@ -391,7 +373,7 @@ static int setup_remotes_and_fetch(
((
retcode
=
git_remote_add_fetch
(
origin
,
"refs/tags/*:refs/tags/*"
))
<
0
))
goto
on_error
;
if
((
retcode
=
do
_fetch
(
origin
))
<
0
)
if
((
retcode
=
git_remote
_fetch
(
origin
))
<
0
)
goto
on_error
;
/* Point HEAD to the requested branch */
...
...
@@ -459,7 +441,7 @@ int git_clone_into(git_repository *repo, git_remote *remote, git_checkout_opts *
old_fetchhead
=
git_remote_update_fetchhead
(
remote
);
git_remote_set_update_fetchhead
(
remote
,
0
);
if
((
error
=
do
_fetch
(
remote
))
<
0
)
if
((
error
=
git_remote
_fetch
(
remote
))
<
0
)
goto
cleanup
;
if
(
branch
)
...
...
src/remote.c
View file @
fe3a40a4
...
...
@@ -767,6 +767,24 @@ int git_remote_download(git_remote *remote)
return
git_fetch_download_pack
(
remote
);
}
int
git_remote_fetch
(
git_remote
*
remote
)
{
int
error
;
/* Connect and download everything */
if
((
error
=
git_remote_connect
(
remote
,
GIT_DIRECTION_FETCH
))
<
0
)
return
error
;
if
((
error
=
git_remote_download
(
remote
))
<
0
)
return
error
;
/* We don't need to be connected anymore */
git_remote_disconnect
(
remote
);
/* Create "remote/foo" branches for all remote branches */
return
git_remote_update_tips
(
remote
);
}
static
int
remote_head_for_fetchspec_src
(
git_remote_head
**
out
,
git_vector
*
update_heads
,
const
char
*
fetchspec_src
)
{
unsigned
int
i
;
...
...
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