mirror of
https://github.com/git/git
synced 2024-08-27 11:39:22 +00:00
git-gui: Add support for removing remotes
We introduce new submenu Remote -> Remove Remote, allowing to remove remotes. In the future, we might consider a confirmation popup to avoid misclicks, but removing a remote is not very lossy operation. Signed-off-by: Petr Baudis <petr.baudis@novartis.com> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
This commit is contained in:
parent
ba6485e05d
commit
0d4044123c
|
@ -137,6 +137,7 @@ proc add_fetch_entry {r} {
|
||||||
set remote_m .mbar.remote
|
set remote_m .mbar.remote
|
||||||
set fetch_m $remote_m.fetch
|
set fetch_m $remote_m.fetch
|
||||||
set prune_m $remote_m.prune
|
set prune_m $remote_m.prune
|
||||||
|
set remove_m $remote_m.remove
|
||||||
set enable 0
|
set enable 0
|
||||||
if {![catch {set a $repo_config(remote.$r.url)}]} {
|
if {![catch {set a $repo_config(remote.$r.url)}]} {
|
||||||
if {![catch {set a $repo_config(remote.$r.fetch)}]} {
|
if {![catch {set a $repo_config(remote.$r.fetch)}]} {
|
||||||
|
@ -157,6 +158,11 @@ proc add_fetch_entry {r} {
|
||||||
|
|
||||||
if {$enable} {
|
if {$enable} {
|
||||||
if {![winfo exists $fetch_m]} {
|
if {![winfo exists $fetch_m]} {
|
||||||
|
menu $remove_m
|
||||||
|
$remote_m insert 0 cascade \
|
||||||
|
-label [mc "Remove Remote"] \
|
||||||
|
-menu $remove_m
|
||||||
|
|
||||||
menu $prune_m
|
menu $prune_m
|
||||||
$remote_m insert 0 cascade \
|
$remote_m insert 0 cascade \
|
||||||
-label [mc "Prune from"] \
|
-label [mc "Prune from"] \
|
||||||
|
@ -174,6 +180,9 @@ proc add_fetch_entry {r} {
|
||||||
$prune_m add command \
|
$prune_m add command \
|
||||||
-label $r \
|
-label $r \
|
||||||
-command [list prune_from $r]
|
-command [list prune_from $r]
|
||||||
|
$remove_m add command \
|
||||||
|
-label $r \
|
||||||
|
-command [list remove_remote $r]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -236,3 +245,31 @@ proc add_single_remote {name location} {
|
||||||
add_fetch_entry $name
|
add_fetch_entry $name
|
||||||
add_push_entry $name
|
add_push_entry $name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
proc delete_from_menu {menu name} {
|
||||||
|
if {[winfo exists $menu]} {
|
||||||
|
$menu delete $name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
proc remove_remote {name} {
|
||||||
|
global all_remotes repo_config
|
||||||
|
|
||||||
|
git remote rm $name
|
||||||
|
|
||||||
|
catch {
|
||||||
|
# Missing values are ok
|
||||||
|
unset repo_config(remote.$name.url)
|
||||||
|
unset repo_config(remote.$name.fetch)
|
||||||
|
unset repo_config(remote.$name.push)
|
||||||
|
}
|
||||||
|
|
||||||
|
set i [lsearch -exact all_remotes $name]
|
||||||
|
lreplace all_remotes $i $i
|
||||||
|
|
||||||
|
set remote_m .mbar.remote
|
||||||
|
delete_from_menu $remote_m.fetch $name
|
||||||
|
delete_from_menu $remote_m.prune $name
|
||||||
|
delete_from_menu $remote_m.remove $name
|
||||||
|
delete_from_menu $remote_m.push $name
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue