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
]
13 proc push_to
{remote
} {
16 "Pushing changes to $remote"]
17 set cmd
[list git push
]
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
[console::new \
58 "Pushing $cnt $unit to $r_url"]
59 console::exec $cons $cmd
63 trace add
variable push_remote write
\
64 [list radio_selector push_urltype remote
]
66 proc do_push_anywhere
{} {
67 global all_heads all_remotes current_branch
68 global push_urltype push_remote push_url push_thin push_tags
72 wm geometry
$w "+[winfo rootx .]+[winfo rooty .]"
74 label $w.header
-text {Push Branches
} -font font_uibold
75 pack $w.header
-side top
-fill x
78 button $w.buttons.create
-text Push
\
80 -command [list start_push_anywhere_action
$w]
81 pack $w.buttons.create
-side right
82 button $w.buttons.cancel
-text {Cancel
} \
84 -command [list destroy $w]
85 pack $w.buttons.cancel
-side right
-padx 5
86 pack $w.buttons
-side bottom
-fill x
-pady 10 -padx 10
88 labelframe $w.
source -text {Source Branches
}
92 -selectmode extended
\
93 -yscrollcommand [list $w.
source.sby
set]
94 foreach h
$all_heads {
95 $w.
source.l insert end
$h
96 if {$h eq
$current_branch} {
97 $w.
source.l select
set end
100 scrollbar $w.
source.sby
-command [list $w.
source.l yview
]
101 pack $w.
source.sby
-side right
-fill y
102 pack $w.
source.l
-side left
-fill both
-expand 1
103 pack $w.
source -fill both
-expand 1 -pady 5 -padx 5
105 labelframe $w.dest
-text {Destination Repository
}
106 if {$all_remotes ne
{}} {
107 radiobutton $w.dest.remote_r
\
110 -variable push_urltype
111 eval tk_optionMenu $w.dest.remote_m push_remote
$all_remotes
112 grid $w.dest.remote_r
$w.dest.remote_m
-sticky w
113 if {[lsearch -sorted -exact $all_remotes origin
] != -1} {
114 set push_remote origin
116 set push_remote
[lindex $all_remotes 0]
118 set push_urltype remote
122 radiobutton $w.dest.url_r
\
123 -text {Arbitrary URL
:} \
125 -variable push_urltype
126 entry $w.dest.url_t
\
130 -textvariable push_url
\
133 if {%d
== 1 && [regexp {\s
} %S
]} {return 0}
134 if {%d
== 1 && [string length
%S
] > 0} {
139 grid $w.dest.url_r
$w.dest.url_t
-sticky we
-padx {0 5}
140 grid columnconfigure
$w.dest
1 -weight 1
141 pack $w.dest
-anchor nw
-fill x
-pady 5 -padx 5
143 labelframe $w.
options -text {Transfer Options
}
144 checkbutton $w.
options.thin
\
145 -text {Use thin
pack (for slow network connections
)} \
147 grid $w.
options.thin
-columnspan 2 -sticky w
148 checkbutton $w.
options.tags
\
149 -text {Include tags
} \
151 grid $w.
options.tags
-columnspan 2 -sticky w
152 grid columnconfigure
$w.
options 1 -weight 1
153 pack $w.
options -anchor nw
-fill x
-pady 5 -padx 5
159 bind $w <Visibility
> "grab $w; focus $w.buttons.create"
160 bind $w <Key-Escape
> "destroy $w"
161 bind $w <Key-Return
> [list start_push_anywhere_action
$w]
162 wm title
$w "[appname] ([reponame]): Push"