git-gui: fix problem with gui.maxfilesdisplayed

gui.maxfilesdisplayed (added in dd6451f9c7c5a36d3006231b618ac6da06c7c7b4) was applied brute force on the file list in alphabetic order. As a result, files that had modifications might not be displayed by git-gui. Even worse, files that are already in the index might not be displayed, which makes git-gui hard to use in some workflows. This fix changes the meaning of gui.maxfilesdisplayed, making it a soft limit that only applies to "_O" files, i.e. files that are "Untracked, not staged". Signed-off-by: Csaba Kiraly <kiraly@disi.unitn.it> Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>

Csaba Kiraly committed Dec 15, 2014 at 16:38 UTC a117fa211671b01449c81c7aed6766e55cb55c38
1 file changed +12 -9
git-gui.sh
+12 -9
@@ -1965,20 +1965,22 @@ proc display_all_files {} {
1965
1966 set to_display [lsort [array names file_states]]
1967 set display_limit [get_config gui.maxfilesdisplayed]
1968 - if {[llength $to_display] > $display_limit} {
1969 - if {!$files_warning} {
1970 - # do not repeatedly warn:
1971 - set files_warning 1
1972 - info_popup [mc "Displaying only %s of %s files." \
1973 - $display_limit [llength $to_display]]
1974 - }
1975 - set to_display [lrange $to_display 0 [expr {$display_limit-1}]]
1976 - }
1968 + set displayed 0
1969 foreach path $to_display {
1970 set s $file_states($path)
1971 set m [lindex $s 0]
1972 set icon_name [lindex $s 1]
1973
1974 + if {$displayed > $display_limit && [string index $m 1] eq {O} } {
1975 + if {!$files_warning} {
1976 + # do not repeatedly warn:
1977 + set files_warning 1
1978 + info_popup [mc "Display limit (gui.maxfilesdisplayed = %s) reached, not showing all %s files." \
1979 + $display_limit [llength $to_display]]
1980 + }
1981 + continue
1982 + }
1983 +
1984 set s [string index $m 0]
1985 if {$s ne {U} && $s ne {_}} {
1986 display_all_files_helper $ui_index $path \
@@ -1993,6 +1995,7 @@ proc display_all_files {} {
1995 if {$s ne {_}} {
1996 display_all_files_helper $ui_workdir $path \
1997 $icon_name $s
1998 + incr displayed
1999 }
2000 }
2001