Skip to content

Commit e534f3a

Browse files
committed
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 <[email protected]>
1 parent d1536c4 commit e534f3a

File tree

1 file changed

+42
-9
lines changed

1 file changed

+42
-9
lines changed

git-gui

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ proc update_status {{final Ready.}} {
7171
global HEAD PARENT commit_type
7272
global ui_index ui_other ui_status_value ui_comm
7373
global status_active file_states
74+
global cfg_trust_mtime
7475

7576
if {$status_active || ![lock_index read]} return
7677

@@ -100,22 +101,28 @@ proc update_status {{final Ready.}} {
100101
$ui_comm edit modified false
101102
}
102103

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+
}
108113
}
109114

110-
proc read_refresh {fd final} {
115+
proc update_status_stage2 {fd final} {
111116
global gitdir PARENT commit_type
112117
global ui_index ui_other ui_status_value ui_comm
113118
global status_active file_states
114119
global buf_rdi buf_rdf buf_rlo
115120

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+
}
119126

120127
set ls_others [list | git ls-files --others -z \
121128
--exclude-per-directory=.gitignore]
@@ -860,6 +867,7 @@ proc toggle_mode {path} {
860867

861868
proc load_repo_config {} {
862869
global repo_config
870+
global cfg_trust_mtime
863871

864872
array unset repo_config
865873
catch {
@@ -871,6 +879,22 @@ proc load_repo_config {} {
871879
}
872880
close $fd_rc
873881
}
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+
}
874898
}
875899

876900
proc load_all_remotes {} {
@@ -1299,6 +1323,7 @@ proc do_quit {} {
12991323
file delete $save
13001324
}
13011325

1326+
save_my_config
13021327
destroy .
13031328
}
13041329

@@ -1407,6 +1432,7 @@ menu .mbar -tearoff 0
14071432
.mbar add cascade -label Fetch -menu .mbar.fetch
14081433
.mbar add cascade -label Pull -menu .mbar.pull
14091434
.mbar add cascade -label Push -menu .mbar.push
1435+
.mbar add cascade -label Options -menu .mbar.options
14101436
. configure -menu .mbar
14111437

14121438
# -- Project Menu
@@ -1461,6 +1487,13 @@ menu .mbar.pull
14611487
# -- Push Menu
14621488
menu .mbar.push
14631489

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+
14641497
# -- Main Window Layout
14651498
panedwindow .vpane -orient vertical
14661499
panedwindow .vpane.files -orient horizontal

0 commit comments

Comments
 (0)