1 # git-gui transport (fetch/push) support
2 # Copyright (C) 2006, 2007 Shawn Pearce
4 proc fetch_from
{remote
} {
7 "Fetching new changes from $remote"]
8 set cmd
[list git fetch
]
10 console_exec
$w $cmd console_done
13 proc push_to
{remote
} {
16 "Pushing changes to $remote"]
17 set cmd
[list git push
]
20 console_exec
$w $cmd console_done
23 proc start_push_anywhere_action
{w
} {
24 global push_urltype push_remote push_url push_thin push_tags
27 switch -- $push_urltype {
28 remote
{set r_url
$push_remote}
29 url
{set r_url
$push_url}
31 if {$r_url eq
{}} return
33 set cmd
[list git push
]
43 foreach i
[$w.
source.l curselection
] {
44 set b
[$w.
source.l get
$i]
45 lappend cmd
"refs/heads/$b:refs/heads/$b"
50 } elseif
{$cnt == 1} {
56 set cons
[new_console
"push $r_url" "Pushing $cnt $unit to $r_url"]
57 console_exec
$cons $cmd console_done
61 trace add
variable push_remote write
\
62 [list radio_selector push_urltype remote
]
64 proc do_push_anywhere
{} {
65 global all_heads all_remotes current_branch
66 global push_urltype push_remote push_url push_thin push_tags
70 wm geometry
$w "+[winfo rootx .]+[winfo rooty .]"
72 label $w.header
-text {Push Branches
} -font font_uibold
73 pack $w.header
-side top
-fill x
76 button $w.buttons.create
-text Push
\
78 -command [list start_push_anywhere_action
$w]
79 pack $w.buttons.create
-side right
80 button $w.buttons.cancel
-text {Cancel
} \
82 -command [list destroy $w]
83 pack $w.buttons.cancel
-side right
-padx 5
84 pack $w.buttons
-side bottom
-fill x
-pady 10 -padx 10
86 labelframe $w.
source -text {Source Branches
}
90 -selectmode extended
\
91 -yscrollcommand [list $w.
source.sby
set]
92 foreach h
$all_heads {
93 $w.
source.l insert end
$h
94 if {$h eq
$current_branch} {
95 $w.
source.l select
set end
98 scrollbar $w.
source.sby
-command [list $w.
source.l yview
]
99 pack $w.
source.sby
-side right
-fill y
100 pack $w.
source.l
-side left
-fill both
-expand 1
101 pack $w.
source -fill both
-expand 1 -pady 5 -padx 5
103 labelframe $w.dest
-text {Destination Repository
}
104 if {$all_remotes ne
{}} {
105 radiobutton $w.dest.remote_r
\
108 -variable push_urltype
109 eval tk_optionMenu $w.dest.remote_m push_remote
$all_remotes
110 grid $w.dest.remote_r
$w.dest.remote_m
-sticky w
111 if {[lsearch -sorted -exact $all_remotes origin
] != -1} {
112 set push_remote origin
114 set push_remote
[lindex $all_remotes 0]
116 set push_urltype remote
120 radiobutton $w.dest.url_r
\
121 -text {Arbitrary URL
:} \
123 -variable push_urltype
124 entry $w.dest.url_t
\
128 -textvariable push_url
\
131 if {%d
== 1 && [regexp {\s
} %S
]} {return 0}
132 if {%d
== 1 && [string length
%S
] > 0} {
137 grid $w.dest.url_r
$w.dest.url_t
-sticky we
-padx {0 5}
138 grid columnconfigure
$w.dest
1 -weight 1
139 pack $w.dest
-anchor nw
-fill x
-pady 5 -padx 5
141 labelframe $w.
options -text {Transfer Options
}
142 checkbutton $w.
options.thin
\
143 -text {Use thin
pack (for slow network connections
)} \
145 grid $w.
options.thin
-columnspan 2 -sticky w
146 checkbutton $w.
options.tags
\
147 -text {Include tags
} \
149 grid $w.
options.tags
-columnspan 2 -sticky w
150 grid columnconfigure
$w.
options 1 -weight 1
151 pack $w.
options -anchor nw
-fill x
-pady 5 -padx 5
157 bind $w <Visibility
> "grab $w; focus $w.buttons.create"
158 bind $w <Key-Escape
> "destroy $w"
159 bind $w <Key-Return
> [list start_push_anywhere_action
$w]
160 wm title
$w "[appname] ([reponame]): Push"