From: Dan Zwell <dzwell@zwell.net>
To: "Shawn O. Pearce" <spearce@spearce.org>
Cc: Git Mailing List <git@vger.kernel.org>, raa.lkml@gmail.com
Subject: Re: [PATCH] Limit git-gui to display a maximum number of files
Date: Tue, 11 Aug 2009 13:23:52 -0500 [thread overview]
Message-ID: <4A81B738.7090507@zwell.net> (raw)
In-Reply-To: <20090810153859.GT1033@spearce.org>
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 when the list of files is truncated.
Signed-off-by: Dan Zwell <dzwell@zwell.net>
---
By the way, is the right way to deal with strings to be
translated? See the end of the patch.
git-gui.sh | 18 +++++++++++++++++-
po/git-gui.pot | 5 +++++
2 files changed, 22 insertions(+), 1 deletions(-)
diff --git a/git-gui.sh b/git-gui.sh
index 3c0ce26..a4dde9e 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -745,6 +745,8 @@ set default_config(gui.newbranchtemplate) {}
set default_config(gui.spellingdictionary) {}
set default_config(gui.fontui) [font configure font_ui]
set default_config(gui.fontdiff) [font configure font_diff]
+# TODO: this option should be added to the git-config documentation
+set default_config(gui.maxfilesdisplayed) 5000
set font_descs {
{fontui font_ui {mc "Main Font"}}
{fontdiff font_diff {mc "Diff/Console Font"}}
@@ -1698,10 +1700,12 @@ proc display_all_files_helper {w path icon_name m} {
$w insert end "[escape_path $path]\n"
}
+set files_warning 0
proc display_all_files {} {
global ui_index ui_workdir
global file_states file_lists
global last_clicked
+ global files_warning
$ui_index conf -state normal
$ui_workdir conf -state normal
@@ -1713,7 +1717,19 @@ proc display_all_files {} {
set file_lists($ui_index) [list]
set file_lists($ui_workdir) [list]
- foreach path [lsort [array names file_states]] {
+ set to_display [lsort [array names file_states]]
+ set display_limit [get_config gui.maxfilesdisplayed]
+ if {[llength $to_display] > $display_limit} {
+ if {!$files_warning} {
+ # do not repeatedly warn:
+ set files_warning 1
+ set warning "Displaying only $display_limit of "
+ append warning "[llength $to_display] files."
+ info_popup [mc $warning]
+ }
+ set to_display [lrange $to_display 0 [expr {$display_limit-1}]]
+ }
+ foreach path $to_display {
set s $file_states($path)
set m [lindex $s 0]
set icon_name [lindex $s 1]
diff --git a/po/git-gui.pot b/po/git-gui.pot
index 53b7d36..fb60472 100644
--- a/po/git-gui.pot
+++ b/po/git-gui.pot
@@ -90,6 +90,11 @@ msgstr ""
msgid "Ready."
msgstr ""
+#: git-gui.sh:1725
+#, tcl-format
+msgid "Displaying only %s of %s files."
+msgstr ""
+
#: git-gui.sh:1819
msgid "Unmodified"
msgstr ""
--
1.6.4
Shawn O. Pearce wrote:
> Dan Zwell <dzwell@gmail.com> wrote:
>
>> When there is a large number of new or modified files,
>> "display_all_files" takes a long time, and git-gui appears to
>> hang. Limit the display to 5000 files, by default. This number
>> is configurable as gui.maxfilesdisplayed.
>>
>> Show a warning if the list of files is truncated.
>>
>
>
>> @@ -1713,7 +1717,18 @@ proc display_all_files {} {
>> set file_lists($ui_index) [list]
>> set file_lists($ui_workdir) [list]
>>
>> - foreach path [lsort [array names file_states]] {
>> + set to_display [lsort [array names file_states]]
>> + set display_limit $default_config(gui.maxfilesdisplayed)
>>
>
> This should use [get_config gui.maxfilesdisplayed] so that the
> user can actually set this property in a configuration file and
> have git-gui honor it. Reading from $default_config means you are
> only looking at the hardcoded value you set in git-gui.sh.
>
>
>> + if {[llength $to_display] > $display_limit} {
>> + if {![info exists files_warning] || !$files_warning} {
>>
>
> Wouldn't it be easier to just set files_warning to 0 at the start
> of the script, so that you don't need to do this info exists test?
>
>
>> + set warning "Displaying only $display_limit of "
>> + append warning "[llength $to_display] files."
>> + info_popup [mc $warning]
>>
>
> This needs to be in the translated strings.
>
>
next prev parent reply other threads:[~2009-08-11 20:24 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-30 20:37 [PATCH] Limited git-gui to displaying 5000 new files Dan Zwell
2009-08-10 15:38 ` Shawn O. Pearce
2009-08-10 17:06 ` Alex Riesen
2009-08-10 17:08 ` Shawn O. Pearce
2009-08-10 15:15 ` Dan Zwell
2009-08-11 18:23 ` Dan Zwell [this message]
2009-08-11 20:29 ` [PATCH] Limit git-gui to display a maximum number of files Shawn O. Pearce
2009-08-11 18:50 ` Dan Zwell
2009-08-12 14:43 ` Shawn O. Pearce
2009-08-12 15:24 ` [PATCH] git-gui: Update russian translation Alex Riesen
2009-08-12 15:40 ` Shawn O. Pearce
2009-08-12 15:51 ` Dan Zwell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4A81B738.7090507@zwell.net \
--to=dzwell@zwell.net \
--cc=git@vger.kernel.org \
--cc=raa.lkml@gmail.com \
--cc=spearce@spearce.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).