Skip to content

Commit 4096958

Browse files
committed
Merge git://repo.or.cz/git-gui
* git://repo.or.cz/git-gui: git-gui: adjust the minimum height of diff pane for shorter screen height git-gui: fix use of uninitialized variable git-gui: store wm state and fix wm geometry git-gui: Ensure submodule path is quoted properly git-gui: fix diff for partially staged submodule changes git-gui: Update russian translation git-gui: Limit display to a maximum number of files git-gui: remove warning when deleting correctly merged remote branch git-gui: Added Greek translation & glossary git-gui: display summary when showing diff of a submodule
2 parents 610f99e + acb9108 commit 4096958

File tree

7 files changed

+2276
-24
lines changed

7 files changed

+2276
-24
lines changed

git-gui/git-gui.sh

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,8 @@ set default_config(gui.newbranchtemplate) {}
745745
set default_config(gui.spellingdictionary) {}
746746
set default_config(gui.fontui) [font configure font_ui]
747747
set default_config(gui.fontdiff) [font configure font_diff]
748+
# TODO: this option should be added to the git-config documentation
749+
set default_config(gui.maxfilesdisplayed) 5000
748750
set font_descs {
749751
{fontui font_ui {mc "Main Font"}}
750752
{fontdiff font_diff {mc "Diff/Console Font"}}
@@ -1132,6 +1134,7 @@ set current_branch {}
11321134
set is_detached 0
11331135
set current_diff_path {}
11341136
set is_3way_diff 0
1137+
set is_submodule_diff 0
11351138
set is_conflict_diff 0
11361139
set selected_commit_type new
11371140
set diff_empty_count 0
@@ -1698,10 +1701,12 @@ proc display_all_files_helper {w path icon_name m} {
16981701
$w insert end "[escape_path $path]\n"
16991702
}
17001703
1704+
set files_warning 0
17011705
proc display_all_files {} {
17021706
global ui_index ui_workdir
17031707
global file_states file_lists
17041708
global last_clicked
1709+
global files_warning
17051710
17061711
$ui_index conf -state normal
17071712
$ui_workdir conf -state normal
@@ -1713,7 +1718,18 @@ proc display_all_files {} {
17131718
set file_lists($ui_index) [list]
17141719
set file_lists($ui_workdir) [list]
17151720
1716-
foreach path [lsort [array names file_states]] {
1721+
set to_display [lsort [array names file_states]]
1722+
set display_limit [get_config gui.maxfilesdisplayed]
1723+
if {[llength $to_display] > $display_limit} {
1724+
if {!$files_warning} {
1725+
# do not repeatedly warn:
1726+
set files_warning 1
1727+
info_popup [mc "Displaying only %s of %s files." \
1728+
$display_limit [llength $to_display]]
1729+
}
1730+
set to_display [lrange $to_display 0 [expr {$display_limit-1}]]
1731+
}
1732+
foreach path $to_display {
17171733
set s $file_states($path)
17181734
set m [lindex $s 0]
17191735
set icon_name [lindex $s 1]
@@ -2010,6 +2026,19 @@ proc do_quit {{rc {1}}} {
20102026
20112027
# -- Stash our current window geometry into this repository.
20122028
#
2029+
set cfg_wmstate [wm state .]
2030+
if {[catch {set rc_wmstate $repo_config(gui.wmstate)}]} {
2031+
set rc_wmstate {}
2032+
}
2033+
if {$cfg_wmstate ne $rc_wmstate} {
2034+
catch {git config gui.wmstate $cfg_wmstate}
2035+
}
2036+
if {$cfg_wmstate eq {zoomed}} {
2037+
# on Windows wm geometry will lie about window
2038+
# position (but not size) when window is zoomed
2039+
# restore the window before querying wm geometry
2040+
wm state . normal
2041+
}
20132042
set cfg_geometry [list]
20142043
lappend cfg_geometry [wm geometry .]
20152044
lappend cfg_geometry [lindex [.vpane sash coord 0] 0]
@@ -3054,7 +3083,7 @@ frame .vpane.lower.diff.body
30543083
set ui_diff .vpane.lower.diff.body.t
30553084
text $ui_diff -background white -foreground black \
30563085
-borderwidth 0 \
3057-
-width 80 -height 15 -wrap none \
3086+
-width 80 -height 5 -wrap none \
30583087
-font font_diff \
30593088
-xscrollcommand {.vpane.lower.diff.body.sbx set} \
30603089
-yscrollcommand {.vpane.lower.diff.body.sby set} \
@@ -3212,7 +3241,7 @@ proc popup_diff_menu {ctxm ctxmmg x y X Y} {
32123241
set l [mc "Stage Hunk For Commit"]
32133242
set t [mc "Stage Line For Commit"]
32143243
}
3215-
if {$::is_3way_diff
3244+
if {$::is_3way_diff || $::is_submodule_diff
32163245
|| $current_diff_path eq {}
32173246
|| {__} eq $state
32183247
|| {_O} eq $state
@@ -3249,6 +3278,14 @@ wm geometry . [lindex $gm 0]
32493278
unset gm
32503279
}
32513280
3281+
# -- Load window state
3282+
#
3283+
catch {
3284+
set gws $repo_config(gui.wmstate)
3285+
wm state . $gws
3286+
unset gws
3287+
}
3288+
32523289
# -- Key Bindings
32533290
#
32543291
bind $ui_comm <$M1B-Key-Return> {do_commit;break}

git-gui/lib/diff.tcl

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ proc show_other_diff {path w m cont_info} {
255255

256256
proc start_show_diff {cont_info {add_opts {}}} {
257257
global file_states file_lists
258-
global is_3way_diff diff_active repo_config
258+
global is_3way_diff is_submodule_diff diff_active repo_config
259259
global ui_diff ui_index ui_workdir
260260
global current_diff_path current_diff_side current_diff_header
261261

@@ -265,6 +265,7 @@ proc start_show_diff {cont_info {add_opts {}}} {
265265
set s $file_states($path)
266266
set m [lindex $s 0]
267267
set is_3way_diff 0
268+
set is_submodule_diff 0
268269
set diff_active 1
269270
set current_diff_header {}
270271

@@ -295,6 +296,16 @@ proc start_show_diff {cont_info {add_opts {}}} {
295296
lappend cmd $path
296297
}
297298

299+
if {[string match {160000 *} [lindex $s 2]]
300+
|| [string match {160000 *} [lindex $s 3]]} {
301+
set is_submodule_diff 1
302+
if {$w eq $ui_index} {
303+
set cmd [list submodule summary --cached -- $path]
304+
} else {
305+
set cmd [list submodule summary --files -- $path]
306+
}
307+
}
308+
298309
if {[catch {set fd [eval git_read --nice $cmd]} err]} {
299310
set diff_active 0
300311
unlock_index
@@ -312,7 +323,7 @@ proc start_show_diff {cont_info {add_opts {}}} {
312323
}
313324

314325
proc read_diff {fd cont_info} {
315-
global ui_diff diff_active
326+
global ui_diff diff_active is_submodule_diff
316327
global is_3way_diff is_conflict_diff current_diff_header
317328
global current_diff_queue
318329
global diff_empty_count
@@ -374,6 +385,23 @@ proc read_diff {fd cont_info} {
374385
set tags {}
375386
}
376387
}
388+
} elseif {$is_submodule_diff} {
389+
if {$line == ""} continue
390+
if {[regexp {^\* } $line]} {
391+
set line [string replace $line 0 1 {Submodule }]
392+
set tags d_@
393+
} else {
394+
set op [string range $line 0 2]
395+
switch -- $op {
396+
{ <} {set tags d_-}
397+
{ >} {set tags d_+}
398+
{ W} {set tags {}}
399+
default {
400+
puts "error: Unhandled submodule diff marker: {$op}"
401+
set tags {}
402+
}
403+
}
404+
}
377405
} else {
378406
set op [string index $line 0]
379407
switch -- $op {

git-gui/lib/remote_branch_delete.tcl

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -208,13 +208,15 @@ method _delete {} {
208208
return
209209
}
210210

211-
if {[tk_messageBox \
212-
-icon warning \
213-
-type yesno \
214-
-title [wm title $w] \
215-
-parent $w \
216-
-message [mc "Recovering deleted branches is difficult.\n\nDelete the selected branches?"]] ne yes} {
217-
return
211+
if {$checktype ne {head}} {
212+
if {[tk_messageBox \
213+
-icon warning \
214+
-type yesno \
215+
-title [wm title $w] \
216+
-parent $w \
217+
-message [mc "Recovering deleted branches is difficult.\n\nDelete the selected branches?"]] ne yes} {
218+
return
219+
}
218220
}
219221

220222
destroy $w

0 commit comments

Comments
 (0)