git-gui: Allow the user to disable update-index --refresh during rescan.

On very large projects (~1000 files) on Windows systems the update-index
--refresh stage of the rescan process takes a nontrival amount of time.
If the user is generally very careful with their file modification such
that the modification timestamp of the file differs only when the content
also differs then we can skip this somewhat expensive step and go right
to the diff-index and diff-files processes.

We save the user's prefernce in the current repository if they modify the
setting during a git-gui session, but we also load it through our dump of
repo-config --list so the user could move it to their ~/.gitconfig file
if they wanted it globally disabled.

We still keep update-index --refresh enabled by default however, as most
users will probably want it.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
This commit is contained in:
Shawn O. Pearce 2006-11-07 21:27:29 -05:00
Родитель d1536c488e
Коммит e534f3a886
1 изменённых файлов: 42 добавлений и 9 удалений

51
git-gui
Просмотреть файл

@ -71,6 +71,7 @@ proc update_status {{final Ready.}} {
global HEAD PARENT commit_type global HEAD PARENT commit_type
global ui_index ui_other ui_status_value ui_comm global ui_index ui_other ui_status_value ui_comm
global status_active file_states global status_active file_states
global cfg_trust_mtime
if {$status_active || ![lock_index read]} return if {$status_active || ![lock_index read]} return
@ -100,22 +101,28 @@ proc update_status {{final Ready.}} {
$ui_comm edit modified false $ui_comm edit modified false
} }
set status_active 1 if {$cfg_trust_mtime == {true}} {
set ui_status_value {Refreshing file status...} update_status_stage2 {} $final
set fd_rf [open "| git update-index -q --unmerged --refresh" r] } else {
fconfigure $fd_rf -blocking 0 -translation binary set status_active 1
fileevent $fd_rf readable [list read_refresh $fd_rf $final] set ui_status_value {Refreshing file status...}
set fd_rf [open "| git update-index -q --unmerged --refresh" r]
fconfigure $fd_rf -blocking 0 -translation binary
fileevent $fd_rf readable [list update_status_stage2 $fd_rf $final]
}
} }
proc read_refresh {fd final} { proc update_status_stage2 {fd final} {
global gitdir PARENT commit_type global gitdir PARENT commit_type
global ui_index ui_other ui_status_value ui_comm global ui_index ui_other ui_status_value ui_comm
global status_active file_states global status_active file_states
global buf_rdi buf_rdf buf_rlo global buf_rdi buf_rdf buf_rlo
read $fd if {$fd != {}} {
if {![eof $fd]} return read $fd
close $fd if {![eof $fd]} return
close $fd
}
set ls_others [list | git ls-files --others -z \ set ls_others [list | git ls-files --others -z \
--exclude-per-directory=.gitignore] --exclude-per-directory=.gitignore]
@ -860,6 +867,7 @@ proc toggle_mode {path} {
proc load_repo_config {} { proc load_repo_config {} {
global repo_config global repo_config
global cfg_trust_mtime
array unset repo_config array unset repo_config
catch { catch {
@ -871,6 +879,22 @@ proc load_repo_config {} {
} }
close $fd_rc close $fd_rc
} }
if {[catch {set cfg_trust_mtime $repo_config(gui.trustmtime)}]} {
set cfg_trust_mtime false
}
}
proc save_my_config {} {
global repo_config
global cfg_trust_mtime
if {[catch {set rc_trustMTime $repo_config(gui.trustmtime)}]} {
set rc_trustMTime false
}
if {$cfg_trust_mtime != $rc_trustMTime} {
exec git repo-config gui.trustMTime $cfg_trust_mtime
}
} }
proc load_all_remotes {} { proc load_all_remotes {} {
@ -1299,6 +1323,7 @@ proc do_quit {} {
file delete $save file delete $save
} }
save_my_config
destroy . destroy .
} }
@ -1407,6 +1432,7 @@ menu .mbar -tearoff 0
.mbar add cascade -label Fetch -menu .mbar.fetch .mbar add cascade -label Fetch -menu .mbar.fetch
.mbar add cascade -label Pull -menu .mbar.pull .mbar add cascade -label Pull -menu .mbar.pull
.mbar add cascade -label Push -menu .mbar.push .mbar add cascade -label Push -menu .mbar.push
.mbar add cascade -label Options -menu .mbar.options
. configure -menu .mbar . configure -menu .mbar
# -- Project Menu # -- Project Menu
@ -1461,6 +1487,13 @@ menu .mbar.pull
# -- Push Menu # -- Push Menu
menu .mbar.push menu .mbar.push
# -- Options Menu
menu .mbar.options
.mbar.options add checkbutton -label {Trust File Modification Timestamp} \
-offvalue false \
-onvalue true \
-variable cfg_trust_mtime
# -- Main Window Layout # -- Main Window Layout
panedwindow .vpane -orient vertical panedwindow .vpane -orient vertical
panedwindow .vpane.files -orient horizontal panedwindow .vpane.files -orient horizontal