@matheusbsbs / matheus-bagliano / commits / b676511298
Fork 0

git-gui: Refactor file state representations.

It just felt wrong to me that I was using _ as part of the mode argument to display_file to mean "don't care/use existing" and * as part of the mode argument to mean "force to _". So instead use ? to mean "don't care/use existing" and _ to mean "force to _". The code is a lot clearer this way and hopefully it won't drive another developer insane, as it did me. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Shawn O. Pearce committed Nov 18, 2006 at 03:08 UTC b67651129897738496a9dcd3c01129a42acd11db
1 file changed +10 -10
git-gui
+10 -10
@@ -378,7 +378,7 @@ proc read_diff_index {fd after} {
378 incr z2 -1
379 display_file \
380 [string range $buf_rdi $z1 $z2] \
381 - [string index $buf_rdi [expr {$z1 - 2}]]_
381 + [string index $buf_rdi [expr {$z1 - 2}]]?
382 incr c
383 }
384 if {$c < $n} {
@@ -407,7 +407,7 @@ proc read_diff_files {fd after} {
407 incr z2 -1
408 display_file \
409 [string range $buf_rdf $z1 $z2] \
410 - _[string index $buf_rdf [expr {$z1 - 2}]]
410 + ?[string index $buf_rdf [expr {$z1 - 2}]]
411 incr c
412 }
413 if {$c < $n} {
@@ -426,7 +426,7 @@ proc read_ls_others {fd after} {
426 set pck [split $buf_rlo "\0"]
427 set buf_rlo [lindex $pck end]
428 foreach p [lrange $pck 0 end-1] {
429 - display_file $p _O
429 + display_file $p ?O
430 }
431 rescan_done $fd buf_rlo $after
432 }
@@ -1151,15 +1151,15 @@ proc merge_state {path new_state} {
1151 set icon [lindex $info 1]
1152 }
1153
1154 - if {$s0 eq {_}} {
1154 + if {$s0 eq {?}} {
1155 set s0 [string index $state 0]
1156 - } elseif {$s0 eq {*}} {
1156 + } elseif {$s0 eq {_}} {
1157 set s0 _
1158 }
1159
1160 - if {$s1 eq {_}} {
1160 + if {$s1 eq {?}} {
1161 set s1 [string index $state 1]
1162 - } elseif {$s1 eq {*}} {
1162 + } elseif {$s1 eq {_}} {
1163 set s1 _
1164 }
1165
@@ -1303,15 +1303,15 @@ proc write_update_index {fd pathList totalCnt batch msg after} {
1303 switch -glob -- [lindex $file_states($path) 0] {
1304 AD -
1305 MD -
1306 - _D {set new D*}
1306 + _D {set new D_}
1307
1308 _M -
1309 MM -
1310 - M_ {set new M*}
1310 + M_ {set new M_}
1311
1312 _O -
1313 AM -
1314 - A_ {set new A*}
1314 + A_ {set new A_}
1315
1316 ?? {continue}
1317 }