Skip to content

Commit dd6451f

Browse files
Dan Zwellspearce
authored andcommitted
git-gui: Limit display to a maximum number of files
When there is a large number of new or modified files, "display_all_files" takes a long time, and git-gui appears to hang. This change limits the number of files that are displayed. This limit can be set as gui.maxfilesdisplayed, and is 5000 by default. A warning is shown the first time the list of files is truncated in this GUI session. Subsequent truncations are not mentioned to the user. Signed-off-by: Dan Zwell <[email protected]> Signed-off-by: Shawn O. Pearce <[email protected]>
1 parent 2112be7 commit dd6451f

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

git-gui.sh

Lines changed: 16 additions & 1 deletion
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"}}
@@ -1698,10 +1700,12 @@ proc display_all_files_helper {w path icon_name m} {
16981700
$w insert end "[escape_path $path]\n"
16991701
}
17001702
1703+
set files_warning 0
17011704
proc display_all_files {} {
17021705
global ui_index ui_workdir
17031706
global file_states file_lists
17041707
global last_clicked
1708+
global files_warning
17051709
17061710
$ui_index conf -state normal
17071711
$ui_workdir conf -state normal
@@ -1713,7 +1717,18 @@ proc display_all_files {} {
17131717
set file_lists($ui_index) [list]
17141718
set file_lists($ui_workdir) [list]
17151719
1716-
foreach path [lsort [array names file_states]] {
1720+
set to_display [lsort [array names file_states]]
1721+
set display_limit [get_config gui.maxfilesdisplayed]
1722+
if {[llength $to_display] > $display_limit} {
1723+
if {!$files_warning} {
1724+
# do not repeatedly warn:
1725+
set files_warning 1
1726+
info_popup [mc "Displaying only %s of %s files." \
1727+
$display_limit [llength $to_display]]
1728+
}
1729+
set to_display [lrange $to_display 0 [expr {$display_limit-1}]]
1730+
}
1731+
foreach path $to_display {
17171732
set s $file_states($path)
17181733
set m [lindex $s 0]
17191734
set icon_name [lindex $s 1]

po/git-gui.pot

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ msgstr ""
9090
msgid "Ready."
9191
msgstr ""
9292

93+
#: git-gui.sh:1726
94+
#, tcl-format
95+
msgid "Displaying only %s of %s files."
96+
msgstr ""
97+
9398
#: git-gui.sh:1819
9499
msgid "Unmodified"
95100
msgstr ""

0 commit comments

Comments
 (0)