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
1ffd0806
Commit
1ffd0806
authored
Apr 30, 2013
by
Carlos Martín Nieto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remote: add resfpec list accessors
Bring back a way of acessing the git_refspec* from a remote. Closes #1514
parent
8d39f2a7
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
62 additions
and
10 deletions
+62
-10
include/git2/refspec.h
+1
-0
include/git2/remote.h
+26
-0
src/remote.c
+26
-0
tests-clar/clone/nonetwork.c
+2
-2
tests-clar/network/remote/remotes.c
+7
-8
No files found.
include/git2/refspec.h
View file @
1ffd0806
...
...
@@ -9,6 +9,7 @@
#include "common.h"
#include "types.h"
#include "net.h"
/**
* @file git2/refspec.h
...
...
include/git2/remote.h
View file @
1ffd0806
...
...
@@ -191,6 +191,32 @@ GIT_EXTERN(int) git_remote_get_push_refspecs(git_strarray *array, git_remote *re
GIT_EXTERN
(
void
)
git_remote_clear_refspecs
(
git_remote
*
remote
);
/**
* Get the number of refspecs for a remote
*
* @param remote the remote
* @return the amount of refspecs configured in this remote
*/
GIT_EXTERN
(
size_t
)
git_remote_refspec_count
(
git_remote
*
remote
);
/**
* Get a refspec from the remote
*
* @param remote the remote to query
* @param n the refspec to get
* @return the nth refspec
*/
GIT_EXTERN
(
const
git_refspec
*
)
git_remote_get_refspec
(
git_remote
*
remote
,
size_t
n
);
/**
* Remove a refspec from the remote
*
* @param remote the remote to query
* @param n the refspec to remove
* @return 0 or GIT_ENOTFOUND
*/
GIT_EXTERN
(
int
)
git_remote_remove_refspec
(
git_remote
*
remote
,
size_t
n
);
/**
* Open a connection to a remote
*
* The transport is selected based on the URL. The direction argument
...
...
src/remote.c
View file @
1ffd0806
...
...
@@ -8,6 +8,7 @@
#include "git2/config.h"
#include "git2/types.h"
#include "git2/oid.h"
#include "git2/net.h"
#include "config.h"
#include "repository.h"
...
...
@@ -1574,3 +1575,28 @@ int git_remote_get_push_refspecs(git_strarray *array, git_remote *remote)
{
return
copy_refspecs
(
array
,
remote
,
true
);
}
size_t
git_remote_refspec_count
(
git_remote
*
remote
)
{
return
remote
->
refspecs
.
length
;
}
const
git_refspec
*
git_remote_get_refspec
(
git_remote
*
remote
,
size_t
n
)
{
return
git_vector_get
(
&
remote
->
refspecs
,
n
);
}
int
git_remote_remove_refspec
(
git_remote
*
remote
,
size_t
n
)
{
git_refspec
*
spec
;
assert
(
remote
);
spec
=
git_vector_get
(
&
remote
->
refspecs
,
n
);
if
(
spec
)
{
git_refspec__free
(
spec
);
git__free
(
spec
);
}
return
git_vector_remove
(
&
remote
->
refspecs
,
n
);
}
tests-clar/clone/nonetwork.c
View file @
1ffd0806
...
...
@@ -149,7 +149,7 @@ void test_clone_nonetwork__custom_fetch_spec(void)
cl_git_pass
(
git_clone
(
&
g_repo
,
cl_git_fixture_url
(
"testrepo.git"
),
"./foo"
,
&
g_options
));
cl_git_pass
(
git_remote_load
(
&
g_remote
,
g_repo
,
"origin"
));
actual_fs
=
git_
vector_get
(
&
g_remote
->
refspecs
,
0
);
actual_fs
=
git_
remote_get_refspec
(
g_remote
,
0
);
cl_assert_equal_s
(
"refs/heads/master"
,
git_refspec_src
(
actual_fs
));
cl_assert_equal_s
(
"refs/heads/foo"
,
git_refspec_dst
(
actual_fs
));
...
...
@@ -165,7 +165,7 @@ void test_clone_nonetwork__custom_push_spec(void)
cl_git_pass
(
git_clone
(
&
g_repo
,
cl_git_fixture_url
(
"testrepo.git"
),
"./foo"
,
&
g_options
));
cl_git_pass
(
git_remote_load
(
&
g_remote
,
g_repo
,
"origin"
));
actual_fs
=
git_
vector_get
(
&
g_remote
->
refspecs
,
g_remote
->
refspecs
.
length
-
1
);
actual_fs
=
git_
remote_get_refspec
(
g_remote
,
git_remote_refspec_count
(
g_remote
)
-
1
);
cl_assert_equal_s
(
"refs/heads/master"
,
git_refspec_src
(
actual_fs
));
cl_assert_equal_s
(
"refs/heads/foo"
,
git_refspec_dst
(
actual_fs
));
}
...
...
tests-clar/network/remote/remotes.c
View file @
1ffd0806
...
...
@@ -13,7 +13,7 @@ void test_network_remote_remotes__initialize(void)
cl_git_pass
(
git_remote_load
(
&
_remote
,
_repo
,
"test"
));
_refspec
=
git_
vector_get
(
&
_remote
->
refspecs
,
0
);
_refspec
=
git_
remote_get_refspec
(
_remote
,
0
);
cl_assert
(
_refspec
!=
NULL
);
}
...
...
@@ -113,15 +113,14 @@ void test_network_remote_remotes__add_fetchspec(void)
{
size_t
size
;
size
=
_remote
->
refspecs
.
length
;
cl_assert_equal_i
(
size
,
_remote
->
refspecs
.
length
);
size
=
git_remote_refspec_count
(
_remote
);
cl_git_pass
(
git_remote_add_fetch
(
_remote
,
"refs/*:refs/*"
));
size
++
;
cl_assert_equal_i
(
size
,
_remote
->
refspecs
.
length
);
cl_assert_equal_i
(
size
,
git_remote_refspec_count
(
_remote
)
);
_refspec
=
git_
vector_get
(
&
_remote
->
refspecs
,
size
-
1
);
_refspec
=
git_
remote_get_refspec
(
_remote
,
size
-
1
);
cl_assert_equal_s
(
git_refspec_src
(
_refspec
),
"refs/*"
);
cl_assert_equal_s
(
git_refspec_dst
(
_refspec
),
"refs/*"
);
cl_assert_equal_s
(
git_refspec_string
(
_refspec
),
"refs/*:refs/*"
);
...
...
@@ -132,13 +131,13 @@ void test_network_remote_remotes__add_pushspec(void)
{
size_t
size
;
size
=
_remote
->
refspecs
.
length
;
size
=
git_remote_refspec_count
(
_remote
)
;
cl_git_pass
(
git_remote_add_push
(
_remote
,
"refs/*:refs/*"
));
size
++
;
cl_assert_equal_i
(
size
,
_remote
->
refspecs
.
length
);
cl_assert_equal_i
(
size
,
git_remote_refspec_count
(
_remote
)
);
_refspec
=
git_
vector_get
(
&
_remote
->
refspecs
,
size
-
1
);
_refspec
=
git_
remote_get_refspec
(
_remote
,
size
-
1
);
cl_assert_equal_s
(
git_refspec_src
(
_refspec
),
"refs/*"
);
cl_assert_equal_s
(
git_refspec_dst
(
_refspec
),
"refs/*"
);
cl_assert_equal_s
(
git_refspec_string
(
_refspec
),
"refs/*:refs/*"
);
...
...
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