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
d5e5bbd7
Commit
d5e5bbd7
authored
May 06, 2013
by
Vicent Martí
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1524 from jamill/clone_tagopts
By default do not set tagopt when cloning
parents
450a78bf
6f748f38
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
25 deletions
+56
-25
src/clone.c
+35
-25
tests-clar/clone/nonetwork.c
+18
-0
tests-clar/online/clone.c
+3
-0
No files found.
src/clone.c
View file @
d5e5bbd7
...
...
@@ -358,31 +358,41 @@ static int setup_remotes_and_fetch(
git_remote
*
origin
;
/* Construct an origin remote */
if
(
!
create_and_configure_origin
(
&
origin
,
repo
,
url
,
options
))
{
git_remote_set_update_fetchhead
(
origin
,
0
);
/* Connect and download everything */
if
(
!
git_remote_connect
(
origin
,
GIT_DIRECTION_FETCH
))
{
if
(
!
(
retcode
=
git_remote_download
(
origin
,
options
->
fetch_progress_cb
,
options
->
fetch_progress_payload
)))
{
/* Create "origin/foo" branches for all remote branches */
if
(
!
git_remote_update_tips
(
origin
))
{
/* Point HEAD to the requested branch */
if
(
options
->
checkout_branch
)
{
if
(
!
update_head_to_branch
(
repo
,
options
))
retcode
=
0
;
}
/* Point HEAD to the same ref as the remote's head */
else
if
(
!
update_head_to_remote
(
repo
,
origin
))
{
retcode
=
0
;
}
}
}
git_remote_disconnect
(
origin
);
}
git_remote_free
(
origin
);
}
if
((
retcode
=
create_and_configure_origin
(
&
origin
,
repo
,
url
,
options
))
<
0
)
goto
on_error
;
git_remote_set_update_fetchhead
(
origin
,
0
);
/* If the download_tags value has not been specified, then make sure to
* download tags as well. It is set here because we want to download tags
* on the initial clone, but do not want to persist the value in the
* configuration file.
*/
if
(
origin
->
download_tags
==
GIT_REMOTE_DOWNLOAD_TAGS_AUTO
&&
((
retcode
=
git_remote_add_fetch
(
origin
,
"refs/tags/*:refs/tags/*"
))
<
0
))
goto
on_error
;
/* Connect and download everything */
if
((
retcode
=
git_remote_connect
(
origin
,
GIT_DIRECTION_FETCH
))
<
0
)
goto
on_error
;
if
((
retcode
=
git_remote_download
(
origin
,
options
->
fetch_progress_cb
,
options
->
fetch_progress_payload
))
<
0
)
goto
on_error
;
/* Create "origin/foo" branches for all remote branches */
if
((
retcode
=
git_remote_update_tips
(
origin
))
<
0
)
goto
on_error
;
/* Point HEAD to the requested branch */
if
(
options
->
checkout_branch
)
retcode
=
update_head_to_branch
(
repo
,
options
);
/* Point HEAD to the same ref as the remote's head */
else
retcode
=
update_head_to_remote
(
repo
,
origin
);
on_error:
git_remote_free
(
origin
);
return
retcode
;
}
...
...
@@ -425,7 +435,7 @@ static void normalize_options(git_clone_options *dst, const git_clone_options *s
/* Provide defaults for null pointers */
if
(
!
dst
->
remote_name
)
dst
->
remote_name
=
"origin"
;
if
(
!
dst
->
remote_autotag
)
dst
->
remote_autotag
=
GIT_REMOTE_DOWNLOAD_TAGS_A
LL
;
if
(
!
dst
->
remote_autotag
)
dst
->
remote_autotag
=
GIT_REMOTE_DOWNLOAD_TAGS_A
UTO
;
}
int
git_clone
(
...
...
tests-clar/clone/nonetwork.c
View file @
d5e5bbd7
...
...
@@ -172,6 +172,7 @@ void test_clone_nonetwork__custom_push_spec(void)
void
test_clone_nonetwork__custom_autotag
(
void
)
{
git_remote
*
origin
;
git_strarray
tags
=
{
0
};
g_options
.
remote_autotag
=
GIT_REMOTE_DOWNLOAD_TAGS_NONE
;
...
...
@@ -180,6 +181,23 @@ void test_clone_nonetwork__custom_autotag(void)
cl_git_pass
(
git_tag_list
(
&
tags
,
g_repo
));
cl_assert_equal_sz
(
0
,
tags
.
count
);
cl_git_pass
(
git_remote_load
(
&
origin
,
g_repo
,
"origin"
));
cl_assert_equal_i
(
GIT_REMOTE_DOWNLOAD_TAGS_NONE
,
origin
->
download_tags
);
git_strarray_free
(
&
tags
);
}
void
test_clone_nonetwork__custom_autotag_tags_all
(
void
)
{
git_strarray
tags
=
{
0
};
git_remote
*
origin
;
g_options
.
remote_autotag
=
GIT_REMOTE_DOWNLOAD_TAGS_ALL
;
cl_git_pass
(
git_clone
(
&
g_repo
,
cl_git_fixture_url
(
"testrepo.git"
),
"./foo"
,
&
g_options
));
cl_git_pass
(
git_remote_load
(
&
origin
,
g_repo
,
"origin"
));
cl_assert_equal_i
(
GIT_REMOTE_DOWNLOAD_TAGS_ALL
,
origin
->
download_tags
);
git_strarray_free
(
&
tags
);
}
...
...
tests-clar/online/clone.c
View file @
d5e5bbd7
...
...
@@ -3,6 +3,7 @@
#include "git2/clone.h"
#include "git2/cred_helpers.h"
#include "repository.h"
#include "remote.h"
#define LIVE_REPO_URL "http://github.com/libgit2/TestGitRepository"
#define LIVE_EMPTYREPO_URL "http://github.com/libgit2/TestEmptyRepository"
...
...
@@ -42,6 +43,8 @@ void test_online_clone__network_full(void)
cl_assert
(
!
git_repository_is_bare
(
g_repo
));
cl_git_pass
(
git_remote_load
(
&
origin
,
g_repo
,
"origin"
));
cl_assert_equal_i
(
GIT_REMOTE_DOWNLOAD_TAGS_AUTO
,
origin
->
download_tags
);
git_remote_free
(
origin
);
}
...
...
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