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
991b2840
Commit
991b2840
authored
Jan 26, 2014
by
Arthur Schreiber
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure git_remote_dup copies a remote's refspecs correctly.
parent
11f6ad5f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
9 deletions
+29
-9
include/git2/remote.h
+1
-1
src/remote.c
+26
-8
tests/network/remote/remotes.c
+2
-0
No files found.
include/git2/remote.h
View file @
991b2840
...
...
@@ -117,7 +117,7 @@ GIT_EXTERN(int) git_remote_save(const git_remote *remote);
* @param source object to copy
* @return 0 or an error code
*/
GIT_EXTERN
(
int
)
git_remote_dup
(
git_remote
**
dest
,
const
git_remote
*
source
);
GIT_EXTERN
(
int
)
git_remote_dup
(
git_remote
**
dest
,
git_remote
*
source
);
/**
* Get the remote's repository
...
...
src/remote.c
View file @
991b2840
...
...
@@ -248,9 +248,10 @@ int git_remote_create_inmemory(git_remote **out, git_repository *repo, const cha
return
0
;
}
int
git_remote_dup
(
git_remote
**
dest
,
const
git_remote
*
source
)
int
git_remote_dup
(
git_remote
**
dest
,
git_remote
*
source
)
{
int
error
;
int
error
=
0
;
git_strarray
refspecs
=
{
0
};
git_remote
*
remote
=
git__calloc
(
1
,
sizeof
(
git_remote
));
GITERR_CHECK_ALLOC
(
remote
);
...
...
@@ -274,16 +275,33 @@ int git_remote_dup(git_remote **dest, const git_remote *source)
remote
->
check_cert
=
source
->
check_cert
;
remote
->
update_fetchhead
=
source
->
update_fetchhead
;
if
(
(
error
=
git_vector_dup
(
&
remote
->
refs
,
&
source
->
refs
,
NULL
)
)
<
0
||
(
error
=
git_vector_dup
(
&
remote
->
refspecs
,
&
source
->
refspecs
,
NULL
)
)
<
0
||
(
error
=
git_vector_dup
(
&
remote
->
active_refspecs
,
&
source
->
active_refspecs
,
NULL
))
)
{
git__free
(
remote
)
;
return
error
;
if
(
git_vector_init
(
&
remote
->
refs
,
32
,
NULL
)
<
0
||
git_vector_init
(
&
remote
->
refspecs
,
2
,
NULL
)
<
0
||
git_vector_init
(
&
remote
->
active_refspecs
,
2
,
NULL
)
<
0
)
{
error
=
-
1
;
goto
cleanup
;
}
if
((
error
=
git_remote_get_fetch_refspecs
(
&
refspecs
,
source
))
<
0
||
(
error
=
git_remote_set_fetch_refspecs
(
remote
,
&
refspecs
))
<
0
)
goto
cleanup
;
git_strarray_free
(
&
refspecs
);
if
((
error
=
git_remote_get_push_refspecs
(
&
refspecs
,
source
))
<
0
||
(
error
=
git_remote_set_push_refspecs
(
remote
,
&
refspecs
))
<
0
)
goto
cleanup
;
*
dest
=
remote
;
return
0
;
cleanup:
git_strarray_free
(
&
refspecs
);
if
(
error
<
0
)
git__free
(
remote
);
return
error
;
}
struct
refspec_cb_data
{
...
...
tests/network/remote/remotes.c
View file @
991b2840
...
...
@@ -148,6 +148,8 @@ void test_network_remote_remotes__dup(void)
cl_git_pass
(
git_remote_get_push_refspecs
(
&
array
,
_remote
));
cl_assert_equal_i
(
0
,
(
int
)
array
.
count
);
git_strarray_free
(
&
array
);
git_remote_free
(
dup
);
}
void
test_network_remote_remotes__add_pushspec
(
void
)
...
...
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