summaryrefslogtreecommitdiff
path: root/git-gui.sh
diff options
context:
space:
mode:
authorLibravatar Shawn O. Pearce <spearce@spearce.org>2007-01-20 23:33:34 -0500
committerLibravatar Shawn O. Pearce <spearce@spearce.org>2007-01-21 02:54:24 -0500
commitb4b491e388627b75ed3aee5dc60e4199eae7b362 (patch)
treeee25e66c96e35d577a99417302bf188b17de6572 /git-gui.sh
parentgit-gui: Refactor the revert (aka checkout-index) implementation. (diff)
downloadtgif-b4b491e388627b75ed3aee5dc60e4199eae7b362.tar.xz
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>
Diffstat (limited to 'git-gui.sh')
-rwxr-xr-xgit-gui.sh50
1 files changed, 15 insertions, 35 deletions
diff --git a/git-gui.sh b/git-gui.sh
index 7bd2b87fe3..954b1983e8 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -1512,26 +1512,15 @@ proc write_update_index {fd pathList totalCnt batch msg after} {
incr update_index_cp
switch -glob -- [lindex $file_states($path) 0] {
- AD -
- MD -
- UD -
- _D {set new D_}
-
- _M -
- MM -
- UM -
- U_ -
- M_ {set new M_}
-
+ AD {set new __}
+ ?D {set new D_}
_O -
- AM -
- A_ {set new A_}
-
+ AM {set new A_}
+ U_ -
+ ?M {set new M_}
?? {continue}
}
-
- puts -nonewline $fd $path
- puts -nonewline $fd "\0"
+ puts -nonewline $fd "$path\0"
display_file $path $new
}
@@ -2333,14 +2322,10 @@ proc add_helper {txt paths} {
set after {}
foreach path $paths {
switch -glob -- [lindex $file_states($path) 0] {
- AM -
- AD -
- MM -
- MD -
- U? -
- _M -
- _D -
- _O {
+ _O -
+ ?M -
+ ?D -
+ U? {
lappend pathList $path
if {$path eq $current_diff} {
set after {reshow_diff;}
@@ -2377,18 +2362,13 @@ proc do_add_all {} {
set paths [list]
foreach path [array names file_states] {
- switch -- [lindex $file_states($path) 0] {
- AM -
- AD -
- MM -
- MD -
- _M -
- _D {lappend paths $path}
+ switch -glob -- [lindex $file_states($path) 0] {
+ U? {continue}
+ ?M -
+ ?D {lappend paths $path}
}
}
- add_helper \
- {Adding all modified files} \
- $paths
+ add_helper {Adding all changed files} $paths
}
proc revert_helper {txt paths} {