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
0fe522d1
Commit
0fe522d1
authored
Nov 07, 2013
by
Victor Garcia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allowing create remote with custom fetch spec
parent
e87d9d3d
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
25 additions
and
21 deletions
+25
-21
include/git2/remote.h
+2
-1
src/clone.c
+1
-1
src/remote.c
+7
-4
src/repository.c
+1
-1
tests-clar/network/fetchlocal.c
+2
-2
tests-clar/network/remote/remotes.c
+6
-6
tests-clar/online/clone.c
+1
-1
tests-clar/online/fetch.c
+3
-3
tests-clar/online/push.c
+1
-1
tests-clar/refs/branches/remote.c
+1
-1
No files found.
include/git2/remote.h
View file @
0fe522d1
...
...
@@ -40,7 +40,8 @@ GIT_EXTERN(int) git_remote_create(
git_remote
**
out
,
git_repository
*
repo
,
const
char
*
name
,
const
char
*
url
);
const
char
*
url
,
const
char
*
fetch
);
/**
* Create a remote in memory
...
...
src/clone.c
View file @
0fe522d1
...
...
@@ -309,7 +309,7 @@ static int create_and_configure_origin(
const
char
*
name
;
name
=
options
->
remote_name
?
options
->
remote_name
:
"origin"
;
if
((
error
=
git_remote_create
(
&
origin
,
repo
,
name
,
url
))
<
0
)
if
((
error
=
git_remote_create
(
&
origin
,
repo
,
name
,
url
,
NULL
))
<
0
)
goto
on_error
;
if
(
options
->
ignore_cert_errors
)
...
...
src/remote.c
View file @
0fe522d1
...
...
@@ -174,7 +174,7 @@ static int ensure_remote_doesnot_exist(git_repository *repo, const char *name)
}
int
git_remote_create
(
git_remote
**
out
,
git_repository
*
repo
,
const
char
*
name
,
const
char
*
url
)
int
git_remote_create
(
git_remote
**
out
,
git_repository
*
repo
,
const
char
*
name
,
const
char
*
url
,
const
char
*
fetch
)
{
git_buf
buf
=
GIT_BUF_INIT
;
git_remote
*
remote
=
NULL
;
...
...
@@ -186,10 +186,13 @@ int git_remote_create(git_remote **out, git_repository *repo, const char *name,
if
((
error
=
ensure_remote_doesnot_exist
(
repo
,
name
))
<
0
)
return
error
;
if
(
git_buf_printf
(
&
buf
,
"+refs/heads/*:refs/remotes/%s/*"
,
name
)
<
0
)
return
-
1
;
if
(
fetch
==
NULL
)
{
if
(
git_buf_printf
(
&
buf
,
"+refs/heads/*:refs/remotes/%s/*"
,
name
)
<
0
)
return
-
1
;
fetch
=
git_buf_cstr
(
&
buf
);
}
if
(
create_internal
(
&
remote
,
repo
,
name
,
url
,
git_buf_cstr
(
&
buf
)
)
<
0
)
if
(
create_internal
(
&
remote
,
repo
,
name
,
url
,
fetch
)
<
0
)
goto
on_error
;
git_buf_free
(
&
buf
);
...
...
src/repository.c
View file @
0fe522d1
...
...
@@ -1473,7 +1473,7 @@ static int repo_init_create_origin(git_repository *repo, const char *url)
int
error
;
git_remote
*
remote
;
if
(
!
(
error
=
git_remote_create
(
&
remote
,
repo
,
GIT_REMOTE_ORIGIN
,
url
)))
{
if
(
!
(
error
=
git_remote_create
(
&
remote
,
repo
,
GIT_REMOTE_ORIGIN
,
url
,
NULL
)))
{
git_remote_free
(
remote
);
}
...
...
tests-clar/network/fetchlocal.c
View file @
0fe522d1
...
...
@@ -33,7 +33,7 @@ void test_network_fetchlocal__complete(void)
cl_set_cleanup
(
&
cleanup_local_repo
,
"foo"
);
cl_git_pass
(
git_repository_init
(
&
repo
,
"foo"
,
true
));
cl_git_pass
(
git_remote_create
(
&
origin
,
repo
,
GIT_REMOTE_ORIGIN
,
url
));
cl_git_pass
(
git_remote_create
(
&
origin
,
repo
,
GIT_REMOTE_ORIGIN
,
url
,
NULL
));
git_remote_set_callbacks
(
origin
,
&
callbacks
);
cl_git_pass
(
git_remote_connect
(
origin
,
GIT_DIRECTION_FETCH
));
cl_git_pass
(
git_remote_download
(
origin
));
...
...
@@ -71,7 +71,7 @@ void test_network_fetchlocal__partial(void)
cl_assert_equal_i
(
1
,
(
int
)
refnames
.
count
);
url
=
cl_git_fixture_url
(
"testrepo.git"
);
cl_git_pass
(
git_remote_create
(
&
origin
,
repo
,
GIT_REMOTE_ORIGIN
,
url
));
cl_git_pass
(
git_remote_create
(
&
origin
,
repo
,
GIT_REMOTE_ORIGIN
,
url
,
NULL
));
git_remote_set_callbacks
(
origin
,
&
callbacks
);
cl_git_pass
(
git_remote_connect
(
origin
,
GIT_DIRECTION_FETCH
));
cl_git_pass
(
git_remote_download
(
origin
));
...
...
tests-clar/network/remote/remotes.c
View file @
0fe522d1
...
...
@@ -159,7 +159,7 @@ void test_network_remote_remotes__save(void)
_remote
=
NULL
;
/* Set up the remote and save it to config */
cl_git_pass
(
git_remote_create
(
&
_remote
,
_repo
,
"upstream"
,
"git://github.com/libgit2/libgit2"
));
cl_git_pass
(
git_remote_create
(
&
_remote
,
_repo
,
"upstream"
,
"git://github.com/libgit2/libgit2"
,
NULL
));
git_remote_clear_refspecs
(
_remote
);
cl_git_pass
(
git_remote_add_fetch
(
_remote
,
fetch_refspec1
));
...
...
@@ -298,7 +298,7 @@ void test_network_remote_remotes__add(void)
git_remote_free
(
_remote
);
_remote
=
NULL
;
cl_git_pass
(
git_remote_create
(
&
_remote
,
_repo
,
"addtest"
,
"http://github.com/libgit2/libgit2"
));
cl_git_pass
(
git_remote_create
(
&
_remote
,
_repo
,
"addtest"
,
"http://github.com/libgit2/libgit2"
,
NULL
));
cl_assert_equal_i
(
GIT_REMOTE_DOWNLOAD_TAGS_AUTO
,
git_remote_autotag
(
_remote
));
git_remote_free
(
_remote
);
...
...
@@ -320,7 +320,7 @@ void test_network_remote_remotes__cannot_add_a_nameless_remote(void)
cl_assert_equal_i
(
GIT_EINVALIDSPEC
,
git_remote_create
(
&
remote
,
_repo
,
NULL
,
"git://github.com/libgit2/libgit2"
));
git_remote_create
(
&
remote
,
_repo
,
NULL
,
"git://github.com/libgit2/libgit2"
,
NULL
));
}
void
test_network_remote_remotes__cannot_save_an_inmemory_remote
(
void
)
...
...
@@ -341,12 +341,12 @@ void test_network_remote_remotes__cannot_add_a_remote_with_an_invalid_name(void)
cl_assert_equal_i
(
GIT_EINVALIDSPEC
,
git_remote_create
(
&
remote
,
_repo
,
"Inv@{id"
,
"git://github.com/libgit2/libgit2"
));
git_remote_create
(
&
remote
,
_repo
,
"Inv@{id"
,
"git://github.com/libgit2/libgit2"
,
NULL
));
cl_assert_equal_p
(
remote
,
NULL
);
cl_assert_equal_i
(
GIT_EINVALIDSPEC
,
git_remote_create
(
&
remote
,
_repo
,
""
,
"git://github.com/libgit2/libgit2"
));
git_remote_create
(
&
remote
,
_repo
,
""
,
"git://github.com/libgit2/libgit2"
,
NULL
));
cl_assert_equal_p
(
remote
,
NULL
);
}
...
...
@@ -439,7 +439,7 @@ void assert_cannot_create_remote(const char *name, int expected_error)
git_remote
*
remote
=
NULL
;
cl_git_fail_with
(
git_remote_create
(
&
remote
,
_repo
,
name
,
"git://github.com/libgit2/libgit2"
),
git_remote_create
(
&
remote
,
_repo
,
name
,
"git://github.com/libgit2/libgit2"
,
NULL
),
expected_error
);
cl_assert_equal_p
(
remote
,
NULL
);
...
...
tests-clar/online/clone.c
View file @
0fe522d1
...
...
@@ -141,7 +141,7 @@ void test_online_clone__clone_into(void)
checkout_opts
.
progress_payload
=
&
checkout_progress_cb_was_called
;
cl_git_pass
(
git_repository_init
(
&
g_repo
,
"./foo"
,
false
));
cl_git_pass
(
git_remote_create
(
&
remote
,
g_repo
,
"origin"
,
LIVE_REPO_URL
));
cl_git_pass
(
git_remote_create
(
&
remote
,
g_repo
,
"origin"
,
LIVE_REPO_URL
,
NULL
));
callbacks
.
transfer_progress
=
&
fetch_progress
;
callbacks
.
payload
=
&
fetch_progress_cb_was_called
;
...
...
tests-clar/online/fetch.c
View file @
0fe522d1
...
...
@@ -43,7 +43,7 @@ static void do_fetch(const char *url, git_remote_autotag_option_t flag, int n)
callbacks
.
payload
=
&
bytes_received
;
counter
=
0
;
cl_git_pass
(
git_remote_create
(
&
remote
,
_repo
,
"test"
,
url
));
cl_git_pass
(
git_remote_create
(
&
remote
,
_repo
,
"test"
,
url
,
NULL
));
git_remote_set_callbacks
(
remote
,
&
callbacks
);
git_remote_set_autotag
(
remote
,
flag
);
cl_git_pass
(
git_remote_connect
(
remote
,
GIT_DIRECTION_FETCH
));
...
...
@@ -140,7 +140,7 @@ void test_online_fetch__can_cancel(void)
git_remote_callbacks
callbacks
=
GIT_REMOTE_CALLBACKS_INIT
;
cl_git_pass
(
git_remote_create
(
&
remote
,
_repo
,
"test"
,
"http://github.com/libgit2/TestGitRepository.git"
));
"http://github.com/libgit2/TestGitRepository.git"
,
NULL
));
callbacks
.
transfer_progress
=
cancel_at_half
;
callbacks
.
payload
=
&
bytes_received
;
...
...
@@ -168,7 +168,7 @@ void test_online_fetch__ls_disconnected(void)
int
nr_before
=
0
,
nr_after
=
0
;
cl_git_pass
(
git_remote_create
(
&
remote
,
_repo
,
"test"
,
"http://github.com/libgit2/TestGitRepository.git"
));
"http://github.com/libgit2/TestGitRepository.git"
,
NULL
));
cl_git_pass
(
git_remote_connect
(
remote
,
GIT_DIRECTION_FETCH
));
cl_git_pass
(
git_remote_ls
(
remote
,
ls_cb
,
&
nr_before
));
git_remote_disconnect
(
remote
);
...
...
tests-clar/online/push.c
View file @
0fe522d1
...
...
@@ -301,7 +301,7 @@ void test_online_push__initialize(void)
_remote
=
NULL
;
if
(
_remote_url
)
{
cl_git_pass
(
git_remote_create
(
&
_remote
,
_repo
,
"test"
,
_remote_url
));
cl_git_pass
(
git_remote_create
(
&
_remote
,
_repo
,
"test"
,
_remote_url
,
NULL
));
record_callbacks_data_clear
(
&
_record_cbs_data
);
git_remote_set_callbacks
(
_remote
,
&
_record_cbs
);
...
...
tests-clar/refs/branches/remote.c
View file @
0fe522d1
...
...
@@ -70,7 +70,7 @@ void test_refs_branches_remote__ambiguous_remote_returns_error(void)
git_remote
*
remote
;
/* Create the remote */
cl_git_pass
(
git_remote_create
(
&
remote
,
g_repo
,
"addtest"
,
"http://github.com/libgit2/libgit2"
));
cl_git_pass
(
git_remote_create
(
&
remote
,
g_repo
,
"addtest"
,
"http://github.com/libgit2/libgit2"
,
NULL
));
/* Update the remote fetch spec */
git_remote_clear_refspecs
(
remote
);
...
...
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