Merge git://repo.or.cz/git-gui
[gitweb.git] / git-gui / lib / remote.tcl
index e235ca88765090e08707f63096369d56da76d196..0e86ddac0981fbb575a7dd5294ddaed29f7c3917 100644 (file)
@@ -57,6 +57,7 @@ proc all_tracking_branches {} {
 proc load_all_remotes {} {
        global repo_config
        global all_remotes tracking_branches some_heads_tracking
+       global remote_url
 
        set some_heads_tracking 0
        set all_remotes [list]
@@ -76,6 +77,10 @@ proc load_all_remotes {} {
                        catch {
                                set fd [open [file join $rm_dir $name] r]
                                while {[gets $fd line] >= 0} {
+                                       if {[regexp {^URL:[     ]*(.+)$} $line line url]} {
+                                               set remote_url($name) $url
+                                               continue
+                                       }
                                        if {![regexp {^Pull:[   ]*([^:]+):(.+)$} \
                                                $line line src dst]} continue
                                        if {[string index $src 0] eq {+}} {
@@ -100,6 +105,7 @@ proc load_all_remotes {} {
        foreach line [array names repo_config remote.*.url] {
                if {![regexp ^remote\.(.*)\.url\$ $line line name]} continue
                lappend all_remotes $name
+               set remote_url($name) $repo_config(remote.$name.url)
 
                if {[catch {set fl $repo_config(remote.$name.fetch)}]} {
                        set fl {}
@@ -129,8 +135,10 @@ proc load_all_remotes {} {
 proc populate_fetch_menu {} {
        global all_remotes repo_config
 
-       set m .mbar.fetch
-       set prune_list [list]
+       set remote_m .mbar.remote
+       set fetch_m $remote_m.fetch
+       set prune_m $remote_m.prune
+
        foreach r $all_remotes {
                set enable 0
                if {![catch {set a $repo_config(remote.$r.url)}]} {
@@ -151,28 +159,34 @@ proc populate_fetch_menu {} {
                }
 
                if {$enable} {
-                       lappend prune_list $r
-                       $m add command \
-                               -label "Fetch from $r..." \
+                       if {![winfo exists $fetch_m]} {
+                               menu $prune_m
+                               $remote_m insert 0 cascade \
+                                       -label [mc "Prune from"] \
+                                       -menu $prune_m
+
+                               menu $fetch_m
+                               $remote_m insert 0 cascade \
+                                       -label [mc "Fetch from"] \
+                                       -menu $fetch_m
+                       }
+
+                       $fetch_m add command \
+                               -label $r \
                                -command [list fetch_from $r]
+                       $prune_m add command \
+                               -label $r \
+                               -command [list prune_from $r]
                }
        }
-
-       if {$prune_list ne {}} {
-               $m add separator
-       }
-       foreach r $prune_list {
-               $m add command \
-                       -label "Prune from $r..." \
-                       -command [list prune_from $r]
-       }
 }
 
 proc populate_push_menu {} {
        global all_remotes repo_config
 
-       set m .mbar.push
-       set fast_count 0
+       set remote_m .mbar.remote
+       set push_m $remote_m.push
+
        foreach r $all_remotes {
                set enable 0
                if {![catch {set a $repo_config(remote.$r.url)}]} {
@@ -193,13 +207,16 @@ proc populate_push_menu {} {
                }
 
                if {$enable} {
-                       if {!$fast_count} {
-                               $m add separator
+                       if {![winfo exists $push_m]} {
+                               menu $push_m
+                               $remote_m insert 0 cascade \
+                                       -label [mc "Push to"] \
+                                       -menu $push_m
                        }
-                       $m add command \
-                               -label "Push to $r..." \
+
+                       $push_m add command \
+                               -label $r \
                                -command [list push_to $r]
-                       incr fast_count
                }
        }
 }