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
1087d4fd
Commit
1087d4fd
authored
Jan 26, 2014
by
Ben Straub
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2052 from arthurschreiber/arthur/add-git_remote_dup
Fix git_remote_dup & add missing const
parents
93b96ea7
991b2840
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
22 deletions
+42
-22
include/git2/remote.h
+7
-7
src/remote.c
+33
-15
tests/network/remote/remotes.c
+2
-0
No files found.
include/git2/remote.h
View file @
1087d4fd
...
@@ -117,7 +117,7 @@ GIT_EXTERN(int) git_remote_save(const git_remote *remote);
...
@@ -117,7 +117,7 @@ GIT_EXTERN(int) git_remote_save(const git_remote *remote);
* @param source object to copy
* @param source object to copy
* @return 0 or an error code
* @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
* Get the remote's repository
...
@@ -194,7 +194,7 @@ GIT_EXTERN(int) git_remote_add_fetch(git_remote *remote, const char *refspec);
...
@@ -194,7 +194,7 @@ GIT_EXTERN(int) git_remote_add_fetch(git_remote *remote, const char *refspec);
* @param array pointer to the array in which to store the strings
* @param array pointer to the array in which to store the strings
* @param remote the remote to query
* @param remote the remote to query
*/
*/
GIT_EXTERN
(
int
)
git_remote_get_fetch_refspecs
(
git_strarray
*
array
,
git_remote
*
remote
);
GIT_EXTERN
(
int
)
git_remote_get_fetch_refspecs
(
git_strarray
*
array
,
const
git_remote
*
remote
);
/**
/**
* Set the remote's list of fetch refspecs
* Set the remote's list of fetch refspecs
...
@@ -227,7 +227,7 @@ GIT_EXTERN(int) git_remote_add_push(git_remote *remote, const char *refspec);
...
@@ -227,7 +227,7 @@ GIT_EXTERN(int) git_remote_add_push(git_remote *remote, const char *refspec);
* @param array pointer to the array in which to store the strings
* @param array pointer to the array in which to store the strings
* @param remote the remote to query
* @param remote the remote to query
*/
*/
GIT_EXTERN
(
int
)
git_remote_get_push_refspecs
(
git_strarray
*
array
,
git_remote
*
remote
);
GIT_EXTERN
(
int
)
git_remote_get_push_refspecs
(
git_strarray
*
array
,
const
git_remote
*
remote
);
/**
/**
* Set the remote's list of push refspecs
* Set the remote's list of push refspecs
...
@@ -254,7 +254,7 @@ GIT_EXTERN(void) git_remote_clear_refspecs(git_remote *remote);
...
@@ -254,7 +254,7 @@ GIT_EXTERN(void) git_remote_clear_refspecs(git_remote *remote);
* @param remote the remote
* @param remote the remote
* @return the amount of refspecs configured in this remote
* @return the amount of refspecs configured in this remote
*/
*/
GIT_EXTERN
(
size_t
)
git_remote_refspec_count
(
git_remote
*
remote
);
GIT_EXTERN
(
size_t
)
git_remote_refspec_count
(
const
git_remote
*
remote
);
/**
/**
* Get a refspec from the remote
* Get a refspec from the remote
...
@@ -263,7 +263,7 @@ GIT_EXTERN(size_t) git_remote_refspec_count(git_remote *remote);
...
@@ -263,7 +263,7 @@ GIT_EXTERN(size_t) git_remote_refspec_count(git_remote *remote);
* @param n the refspec to get
* @param n the refspec to get
* @return the nth refspec
* @return the nth refspec
*/
*/
GIT_EXTERN
(
const
git_refspec
*
)
git_remote_get_refspec
(
git_remote
*
remote
,
size_t
n
);
GIT_EXTERN
(
const
git_refspec
*
)
git_remote_get_refspec
(
const
git_remote
*
remote
,
size_t
n
);
/**
/**
* Open a connection to a remote
* Open a connection to a remote
...
@@ -319,7 +319,7 @@ GIT_EXTERN(int) git_remote_download(git_remote *remote);
...
@@ -319,7 +319,7 @@ GIT_EXTERN(int) git_remote_download(git_remote *remote);
* @param remote the remote
* @param remote the remote
* @return 1 if it's connected, 0 otherwise.
* @return 1 if it's connected, 0 otherwise.
*/
*/
GIT_EXTERN
(
int
)
git_remote_connected
(
git_remote
*
remote
);
GIT_EXTERN
(
int
)
git_remote_connected
(
const
git_remote
*
remote
);
/**
/**
* Cancel the operation
* Cancel the operation
...
@@ -510,7 +510,7 @@ typedef enum {
...
@@ -510,7 +510,7 @@ typedef enum {
* @param remote the remote to query
* @param remote the remote to query
* @return the auto-follow setting
* @return the auto-follow setting
*/
*/
GIT_EXTERN
(
git_remote_autotag_option_t
)
git_remote_autotag
(
git_remote
*
remote
);
GIT_EXTERN
(
git_remote_autotag_option_t
)
git_remote_autotag
(
const
git_remote
*
remote
);
/**
/**
* Set the tag auto-follow setting
* Set the tag auto-follow setting
...
...
src/remote.c
View file @
1087d4fd
...
@@ -248,9 +248,10 @@ int git_remote_create_inmemory(git_remote **out, git_repository *repo, const cha
...
@@ -248,9 +248,10 @@ int git_remote_create_inmemory(git_remote **out, git_repository *repo, const cha
return
0
;
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
));
git_remote
*
remote
=
git__calloc
(
1
,
sizeof
(
git_remote
));
GITERR_CHECK_ALLOC
(
remote
);
GITERR_CHECK_ALLOC
(
remote
);
...
@@ -274,16 +275,33 @@ int git_remote_dup(git_remote **dest, const git_remote *source)
...
@@ -274,16 +275,33 @@ int git_remote_dup(git_remote **dest, const git_remote *source)
remote
->
check_cert
=
source
->
check_cert
;
remote
->
check_cert
=
source
->
check_cert
;
remote
->
update_fetchhead
=
source
->
update_fetchhead
;
remote
->
update_fetchhead
=
source
->
update_fetchhead
;
if
(
(
error
=
git_vector_dup
(
&
remote
->
refs
,
&
source
->
refs
,
NULL
)
)
<
0
||
if
(
git_vector_init
(
&
remote
->
refs
,
32
,
NULL
)
<
0
||
(
error
=
git_vector_dup
(
&
remote
->
refspecs
,
&
source
->
refspecs
,
NULL
)
)
<
0
||
git_vector_init
(
&
remote
->
refspecs
,
2
,
NULL
)
<
0
||
(
error
=
git_vector_dup
(
&
remote
->
active_refspecs
,
&
source
->
active_refspecs
,
NULL
))
)
{
git_vector_init
(
&
remote
->
active_refspecs
,
2
,
NULL
)
<
0
)
{
git__free
(
remote
)
;
error
=
-
1
;
return
error
;
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
;
*
dest
=
remote
;
return
0
;
cleanup:
git_strarray_free
(
&
refspecs
);
if
(
error
<
0
)
git__free
(
remote
);
return
error
;
}
}
struct
refspec_cb_data
{
struct
refspec_cb_data
{
...
@@ -1089,7 +1107,7 @@ out:
...
@@ -1089,7 +1107,7 @@ out:
return
error
;
return
error
;
}
}
int
git_remote_connected
(
git_remote
*
remote
)
int
git_remote_connected
(
const
git_remote
*
remote
)
{
{
assert
(
remote
);
assert
(
remote
);
...
@@ -1233,7 +1251,7 @@ const git_transfer_progress* git_remote_stats(git_remote *remote)
...
@@ -1233,7 +1251,7 @@ const git_transfer_progress* git_remote_stats(git_remote *remote)
return
&
remote
->
stats
;
return
&
remote
->
stats
;
}
}
git_remote_autotag_option_t
git_remote_autotag
(
git_remote
*
remote
)
git_remote_autotag_option_t
git_remote_autotag
(
const
git_remote
*
remote
)
{
{
return
remote
->
download_tags
;
return
remote
->
download_tags
;
}
}
...
@@ -1626,7 +1644,7 @@ int git_remote_set_push_refspecs(git_remote *remote, git_strarray *array)
...
@@ -1626,7 +1644,7 @@ int git_remote_set_push_refspecs(git_remote *remote, git_strarray *array)
return
set_refspecs
(
remote
,
array
,
true
);
return
set_refspecs
(
remote
,
array
,
true
);
}
}
static
int
copy_refspecs
(
git_strarray
*
array
,
git_remote
*
remote
,
unsigned
int
push
)
static
int
copy_refspecs
(
git_strarray
*
array
,
const
git_remote
*
remote
,
unsigned
int
push
)
{
{
size_t
i
;
size_t
i
;
git_vector
refspecs
;
git_vector
refspecs
;
...
@@ -1660,22 +1678,22 @@ on_error:
...
@@ -1660,22 +1678,22 @@ on_error:
return
-
1
;
return
-
1
;
}
}
int
git_remote_get_fetch_refspecs
(
git_strarray
*
array
,
git_remote
*
remote
)
int
git_remote_get_fetch_refspecs
(
git_strarray
*
array
,
const
git_remote
*
remote
)
{
{
return
copy_refspecs
(
array
,
remote
,
false
);
return
copy_refspecs
(
array
,
remote
,
false
);
}
}
int
git_remote_get_push_refspecs
(
git_strarray
*
array
,
git_remote
*
remote
)
int
git_remote_get_push_refspecs
(
git_strarray
*
array
,
const
git_remote
*
remote
)
{
{
return
copy_refspecs
(
array
,
remote
,
true
);
return
copy_refspecs
(
array
,
remote
,
true
);
}
}
size_t
git_remote_refspec_count
(
git_remote
*
remote
)
size_t
git_remote_refspec_count
(
const
git_remote
*
remote
)
{
{
return
remote
->
refspecs
.
length
;
return
remote
->
refspecs
.
length
;
}
}
const
git_refspec
*
git_remote_get_refspec
(
git_remote
*
remote
,
size_t
n
)
const
git_refspec
*
git_remote_get_refspec
(
const
git_remote
*
remote
,
size_t
n
)
{
{
return
git_vector_get
(
&
remote
->
refspecs
,
n
);
return
git_vector_get
(
&
remote
->
refspecs
,
n
);
}
}
tests/network/remote/remotes.c
View file @
1087d4fd
...
@@ -148,6 +148,8 @@ void test_network_remote_remotes__dup(void)
...
@@ -148,6 +148,8 @@ void test_network_remote_remotes__dup(void)
cl_git_pass
(
git_remote_get_push_refspecs
(
&
array
,
_remote
));
cl_git_pass
(
git_remote_get_push_refspecs
(
&
array
,
_remote
));
cl_assert_equal_i
(
0
,
(
int
)
array
.
count
);
cl_assert_equal_i
(
0
,
(
int
)
array
.
count
);
git_strarray_free
(
&
array
);
git_strarray_free
(
&
array
);
git_remote_free
(
dup
);
}
}
void
test_network_remote_remotes__add_pushspec
(
void
)
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