summaryrefslogtreecommitdiff
path: root/git-gui
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2006-11-16 04:52:20 (GMT)
committerShawn O. Pearce <spearce@spearce.org>2006-11-18 04:56:16 (GMT)
commitc1237ae288aae7e45a18f3d5097b49451293acfe (patch)
treef032dfd2457695fae28368348e193084a7f964f1 /git-gui
parent306500fc09e7d8be042e8b9abbd9011b80b3300d (diff)
downloadgit-c1237ae288aae7e45a18f3d5097b49451293acfe.zip
git-c1237ae288aae7e45a18f3d5097b49451293acfe.tar.gz
git-c1237ae288aae7e45a18f3d5097b49451293acfe.tar.bz2
git-gui: Only populate a fetch or push if we have an action.
Don't offer to fetch from a remote unless we have at least one Pull: line in its .git/remotes/<name> file or at least one configuration value for remote.<name>.fetch. Ditto for push. Users shouldn't be fetching or pushing branch groups unless they have them configured; anything else is just crazy. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'git-gui')
-rwxr-xr-xgit-gui68
1 files changed, 60 insertions, 8 deletions
diff --git a/git-gui b/git-gui
index 013f21b..ea60e32 100755
--- a/git-gui
+++ b/git-gui
@@ -1343,13 +1343,65 @@ proc load_all_remotes {} {
set all_remotes [lsort -unique $all_remotes]
}
-proc populate_remote_menu {m pfx op} {
- global all_remotes
+proc populate_fetch_menu {m} {
+ global gitdir all_remotes repo_config
- foreach remote $all_remotes {
- $m add command -label "$pfx $remote..." \
- -command [list $op $remote] \
- -font font_ui
+ foreach r $all_remotes {
+ set enable 0
+ if {![catch {set a $repo_config(remote.$r.url)}]} {
+ if {![catch {set a $repo_config(remote.$r.fetch)}]} {
+ set enable 1
+ }
+ } else {
+ catch {
+ set fd [open [file join $gitdir remotes $r] r]
+ while {[gets $fd n] >= 0} {
+ if {[regexp {^Pull:[ \t]*([^:]+):} $n]} {
+ set enable 1
+ break
+ }
+ }
+ close $fd
+ }
+ }
+
+ if {$enable} {
+ $m add command \
+ -label "Fetch from $r..." \
+ -command [list fetch_from $r] \
+ -font font_ui
+ }
+ }
+}
+
+proc populate_push_menu {m} {
+ global gitdir all_remotes repo_config
+
+ foreach r $all_remotes {
+ set enable 0
+ if {![catch {set a $repo_config(remote.$r.url)}]} {
+ if {![catch {set a $repo_config(remote.$r.push)}]} {
+ set enable 1
+ }
+ } else {
+ catch {
+ set fd [open [file join $gitdir remotes $r] r]
+ while {[gets $fd n] >= 0} {
+ if {[regexp {^Push:[ \t]*([^:]+):} $n]} {
+ set enable 1
+ break
+ }
+ }
+ close $fd
+ }
+ }
+
+ if {$enable} {
+ $m add command \
+ -label "Push to $r..." \
+ -command [list push_to $r] \
+ -font font_ui
+ }
}
}
@@ -2713,8 +2765,8 @@ wm title . "$appname ([file normalize [file dirname $gitdir]])"
focus -force $ui_comm
if {!$single_commit} {
load_all_remotes
- populate_remote_menu .mbar.fetch From fetch_from
- populate_remote_menu .mbar.push To push_to
+ populate_fetch_menu .mbar.fetch
populate_pull_menu .mbar.pull
+ populate_push_menu .mbar.push
}
after 1 do_rescan