git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 4/5] git-gui: Add support for removing remotes

From
pasky@suse.cz <pasky@suse.cz>
Date
Sep 24, 2008, 20:44 UTC
Message-ID
<20080924204616.189163849@suse.cz>
In-Reply-To
<20080924204358.144077183@suse.cz>

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.

This patch has been sponsored by Novartis.
Signed-off-by: Petr Baudis <pasky@suse.cz>
---
 git-gui/lib/remote.tcl |   37 +++++++++++++++++++++++++++++++++++++
 1 files changed, 37 insertions(+), 0 deletions(-)
diff --git a/git-gui/lib/remote.tcl b/git-gui/lib/remote.tcl
index 643f0bc..1852247 100644
--- a/git-gui/lib/remote.tcl
+++ b/git-gui/lib/remote.tcl
@@ -137,6 +137,7 @@ proc add_fetch_entry {r} {
 	set remote_m .mbar.remote
 	set fetch_m $remote_m.fetch
 	set prune_m $remote_m.prune
+	set remove_m $remote_m.remove
 	set enable 0
 	if {![catch {set a $repo_config(remote.$r.url)}]} {
 		if {![catch {set a $repo_config(remote.$r.fetch)}]} {
@@ -157,6 +158,11 @@ proc add_fetch_entry {r} {
 
 	if {$enable} {
 		if {![winfo exists $fetch_m]} {
+			menu $remove_m
+			$remote_m insert 0 cascade \
+				-label [mc "Remove Remote"] \
+				-menu $remove_m
+
 			menu $prune_m
 			$remote_m insert 0 cascade \
 				-label [mc "Prune from"] \
@@ -174,6 +180,9 @@ proc add_fetch_entry {r} {
 		$prune_m add command \
 			-label $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_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
+}
-- 
tg: (f30d624..) t/git-gui/remote-rm (depends on: t/git-gui/remote-add)
Previous: Petr BaudisNext: Petr Baudis
Message 6 of 20 in “git-gui: Remotes manipulation enhancements”
  1. 0/5 git-gui: Remotes manipulation enhancementspasky@suse.cz, Sep 24, 2008
  2. 1/5 git-gui: Clarify the Remote -> Delete... actionpasky@suse.cz, Sep 24, 2008
  3. 2/5 git-gui: Squash populate_{push,fetch}_menu to populate_remotes_menupasky@suse.cz, Sep 24, 2008
  4. 3/5 git-gui: Add support for adding remotespasky@suse.cz, Sep 24, 2008
  5. git-gui: Fix fetching from remotes when adding themPetr Baudis, Sep 24, 2008
  6. 4/5 git-gui: Add support for removing remotespasky@suse.cz, Sep 24, 2008
  7. Fix removing non-pushable remotesPetr Baudis, Sep 24, 2008
  8. 5/5 git-gui: mkdir -p when initializing new remote repositorypasky@suse.cz, Sep 24, 2008
  9. On Sponsor NoticesPetr Baudis, Sep 24, 2008
  10. Heikki OrsilaSep 24, 2008
  11. Martin LanghoffSep 24, 2008
  12. Petr BaudisSep 24, 2008
  13. Martin LanghoffSep 24, 2008
  14. Nicolas PitreSep 25, 2008
  15. Petr BaudisSep 25, 2008
  16. Nicolas PitreSep 25, 2008
  17. Petr BaudisSep 25, 2008
  18. Shawn O. PearceSep 25, 2008
  19. Andreas EricssonSep 25, 2008
  20. A.J. RossiniSep 26, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.