@matheusbsbs / matheus-bagliano / commits / dd6451f9c7
Fork 0

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 <dzwell@zwell.net> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Dan Zwell committed Aug 11, 2009 at 13:50 UTC dd6451f9c7c5a36d3006231b618ac6da06c7c7b4
2 files changed +21 -1
git-gui.sh
+16 -1
@@ -745,6 +745,8 @@ set default_config(gui.newbranchtemplate) {}
745 set default_config(gui.spellingdictionary) {}
746 set default_config(gui.fontui) [font configure font_ui]
747 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
750 set font_descs {
751 {fontui font_ui {mc "Main Font"}}
752 {fontdiff font_diff {mc "Diff/Console Font"}}
@@ -1698,10 +1700,12 @@ proc display_all_files_helper {w path icon_name m} {
1700 $w insert end "[escape_path $path]\n"
1701 }
1702
1703 +set files_warning 0
1704 proc display_all_files {} {
1705 global ui_index ui_workdir
1706 global file_states file_lists
1707 global last_clicked
1708 + global files_warning
1709
1710 $ui_index conf -state normal
1711 $ui_workdir conf -state normal
@@ -1713,7 +1717,18 @@ proc display_all_files {} {
1717 set file_lists($ui_index) [list]
1718 set file_lists($ui_workdir) [list]
1719
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 {
1732 set s $file_states($path)
1733 set m [lindex $s 0]
1734 set icon_name [lindex $s 1]
po/git-gui.pot
+5
@@ -90,6 +90,11 @@ msgstr ""
90 msgid "Ready."
91 msgstr ""
92
93 +#: git-gui.sh:1726
94 +#, tcl-format
95 +msgid "Displaying only %s of %s files."
96 +msgstr ""
97 +
98 #: git-gui.sh:1819
99 msgid "Unmodified"
100 msgstr ""