git-gui: Refactor the add to commit state filters.
The list of states which are valid for update-index were a little too verbose and fed a few too many cases to the program. We can do better with less lines of code by using more pattern matching, and since we already were globbing here there's little change in runtime cost. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
This commit is contained in:
parent
7d40edfa06
commit
b4b491e388
50
git-gui.sh
50
git-gui.sh
@ -1512,26 +1512,15 @@ proc write_update_index {fd pathList totalCnt batch msg after} {
|
|||||||
incr update_index_cp
|
incr update_index_cp
|
||||||
|
|
||||||
switch -glob -- [lindex $file_states($path) 0] {
|
switch -glob -- [lindex $file_states($path) 0] {
|
||||||
AD -
|
AD {set new __}
|
||||||
MD -
|
?D {set new D_}
|
||||||
UD -
|
|
||||||
_D {set new D_}
|
|
||||||
|
|
||||||
_M -
|
|
||||||
MM -
|
|
||||||
UM -
|
|
||||||
U_ -
|
|
||||||
M_ {set new M_}
|
|
||||||
|
|
||||||
_O -
|
_O -
|
||||||
AM -
|
AM {set new A_}
|
||||||
A_ {set new A_}
|
U_ -
|
||||||
|
?M {set new M_}
|
||||||
?? {continue}
|
?? {continue}
|
||||||
}
|
}
|
||||||
|
puts -nonewline $fd "$path\0"
|
||||||
puts -nonewline $fd $path
|
|
||||||
puts -nonewline $fd "\0"
|
|
||||||
display_file $path $new
|
display_file $path $new
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2333,14 +2322,10 @@ proc add_helper {txt paths} {
|
|||||||
set after {}
|
set after {}
|
||||||
foreach path $paths {
|
foreach path $paths {
|
||||||
switch -glob -- [lindex $file_states($path) 0] {
|
switch -glob -- [lindex $file_states($path) 0] {
|
||||||
AM -
|
_O -
|
||||||
AD -
|
?M -
|
||||||
MM -
|
?D -
|
||||||
MD -
|
U? {
|
||||||
U? -
|
|
||||||
_M -
|
|
||||||
_D -
|
|
||||||
_O {
|
|
||||||
lappend pathList $path
|
lappend pathList $path
|
||||||
if {$path eq $current_diff} {
|
if {$path eq $current_diff} {
|
||||||
set after {reshow_diff;}
|
set after {reshow_diff;}
|
||||||
@ -2377,18 +2362,13 @@ proc do_add_all {} {
|
|||||||
|
|
||||||
set paths [list]
|
set paths [list]
|
||||||
foreach path [array names file_states] {
|
foreach path [array names file_states] {
|
||||||
switch -- [lindex $file_states($path) 0] {
|
switch -glob -- [lindex $file_states($path) 0] {
|
||||||
AM -
|
U? {continue}
|
||||||
AD -
|
?M -
|
||||||
MM -
|
?D {lappend paths $path}
|
||||||
MD -
|
|
||||||
_M -
|
|
||||||
_D {lappend paths $path}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
add_helper \
|
add_helper {Adding all changed files} $paths
|
||||||
{Adding all modified files} \
|
|
||||||
$paths
|
|
||||||
}
|
}
|
||||||
|
|
||||||
proc revert_helper {txt paths} {
|
proc revert_helper {txt paths} {
|
||||||
|
Loading…
Reference in New Issue
Block a user