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

git-gui: By default don't allow partially included files.

The concept of the Git index is confusing for many users, especially those who are newer to Git. Since git-gui is (at least partially) intended to be used by newer users who don't need the complexity of the index to be put in front of them early on, we should hide it by making any partially included file fully included as soon as we identify it. To do this we just run a quick update_index pass on any file which differs both in the index and the working directory, as these files have already been at least partially included by the user. A new option has been added in the options dialog (gui.partialinclude) which lets the user enable accessing the index from git-gui. This just disables the automatic update_index pass on partially included files. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Shawn O. Pearce committed Nov 13, 2006 at 04:22 UTC f7f8d32226595c22cb4f28f8e9e139cf42e1e640
1 file changed +25 -11
git-gui
+25 -11
@@ -406,19 +406,33 @@ proc read_ls_others {fd final} {
406
407 proc status_eof {fd buf final} {
408 global status_active ui_status_value
409 + global file_states repo_config
410 upvar $buf to_clear
411
411 - if {[eof $fd]} {
412 - set to_clear {}
413 - close $fd
412 + if {![eof $fd]} return
413 + set to_clear {}
414 + close $fd
415 + if {[incr status_active -1] > 0} return
416
415 - if {[incr status_active -1] == 0} {
416 - display_all_files
417 - unlock_index
418 - reshow_diff
419 - set ui_status_value $final
417 + unlock_index
418 + display_all_files
419 +
420 + if {$repo_config(gui.partialinclude) ne {true}} {
421 + set pathList [list]
422 + foreach path [array names file_states] {
423 + switch -- [lindex $file_states($path) 0] {
424 + AM -
425 + MM {lappend pathList $path}
426 + }
427 + }
428 + if {$pathList ne {}} {
429 + update_index $pathList
430 + return
431 }
432 }
433 +
434 + reshow_diff
435 + set ui_status_value $final
436 }
437
438 ######################################################################
@@ -1164,7 +1178,6 @@ proc update_index {pathList} {
1178 set batch [expr {int($totalCnt * .01) + 1}]
1179 if {$batch > 25} {set batch 25}
1180
1167 - set ui_status_value "Including files ... 0/$totalCnt 0%"
1181 set ui_status_value [format \
1182 "Including files ... %i/%i files (%.2f%%)" \
1183 $update_index_cp \
@@ -1192,10 +1205,9 @@ proc write_update_index {fd pathList totalCnt batch} {
1205 if {$update_index_cp >= $totalCnt} {
1206 close $fd
1207 unlock_index
1208 + set ui_status_value {Ready.}
1209 if {$update_index_rsd} {
1210 reshow_diff
1197 - } else {
1198 - set ui_status_value {Ready.}
1211 }
1212 return
1213 }
@@ -1823,6 +1835,7 @@ proc do_options {} {
1835 pack $w.global -side right -fill both -expand 1 -pady 5 -padx 5
1836
1837 foreach option {
1838 + {b partialinclude {Allow Partially Included Files}}
1839 {b pullsummary {Show Pull Summary}}
1840 {b trustmtime {Trust File Modification Timestamps}}
1841 {i diffcontext {Number of Diff Context Lines}}
@@ -2000,6 +2013,7 @@ proc apply_config {} {
2013
2014 set default_config(gui.trustmtime) false
2015 set default_config(gui.pullsummary) true
2016 +set default_config(gui.partialinclude) false
2017 set default_config(gui.diffcontext) 5
2018 set default_config(gui.fontui) [font configure font_ui]
2019 set default_config(gui.fontdiff) [font configure font_diff]