]> asedeno.scripts.mit.edu Git - git.git/commitdiff
git-gui: By default don't allow partially included files.
authorShawn O. Pearce <spearce@spearce.org>
Mon, 13 Nov 2006 09:22:42 +0000 (04:22 -0500)
committerShawn O. Pearce <spearce@spearce.org>
Mon, 13 Nov 2006 09:22:42 +0000 (04:22 -0500)
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>
git-gui

diff --git a/git-gui b/git-gui
index ca7f8dbc414b365a70489a5323f6e9ee440eb5c5..3e3a535326d21af3923de6d916f9ec8527230d07 100755 (executable)
--- a/git-gui
+++ b/git-gui
@@ -406,19 +406,33 @@ proc read_ls_others {fd final} {
 
 proc status_eof {fd buf final} {
        global status_active ui_status_value
+       global file_states repo_config
        upvar $buf to_clear
 
-       if {[eof $fd]} {
-               set to_clear {}
-               close $fd
+       if {![eof $fd]} return
+       set to_clear {}
+       close $fd
+       if {[incr status_active -1] > 0} return
 
-               if {[incr status_active -1] == 0} {
-                       display_all_files
-                       unlock_index
-                       reshow_diff
-                       set ui_status_value $final
+       unlock_index
+       display_all_files
+
+       if {$repo_config(gui.partialinclude) ne {true}} {
+               set pathList  [list]
+               foreach path [array names file_states] {
+                       switch -- [lindex $file_states($path) 0] {
+                       AM -
+                       MM {lappend pathList $path}
+                       }
+               }
+               if {$pathList ne {}} {
+                       update_index $pathList
+                       return
                }
        }
+
+       reshow_diff
+       set ui_status_value $final
 }
 
 ######################################################################
@@ -1164,7 +1178,6 @@ proc update_index {pathList} {
        set batch [expr {int($totalCnt * .01) + 1}]
        if {$batch > 25} {set batch 25}
 
-       set ui_status_value "Including files ... 0/$totalCnt 0%"
        set ui_status_value [format \
                "Including files ... %i/%i files (%.2f%%)" \
                $update_index_cp \
@@ -1192,10 +1205,9 @@ proc write_update_index {fd pathList totalCnt batch} {
        if {$update_index_cp >= $totalCnt} {
                close $fd
                unlock_index
+               set ui_status_value {Ready.}
                if {$update_index_rsd} {
                        reshow_diff
-               } else {
-                       set ui_status_value {Ready.}
                }
                return
        }
@@ -1823,6 +1835,7 @@ proc do_options {} {
        pack $w.global -side right -fill both -expand 1 -pady 5 -padx 5
 
        foreach option {
+               {b partialinclude {Allow Partially Included Files}}
                {b pullsummary {Show Pull Summary}}
                {b trustmtime  {Trust File Modification Timestamps}}
                {i diffcontext {Number of Diff Context Lines}}
@@ -2000,6 +2013,7 @@ proc apply_config {} {
 
 set default_config(gui.trustmtime) false
 set default_config(gui.pullsummary) true
+set default_config(gui.partialinclude) false
 set default_config(gui.diffcontext) 5
 set default_config(gui.fontui) [font configure font_ui]
 set default_config(gui.fontdiff) [font configure font_diff]