@matheusbsbs / matheus-bagliano / commits / 5b6ffff644
Fork 0

git-gui: GUI support for running 'git remote prune <name>'

In some workflows it is common for a large number of temporary branches to be created in a remote repository, get fetched to clients that typically only use git-gui, and then later have those branches deleted from the remote repository once they have been fully merged into all destination branches. Users of git-gui would obviously like to have their local tracking branches cleaned up for them, otherwise their local tracking branch namespace would grow out of control. The best known way to remove these tracking branches is to run "git remote prune <remotename>". Even though it is more of a Porcelain command than plumbing I'm invoking it through the UI, because frankly I don't see a reason to reimplement its ls-remote output filtering and config file parsing. A new configuration option (gui.pruneduringfetch) can be used to automatically enable running "git remote prune <remotename>" after the fetch of that remote also completes successfully. This is off by default as it require an additional network connection and is not very fast on Cygwin if a large number of tracking branches have been removed (due to the 2 fork+exec calls per branch). Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Shawn O. Pearce committed May 28, 2007 at 11:04 UTC 5b6ffff644237682c5a20e8ec0a16164bdeb3bfb
4 files changed +26 -3
git-gui.sh
+1
@@ -1243,6 +1243,7 @@ set default_config(merge.verbosity) 2
1243 set default_config(user.name) {}
1244 set default_config(user.email) {}
1245
1246 +set default_config(gui.pruneduringfetch) false
1247 set default_config(gui.trustmtime) false
1248 set default_config(gui.diffcontext) 5
1249 set default_config(gui.newbranchtemplate) {}
lib/option.tcl
+1
@@ -173,6 +173,7 @@ proc do_options {} {
173 {i-1..5 merge.verbosity {Merge Verbosity}}
174
175 {b gui.trustmtime {Trust File Modification Timestamps}}
176 + {b gui.pruneduringfetch {Prune Tracking Branches During Fetch}}
177 {i-1..99 gui.diffcontext {Number of Diff Context Lines}}
178 {t gui.newbranchtemplate {New Branch Name Template}}
179 } {
lib/remote.tcl
+11
@@ -95,6 +95,7 @@ proc populate_fetch_menu {} {
95 global all_remotes repo_config
96
97 set m .mbar.fetch
98 + set prune_list [list]
99 foreach r $all_remotes {
100 set enable 0
101 if {![catch {set a $repo_config(remote.$r.url)}]} {
@@ -115,11 +116,21 @@ proc populate_fetch_menu {} {
116 }
117
118 if {$enable} {
119 + lappend prune_list $r
120 $m add command \
121 -label "Fetch from $r..." \
122 -command [list fetch_from $r]
123 }
124 }
125 +
126 + if {$prune_list ne {}} {
127 + $m add separator
128 + }
129 + foreach r $prune_list {
130 + $m add command \
131 + -label "Prune from $r..." \
132 + -command [list prune_from $r]
133 + }
134 }
135
136 proc populate_push_menu {} {
lib/transport.tcl
+13 -3
@@ -5,9 +5,19 @@ proc fetch_from {remote} {
5 set w [console::new \
6 "fetch $remote" \
7 "Fetching new changes from $remote"]
8 - set cmd [list git fetch]
9 - lappend cmd $remote
10 - console::exec $w $cmd
8 + set cmds [list]
9 + lappend cmds [list exec git fetch $remote]
10 + if {[is_config_true gui.pruneduringfetch]} {
11 + lappend cmds [list exec git remote prune $remote]
12 + }
13 + console::chain $w $cmds
14 +}
15 +
16 +proc prune_from {remote} {
17 + set w [console::new \
18 + "remote prune $remote" \
19 + "Pruning tracking branches deleted from $remote"]
20 + console::exec $w [list git remote prune $remote]
21 }
22
23 proc push_to {remote} {