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
b914e17d
Commit
b914e17d
authored
Dec 12, 2012
by
Ben Straub
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
API to set a dangling remote's repository
parent
a71c27cc
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
2 deletions
+29
-2
include/git2/remote.h
+10
-0
src/remote.c
+13
-0
tests-clar/network/remotes.c
+6
-2
No files found.
include/git2/remote.h
View file @
b914e17d
...
...
@@ -52,6 +52,16 @@ typedef int (*git_remote_rename_problem_cb)(const char *problematic_refspec, voi
GIT_EXTERN
(
int
)
git_remote_new
(
git_remote
**
out
,
git_repository
*
repo
,
const
char
*
name
,
const
char
*
url
,
const
char
*
fetch
);
/**
* Sets the owning repository for the remote. This is only allowed on
* dangling remotes.
*
* @param remote the remote to configure
* @param repo the repository that will own the remote
* @return 0 or an error code
*/
GIT_EXTERN
(
int
)
git_remote_set_repository
(
git_remote
*
remote
,
git_repository
*
repo
);
/**
* Get the information for a particular remote
*
* The name will be checked for validity.
...
...
src/remote.c
View file @
b914e17d
...
...
@@ -132,6 +132,19 @@ on_error:
return
-
1
;
}
int
git_remote_set_repository
(
git_remote
*
remote
,
git_repository
*
repo
)
{
assert
(
repo
);
if
(
remote
->
repo
)
{
giterr_set
(
GITERR_INVALID
,
"Remotes can't change repositiories."
);
return
GIT_ERROR
;
}
remote
->
repo
=
repo
;
return
0
;
}
int
git_remote_load
(
git_remote
**
out
,
git_repository
*
repo
,
const
char
*
name
)
{
git_remote
*
remote
;
...
...
tests-clar/network/remotes.c
View file @
b914e17d
...
...
@@ -330,9 +330,13 @@ void test_network_remotes__check_structure_version(void)
void
test_network_remotes__dangling
(
void
)
{
cl_git_pass
(
git_remote_new
(
&
_remote
,
NULL
,
"upstream"
,
"git://github.com/libgit2/libgit2"
,
NULL
));
cl_git_fail
(
git_remote_save
(
_remote
));
cl_git_fail
(
git_remote_update_tips
(
_remote
));
cl_git_pass
(
git_remote_rename
(
_remote
,
"newname"
,
NULL
,
NULL
));
cl_assert_equal_s
(
git_remote_name
(
_remote
),
"newname"
);
cl_git_fail
(
git_remote_save
(
_remote
));
cl_git_fail
(
git_remote_update_tips
(
_remote
));
cl_git_pass
(
git_remote_set_repository
(
_remote
,
_repo
));
cl_git_pass
(
git_remote_save
(
_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