git-gui: Correct language for M_/A_ status codes.
[gitweb.git] / git-gui
diff --git a/git-gui b/git-gui
index fdb82812bd14304ae78ae5c66ef4f6572f509f4f..907db0e9dce005598c256366831558e378120274 100755 (executable)
--- a/git-gui
+++ b/git-gui
@@ -488,7 +488,7 @@ prevent possible confusion.
 
 proc show_diff {path {w {}} {lno {}}} {
        global file_states file_lists
-       global PARENT diff_3way diff_active
+       global PARENT diff_3way diff_active repo_config
        global ui_diff ui_fname_value ui_fstatus_value ui_status_value
 
        if {$diff_active || ![lock_index read]} return
@@ -511,14 +511,20 @@ proc show_diff {path {w {}} {lno {}}} {
        set m [lindex $s 0]
        set diff_3way 0
        set diff_active 1
-       set ui_fname_value [escape_path $path]
+       set ui_fname_value $path
        set ui_fstatus_value [mapdesc $m $path]
        set ui_status_value "Loading diff of [escape_path $path]..."
 
-       set cmd [list | git diff-index -p $PARENT -- $path]
+       set cmd [list | git diff-index]
+       lappend cmd --no-color
+       if {$repo_config(gui.diffcontext) > 0} {
+               lappend cmd "-U$repo_config(gui.diffcontext)"
+       }
+       lappend cmd -p
+
        switch $m {
        MM {
-               set cmd [list | git diff-index -p -c $PARENT $path]
+               lappend cmd -c
        }
        _O {
                if {[catch {
@@ -542,6 +548,10 @@ proc show_diff {path {w {}} {lno {}}} {
        }
        }
 
+       lappend cmd $PARENT
+       lappend cmd --
+       lappend cmd $path
+
        if {[catch {set fd [open $cmd r]} err]} {
                set diff_active 0
                unlock_index
@@ -1149,6 +1159,7 @@ proc update_index {pathList} {
 
        set update_index_cp 0
        set update_index_rsd 0
+       set pathList [lsort $pathList]
        set totalCnt [llength $pathList]
        set batch [expr {int($totalCnt * .01) + 1}]
        if {$batch > 25} {set batch 25}
@@ -1160,7 +1171,11 @@ proc update_index {pathList} {
                $totalCnt \
                0.0]
        set fd [open "| git update-index --add --remove -z --stdin" w]
-       fconfigure $fd -blocking 0 -translation binary
+       fconfigure $fd \
+               -blocking 0 \
+               -buffering full \
+               -buffersize 512 \
+               -translation binary
        fileevent $fd writable [list \
                write_update_index \
                $fd \
@@ -1178,7 +1193,7 @@ proc write_update_index {fd pathList totalCnt batch} {
                close $fd
                unlock_index
                if {$update_index_rsd} {
-                       show_diff $ui_fname_value
+                       reshow_diff
                } else {
                        set ui_status_value {Ready.}
                }
@@ -1370,17 +1385,17 @@ set max_status_desc 0
 foreach i {
                {__ i plain    "Unmodified"}
                {_M i mod      "Modified"}
-               {M_ i fulltick "Checked in"}
+               {M_ i fulltick "Included in commit"}
                {MM i parttick "Partially included"}
 
                {_O o plain    "Untracked"}
-               {A_ o fulltick "Added"}
+               {A_ o fulltick "Added by commit"}
                {AM o parttick "Partially added"}
                {AD o question "Added (but now gone)"}
 
                {_D i question "Missing"}
-               {D_ i removed  "Removed"}
-               {DD i removed  "Removed"}
+               {D_ i removed  "Removed by commit"}
+               {DD i removed  "Removed by commit"}
                {DO i removed  "Removed (still exists)"}
 
                {UM i merge    "Merge conflicts"}
@@ -1758,12 +1773,18 @@ proc do_options {} {
        global repo_config global_config
        global repo_config_new global_config_new
 
-       load_config 1
        array unset repo_config_new
        array unset global_config_new
        foreach name [array names repo_config] {
                set repo_config_new($name) $repo_config($name)
        }
+       load_config 1
+       foreach name [array names repo_config] {
+               switch -- $name {
+               gui.diffcontext {continue}
+               }
+               set repo_config_new($name) $repo_config($name)
+       }
        foreach name [array names global_config] {
                set global_config_new($name) $global_config($name)
        }
@@ -1804,18 +1825,36 @@ proc do_options {} {
        pack $w.global -side right -fill both -expand 1 -pady 5 -padx 5
 
        foreach option {
-               {pullsummary {Show Pull Summary}}
-               {trustmtime {Trust File Modification Timestamps}}
+               {b pullsummary {Show Pull Summary}}
+               {b trustmtime  {Trust File Modification Timestamps}}
+               {i diffcontext {Number of Diff Context Lines}}
                } {
-               set name [lindex $option 0]
-               set text [lindex $option 1]
+               set type [lindex $option 0]
+               set name [lindex $option 1]
+               set text [lindex $option 2]
                foreach f {repo global} {
-                       checkbutton $w.$f.$name -text $text \
-                               -variable ${f}_config_new(gui.$name) \
-                               -onvalue true \
-                               -offvalue false \
-                               -font font_ui
-                       pack $w.$f.$name -side top -anchor w
+                       switch $type {
+                       b {
+                               checkbutton $w.$f.$name -text $text \
+                                       -variable ${f}_config_new(gui.$name) \
+                                       -onvalue true \
+                                       -offvalue false \
+                                       -font font_ui
+                               pack $w.$f.$name -side top -anchor w
+                       }
+                       i {
+                               frame $w.$f.$name
+                               label $w.$f.$name.l -text "$text:" -font font_ui
+                               pack $w.$f.$name.l -side left -anchor w -fill x
+                               spinbox $w.$f.$name.v \
+                                       -textvariable ${f}_config_new(gui.$name) \
+                                       -from 1 -to 99 -increment 1 \
+                                       -width 3 \
+                                       -font font_ui
+                               pack $w.$f.$name.v -side right -anchor e
+                               pack $w.$f.$name -side top -anchor w -fill x
+                       }
+                       }
                }
        }
 
@@ -1881,6 +1920,7 @@ proc do_save_config {w} {
        if {[catch {save_config} err]} {
                error_popup "Failed to completely save options:\n\n$err"
        }
+       reshow_diff
        destroy $w
 }
 
@@ -1962,6 +2002,7 @@ proc apply_config {} {
 
 set default_config(gui.trustmtime) false
 set default_config(gui.pullsummary) true
+set default_config(gui.diffcontext) 5
 set default_config(gui.fontui) [font configure font_ui]
 set default_config(gui.fontdiff) [font configure font_diff]
 set font_descs {
@@ -2243,11 +2284,33 @@ frame .vpane.lower.diff.header -background orange
 label .vpane.lower.diff.header.l1 -text {File:} \
        -background orange \
        -font font_ui
-label .vpane.lower.diff.header.l2 -textvariable ui_fname_value \
+set ui_fname .vpane.lower.diff.header.l2
+text $ui_fname \
        -background orange \
-       -anchor w \
-       -justify left \
+       -height 1 \
+       -relief flat \
+       -state disabled \
        -font font_ui
+menu $ui_fname.ctxm -tearoff 0
+$ui_fname.ctxm add command -label "Copy Only Selection" \
+       -font font_ui \
+       -command "tk_textCopy $ui_fname"
+$ui_fname.ctxm add command -label "Copy Complete Name" \
+       -font font_ui \
+       -command "
+               $ui_fname tag add sel 0.0 {end -1c}
+               tk_textCopy $ui_fname
+               $ui_fname tag remove sel 0.0 end
+       "
+bind_button3 $ui_fname "tk_popup $ui_fname.ctxm %X %Y"
+trace add variable ui_fname_value write $ui_fname.update
+proc $ui_fname.update {varname args} {
+       global ui_fname ui_fname_value
+       $ui_fname configure -state normal
+       $ui_fname delete 0.0 end
+       $ui_fname insert end [escape_path $ui_fname_value]
+       $ui_fname configure -state disabled
+}
 label .vpane.lower.diff.header.l3 -text {Status:} \
        -background orange \
        -font font_ui
@@ -2311,6 +2374,21 @@ $ui_diff.ctxm add command -label "Decrease Font Size" \
 $ui_diff.ctxm add command -label "Increase Font Size" \
        -font font_ui \
        -command {incr_font_size font_diff 1}
+$ui_diff.ctxm add separator
+$ui_diff.ctxm add command -label "Show Less Context" \
+       -font font_ui \
+       -command {if {$ui_fname_value ne {}
+               && $repo_config(gui.diffcontext) >= 2} {
+               incr repo_config(gui.diffcontext) -1
+               reshow_diff
+       }}
+$ui_diff.ctxm add command -label "Show More Context" \
+       -font font_ui \
+       -command {if {$ui_fname_value ne {}} {
+               incr repo_config(gui.diffcontext)
+               reshow_diff
+       }}
+$ui_diff.ctxm add separator
 $ui_diff.ctxm add command -label {Options...} \
        -font font_ui \
        -command do_options