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
a6ed1fcb
Commit
a6ed1fcb
authored
Oct 10, 2014
by
Edward Thomson
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2593 from libgit2/cmn/remote-delete-name
remote: accept a repository and remote name for deletion
parents
bab92a8d
262eec23
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
39 deletions
+14
-39
CHANGELOG.md
+3
-0
include/git2/remote.h
+3
-2
src/remote.c
+5
-19
tests/network/remote/delete.c
+3
-18
No files found.
CHANGELOG.md
View file @
a6ed1fcb
...
...
@@ -40,6 +40,9 @@ v0.21 + 1
path of the programs to execute for receive-pack and upload-pack on
the server, git_transport_ssh_with_paths.
*
git_remote_delete() now accepts the repository and the remote's name
instead of a loaded remote.
*
The git_clone_options struct no longer provides the ignore_cert_errors or
remote_name members for remote customization.
...
...
include/git2/remote.h
View file @
a6ed1fcb
...
...
@@ -602,10 +602,11 @@ GIT_EXTERN(int) git_remote_is_valid_name(const char *remote_name);
* All remote-tracking branches and configuration settings
* for the remote will be removed.
*
* @param remote A valid remote
* @param repo the repository in which to act
* @param name the name of the remove to delete
* @return 0 on success, or an error code.
*/
GIT_EXTERN
(
int
)
git_remote_delete
(
git_re
mote
*
remot
e
);
GIT_EXTERN
(
int
)
git_remote_delete
(
git_re
pository
*
repo
,
const
char
*
nam
e
);
/**
* Retrieve the name of the remote's default branch
...
...
src/remote.c
View file @
a6ed1fcb
...
...
@@ -2028,29 +2028,15 @@ static int remove_remote_tracking(git_repository *repo, const char *remote_name)
return
error
;
}
int
git_remote_delete
(
git_re
mote
*
remot
e
)
int
git_remote_delete
(
git_re
pository
*
repo
,
const
char
*
nam
e
)
{
int
error
;
git_repository
*
repo
;
assert
(
remote
);
if
(
!
remote
->
name
)
{
giterr_set
(
GITERR_INVALID
,
"Can't delete an anonymous remote."
);
return
-
1
;
}
repo
=
git_remote_owner
(
remote
);
if
((
error
=
remove_branch_config_related_entries
(
repo
,
git_remote_name
(
remote
)))
<
0
)
return
error
;
if
((
error
=
remove_remote_tracking
(
repo
,
git_remote_name
(
remote
)))
<
0
)
return
error
;
assert
(
repo
&&
name
);
if
((
error
=
rename_remote_config_section
(
repo
,
git_remote_name
(
remote
),
NULL
))
<
0
)
if
((
error
=
remove_branch_config_related_entries
(
repo
,
name
))
<
0
||
(
error
=
remove_remote_tracking
(
repo
,
name
))
<
0
||
(
error
=
rename_remote_config_section
(
repo
,
name
,
NULL
))
<
0
)
return
error
;
return
0
;
...
...
tests/network/remote/delete.c
View file @
a6ed1fcb
...
...
@@ -3,38 +3,23 @@
#include "repository.h"
static
git_remote
*
_remote
;
static
git_repository
*
_repo
;
void
test_network_remote_delete__initialize
(
void
)
{
_repo
=
cl_git_sandbox_init
(
"testrepo.git"
);
cl_git_pass
(
git_remote_load
(
&
_remote
,
_repo
,
"test"
));
}
void
test_network_remote_delete__cleanup
(
void
)
{
git_remote_free
(
_remote
);
cl_git_sandbox_cleanup
();
}
void
test_network_remote_delete__cannot_delete_an_anonymous_remote
(
void
)
{
git_remote
*
remote
;
cl_git_pass
(
git_remote_create_anonymous
(
&
remote
,
_repo
,
"git://github.com/libgit2/libgit2"
,
NULL
));
cl_git_fail
(
git_remote_delete
(
remote
));
git_remote_free
(
remote
);
}
void
test_network_remote_delete__remove_remote_tracking_branches
(
void
)
{
git_reference
*
ref
;
cl_git_pass
(
git_remote_delete
(
_re
mote
));
cl_git_pass
(
git_remote_delete
(
_re
po
,
"test"
));
cl_git_fail_with
(
GIT_ENOTFOUND
,
git_reference_lookup
(
&
ref
,
_repo
,
"refs/remotes/test/master"
));
}
...
...
@@ -42,7 +27,7 @@ void test_network_remote_delete__remove_remote_configuration_settings(void)
{
cl_assert
(
count_config_entries_match
(
_repo
,
"remote
\\
.test
\\
.+"
)
>
0
);
cl_git_pass
(
git_remote_delete
(
_re
mote
));
cl_git_pass
(
git_remote_delete
(
_re
po
,
"test"
));
cl_assert_equal_i
(
0
,
count_config_entries_match
(
_repo
,
"remote
\\
.test
\\
.+"
));
}
...
...
@@ -52,7 +37,7 @@ void test_network_remote_delete__remove_branch_upstream_configuration_settings(v
assert_config_entry_existence
(
_repo
,
"branch.mergeless.remote"
,
true
);
assert_config_entry_existence
(
_repo
,
"branch.master.remote"
,
true
);
cl_git_pass
(
git_remote_delete
(
_re
mote
));
cl_git_pass
(
git_remote_delete
(
_re
po
,
"test"
));
assert_config_entry_existence
(
_repo
,
"branch.mergeless.remote"
,
false
);
assert_config_entry_existence
(
_repo
,
"branch.mergeless.merge"
,
false
);
...
...
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