@matheusbsbs / matheus-bagliano / commits / 7d40edfa06
Fork 0

git-gui: Refactor the revert (aka checkout-index) implementation.

We can revert any file which has a valid stage 0 (is not unmerged) and which is has a working directory status of M or D. This vastly simplifies our pattern matching on file status when building up the list of files to perform a checkout-index against. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Shawn O. Pearce committed Jan 20, 2007 at 23:20 UTC 7d40edfa06adf7f31f787bb6379c1eb454242c19
1 file changed +9 -18
git-gui.sh
+9 -18
@@ -1597,20 +1597,14 @@ proc write_checkout_index {fd pathList totalCnt batch msg after} {
1597 {incr i -1} {
1598 set path [lindex $pathList $update_index_cp]
1599 incr update_index_cp
1600 -
1600 switch -glob -- [lindex $file_states($path) 0] {
1602 - AM -
1603 - AD {set new A_}
1604 - MM -
1605 - MD {set new M_}
1606 - _M -
1607 - _D {set new __}
1608 - ?? {continue}
1601 + U? {continue}
1602 + ?M -
1603 + ?D {
1604 + puts -nonewline $fd "$path\0"
1605 + display_file $path ?_
1606 + }
1607 }
1610 -
1611 - puts -nonewline $fd $path
1612 - puts -nonewline $fd "\0"
1613 - display_file $path $new
1608 }
1609
1610 set ui_status_value [format \
@@ -2406,12 +2400,9 @@ proc revert_helper {txt paths} {
2400 set after {}
2401 foreach path $paths {
2402 switch -glob -- [lindex $file_states($path) 0] {
2409 - AM -
2410 - AD -
2411 - MM -
2412 - MD -
2413 - _M -
2414 - _D {
2403 + U? {continue}
2404 + ?M -
2405 + ?D {
2406 lappend pathList $path
2407 if {$path eq $current_diff} {
2408 set after {reshow_diff;}