1 # git-gui transport (fetch/push) support
2 # Copyright (C) 2006, 2007 Shawn Pearce
4 proc fetch_from
{remote
} {
6 [mc
"fetch %s" $remote] \
7 [mc
"Fetching new changes from %s" $remote]]
9 lappend cmds
[list exec git fetch
$remote]
10 if {[is_config_true gui.pruneduringfetch
]} {
11 lappend cmds
[list exec git remote prune
$remote]
13 console::chain $w $cmds
16 proc prune_from
{remote
} {
18 [mc
"remote prune %s" $remote] \
19 [mc
"Pruning tracking branches deleted from %s" $remote]]
20 console::exec $w [list git remote prune
$remote]
23 proc push_to
{remote
} {
25 [mc
"push %s" $remote] \
26 [mc
"Pushing changes to %s" $remote]]
27 set cmd
[list git push
]
33 proc start_push_anywhere_action
{w
} {
34 global push_urltype push_remote push_url push_thin push_tags
40 switch -- $push_urltype {
42 set r_url
$push_remote
43 catch {set is_mirror
$repo_config(remote.
$push_remote.mirror
)}
45 url
{set r_url
$push_url}
47 if {$r_url eq
{}} return
49 set cmd
[list git push
]
62 set cons
[console::new \
63 [mc
"push %s" $r_url] \
64 [mc
"Mirroring to %s" $r_url]]
67 foreach i
[$w.
source.l curselection
] {
68 set b
[$w.
source.l get
$i]
69 lappend cmd
"refs/heads/$b:refs/heads/$b"
74 } elseif
{$cnt == 1} {
80 set cons
[console::new \
81 [mc
"push %s" $r_url] \
82 [mc
"Pushing %s %s to %s" $cnt $unit $r_url]]
84 console::exec $cons $cmd
88 trace add
variable push_remote write
\
89 [list radio_selector push_urltype remote
]
91 proc do_push_anywhere
{} {
92 global all_remotes current_branch
93 global push_urltype push_remote push_url push_thin push_tags
98 wm geometry
$w "+[winfo rootx .]+[winfo rooty .]"
100 label $w.header
-text [mc
"Push Branches"] -font font_uibold
101 pack $w.header
-side top
-fill x
104 button $w.buttons.create
-text [mc Push
] \
106 -command [list start_push_anywhere_action
$w]
107 pack $w.buttons.create
-side right
108 button $w.buttons.cancel
-text [mc
"Cancel"] \
110 -command [list destroy $w]
111 pack $w.buttons.cancel
-side right
-padx 5
112 pack $w.buttons
-side bottom
-fill x
-pady 10 -padx 10
114 labelframe $w.
source -text [mc
"Source Branches"]
115 listbox $w.
source.l
\
118 -selectmode extended
\
119 -yscrollcommand [list $w.
source.sby
set]
120 foreach h
[load_all_heads
] {
121 $w.
source.l insert end
$h
122 if {$h eq
$current_branch} {
123 $w.
source.l select
set end
126 scrollbar $w.
source.sby
-command [list $w.
source.l yview
]
127 pack $w.
source.sby
-side right
-fill y
128 pack $w.
source.l
-side left
-fill both
-expand 1
129 pack $w.
source -fill both
-expand 1 -pady 5 -padx 5
131 labelframe $w.dest
-text [mc
"Destination Repository"]
132 if {$all_remotes ne
{}} {
133 radiobutton $w.dest.remote_r
\
134 -text [mc
"Remote:"] \
136 -variable push_urltype
137 eval tk_optionMenu $w.dest.remote_m push_remote
$all_remotes
138 grid $w.dest.remote_r
$w.dest.remote_m
-sticky w
139 if {[lsearch -sorted -exact $all_remotes origin
] != -1} {
140 set push_remote origin
142 set push_remote
[lindex $all_remotes 0]
144 set push_urltype remote
148 radiobutton $w.dest.url_r
\
149 -text [mc
"Arbitrary Location:"] \
151 -variable push_urltype
152 entry $w.dest.url_t
\
156 -textvariable push_url
\
159 if {%d
== 1 && [regexp {\s
} %S
]} {return 0}
160 if {%d
== 1 && [string length
%S
] > 0} {
165 grid $w.dest.url_r
$w.dest.url_t
-sticky we
-padx {0 5}
166 grid columnconfigure
$w.dest
1 -weight 1
167 pack $w.dest
-anchor nw
-fill x
-pady 5 -padx 5
169 labelframe $w.
options -text [mc
"Transfer Options"]
170 checkbutton $w.
options.force
\
171 -text [mc
"Force overwrite existing branch (may discard changes)"] \
173 grid $w.
options.force
-columnspan 2 -sticky w
174 checkbutton $w.
options.thin
\
175 -text [mc
"Use thin pack (for slow network connections)"] \
177 grid $w.
options.thin
-columnspan 2 -sticky w
178 checkbutton $w.
options.tags
\
179 -text [mc
"Include tags"] \
181 grid $w.
options.tags
-columnspan 2 -sticky w
182 grid columnconfigure
$w.
options 1 -weight 1
183 pack $w.
options -anchor nw
-fill x
-pady 5 -padx 5
190 bind $w <Visibility
> "grab $w; focus $w.buttons.create"
191 bind $w <Key-Escape
> "destroy $w"
192 bind $w <Key-Return
> [list start_push_anywhere_action
$w]
193 wm title
$w [append "[appname] ([reponame]): " [mc
"Push"]]