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

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>

Shawn O. Pearce committed Nov 7, 2006 at 21:27 UTC e534f3a88676fe0a08eb20359e1a43c6aa7dfe84
1 file changed +42 -9
git-gui
+42 -9
@@ -71,6 +71,7 @@ proc update_status {{final Ready.}} {
71 global HEAD PARENT commit_type
72 global ui_index ui_other ui_status_value ui_comm
73 global status_active file_states
74 + global cfg_trust_mtime
75
76 if {$status_active || ![lock_index read]} return
77
@@ -100,22 +101,28 @@ proc update_status {{final Ready.}} {
101 $ui_comm edit modified false
102 }
103
103 - set status_active 1
104 - set ui_status_value {Refreshing file status...}
105 - set fd_rf [open "| git update-index -q --unmerged --refresh" r]
106 - fconfigure $fd_rf -blocking 0 -translation binary
107 - fileevent $fd_rf readable [list read_refresh $fd_rf $final]
104 + if {$cfg_trust_mtime == {true}} {
105 + update_status_stage2 {} $final
106 + } else {
107 + set status_active 1
108 + set ui_status_value {Refreshing file status...}
109 + set fd_rf [open "| git update-index -q --unmerged --refresh" r]
110 + fconfigure $fd_rf -blocking 0 -translation binary
111 + fileevent $fd_rf readable [list update_status_stage2 $fd_rf $final]
112 + }
113 }
114
110 -proc read_refresh {fd final} {
115 +proc update_status_stage2 {fd final} {
116 global gitdir PARENT commit_type
117 global ui_index ui_other ui_status_value ui_comm
118 global status_active file_states
119 global buf_rdi buf_rdf buf_rlo
120
116 - read $fd
117 - if {![eof $fd]} return
118 - close $fd
121 + if {$fd != {}} {
122 + read $fd
123 + if {![eof $fd]} return
124 + close $fd
125 + }
126
127 set ls_others [list | git ls-files --others -z \
128 --exclude-per-directory=.gitignore]
@@ -860,6 +867,7 @@ proc toggle_mode {path} {
867
868 proc load_repo_config {} {
869 global repo_config
870 + global cfg_trust_mtime
871
872 array unset repo_config
873 catch {
@@ -871,6 +879,22 @@ proc load_repo_config {} {
879 }
880 close $fd_rc
881 }
882 +
883 + if {[catch {set cfg_trust_mtime $repo_config(gui.trustmtime)}]} {
884 + set cfg_trust_mtime false
885 + }
886 +}
887 +
888 +proc save_my_config {} {
889 + global repo_config
890 + global cfg_trust_mtime
891 +
892 + if {[catch {set rc_trustMTime $repo_config(gui.trustmtime)}]} {
893 + set rc_trustMTime false
894 + }
895 + if {$cfg_trust_mtime != $rc_trustMTime} {
896 + exec git repo-config gui.trustMTime $cfg_trust_mtime
897 + }
898 }
899
900 proc load_all_remotes {} {
@@ -1299,6 +1323,7 @@ proc do_quit {} {
1323 file delete $save
1324 }
1325
1326 + save_my_config
1327 destroy .
1328 }
1329
@@ -1407,6 +1432,7 @@ menu .mbar -tearoff 0
1432 .mbar add cascade -label Fetch -menu .mbar.fetch
1433 .mbar add cascade -label Pull -menu .mbar.pull
1434 .mbar add cascade -label Push -menu .mbar.push
1435 +.mbar add cascade -label Options -menu .mbar.options
1436 . configure -menu .mbar
1437
1438 # -- Project Menu
@@ -1461,6 +1487,13 @@ menu .mbar.pull
1487 # -- Push Menu
1488 menu .mbar.push
1489
1490 +# -- Options Menu
1491 +menu .mbar.options
1492 +.mbar.options add checkbutton -label {Trust File Modification Timestamp} \
1493 + -offvalue false \
1494 + -onvalue true \
1495 + -variable cfg_trust_mtime
1496 +
1497 # -- Main Window Layout
1498 panedwindow .vpane -orient vertical
1499 panedwindow .vpane.files -orient horizontal