git-gui: Convert UI to use 'staged for commit' interface.
This is a rather drastic change to the git-gui user interface, but it doesn't really look any different yet. I've taken the two lists and converted them to being "changes to be committed" and "changed but not updated". These lists correspond to the same lists output by git-runstatus based on how files differ in the HEAD<->index and the index<->working directory comparsions it performs. This change is meant to correlate with the change in Git 1.5.0 where we have brought the index more into the foreground and are trying to teach users to make use of it as part of their daily operations. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Shawn O. Pearce committed
Jan 20, 2007 at 22:45 UTC
21e409ad7f85b0557b0baa6d32f9b2064c7aa633
1 file changed
+101
-113
git-gui.sh
+101
-113
@@ -610,16 +610,7 @@ files list, to prevent possible confusion.
610
}
611
612
clear_diff
613
- set old_w [mapcol [lindex $file_states($path) 0] $path]
614
- set lno [lsearch -sorted $file_lists($old_w) $path]
615
- if {$lno >= 0} {
616
- set file_lists($old_w) \
617
- [lreplace $file_lists($old_w) $lno $lno]
618
- incr lno
619
- $old_w conf -state normal
620
- $old_w delete $lno.0 [expr {$lno + 1}].0
621
- $old_w conf -state disabled
622
- }
613
+ display_file $path __
614
}
615
616
proc show_diff {path {w {}} {lno {}}} {
@@ -1230,21 +1221,11 @@ proc push_to {remote} {
1221
##
1222
## ui helpers
1223
1233
-proc mapcol {state path} {
1234
- global all_cols ui_workdir
1235
-
1236
- if {[catch {set r $all_cols($state)}]} {
1237
- puts "error: no column for state={$state} $path"
1238
- return $ui_workdir
1239
- }
1240
- return $r
1241
-}
1242
-
1243
-proc mapicon {state path} {
1224
+proc mapicon {w state path} {
1225
global all_icons
1226
1246
- if {[catch {set r $all_icons($state)}]} {
1247
- puts "error: no icon for state={$state} $path"
1227
+ if {[catch {set r $all_icons($state$w)}]} {
1228
+ puts "error: no icon for $w state={$state} $path"
1229
return file_plain
1230
}
1231
return $r
@@ -1307,64 +1288,69 @@ proc merge_state {path new_state {head_info {}} {index_info {}}} {
1288
return $state
1289
}
1290
1291
+proc display_file_helper {w path icon_name old_m new_m} {
1292
+ global file_lists
1293
+
1294
+ if {$new_m eq {_}} {
1295
+ set lno [lsearch -sorted $file_lists($w) $path]
1296
+ if {$lno >= 0} {
1297
+ set file_lists($w) [lreplace $file_lists($w) $lno $lno]
1298
+ incr lno
1299
+ $w conf -state normal
1300
+ $w delete $lno.0 [expr {$lno + 1}].0
1301
+ $w conf -state disabled
1302
+ }
1303
+ } elseif {$old_m eq {_} && $new_m ne {_}} {
1304
+ lappend file_lists($w) $path
1305
+ set file_lists($w) [lsort -unique $file_lists($w)]
1306
+ set lno [lsearch -sorted $file_lists($w) $path]
1307
+ incr lno
1308
+ $w conf -state normal
1309
+ $w image create $lno.0 \
1310
+ -align center -padx 5 -pady 1 \
1311
+ -name $icon_name \
1312
+ -image [mapicon $w $new_m $path]
1313
+ $w insert $lno.1 "[escape_path $path]\n"
1314
+ $w conf -state disabled
1315
+ } elseif {$old_m ne $new_m} {
1316
+ $w conf -state normal
1317
+ $w image conf $icon_name -image [mapicon $w $new_m $path]
1318
+ $w conf -state disabled
1319
+ }
1320
+}
1321
+
1322
proc display_file {path state} {
1311
- global file_states file_lists selected_paths
1323
+ global file_states selected_paths
1324
+ global ui_index ui_workdir
1325
1326
set old_m [merge_state $path $state]
1327
set s $file_states($path)
1328
set new_m [lindex $s 0]
1316
- set new_w [mapcol $new_m $path]
1317
- set old_w [mapcol $old_m $path]
1318
- set new_icon [mapicon $new_m $path]
1329
+ set icon_name [lindex $s 1]
1330
+
1331
+ display_file_helper $ui_index $path $icon_name \
1332
+ [string index $old_m 0] \
1333
+ [string index $new_m 0]
1334
+ display_file_helper $ui_workdir $path $icon_name \
1335
+ [string index $old_m 1] \
1336
+ [string index $new_m 1]
1337
1338
if {$new_m eq {__}} {
1321
- set lno [lsearch -sorted $file_lists($old_w) $path]
1322
- if {$lno >= 0} {
1323
- set file_lists($old_w) \
1324
- [lreplace $file_lists($old_w) $lno $lno]
1325
- incr lno
1326
- $old_w conf -state normal
1327
- $old_w delete $lno.0 [expr {$lno + 1}].0
1328
- $old_w conf -state disabled
1329
- }
1339
unset file_states($path)
1340
catch {unset selected_paths($path)}
1332
- return
1341
}
1342
+}
1343
1335
- if {$new_w ne $old_w} {
1336
- set lno [lsearch -sorted $file_lists($old_w) $path]
1337
- if {$lno >= 0} {
1338
- set file_lists($old_w) \
1339
- [lreplace $file_lists($old_w) $lno $lno]
1340
- incr lno
1341
- $old_w conf -state normal
1342
- $old_w delete $lno.0 [expr {$lno + 1}].0
1343
- $old_w conf -state disabled
1344
- }
1344
+proc display_all_files_helper {w path icon_name m} {
1345
+ global file_lists
1346
1346
- lappend file_lists($new_w) $path
1347
- set file_lists($new_w) [lsort $file_lists($new_w)]
1348
- set lno [lsearch -sorted $file_lists($new_w) $path]
1349
- incr lno
1350
- $new_w conf -state normal
1351
- $new_w image create $lno.0 \
1352
- -align center -padx 5 -pady 1 \
1353
- -name [lindex $s 1] \
1354
- -image $new_icon
1355
- $new_w insert $lno.1 "[escape_path $path]\n"
1356
- if {[catch {set in_sel $selected_paths($path)}]} {
1357
- set in_sel 0
1358
- }
1359
- if {$in_sel} {
1360
- $new_w tag add in_sel $lno.0 [expr {$lno + 1}].0
1361
- }
1362
- $new_w conf -state disabled
1363
- } elseif {$new_icon ne [mapicon $old_m $path]} {
1364
- $new_w conf -state normal
1365
- $new_w image conf [lindex $s 1] -image $new_icon
1366
- $new_w conf -state disabled
1367
- }
1347
+ lappend file_lists($w) $path
1348
+ set lno [expr {[lindex [split [$w index end] .] 0] - 1}]
1349
+ $w image create end \
1350
+ -align center -padx 5 -pady 1 \
1351
+ -name $icon_name \
1352
+ -image [mapicon $w $m $path]
1353
+ $w insert end "[escape_path $path]\n"
1354
}
1355
1356
proc display_all_files {} {
@@ -1385,19 +1371,15 @@ proc display_all_files {} {
1371
foreach path [lsort [array names file_states]] {
1372
set s $file_states($path)
1373
set m [lindex $s 0]
1388
- set w [mapcol $m $path]
1389
- lappend file_lists($w) $path
1390
- set lno [expr {[lindex [split [$w index end] .] 0] - 1}]
1391
- $w image create end \
1392
- -align center -padx 5 -pady 1 \
1393
- -name [lindex $s 1] \
1394
- -image [mapicon $m $path]
1395
- $w insert end "[escape_path $path]\n"
1396
- if {[catch {set in_sel $selected_paths($path)}]} {
1397
- set in_sel 0
1374
+ set icon_name [lindex $s 1]
1375
+
1376
+ if {[string index $m 0] ne {_}} {
1377
+ display_all_files_helper $ui_index $path \
1378
+ $icon_name [string index $m 0]
1379
}
1399
- if {$in_sel} {
1400
- $w tag add in_sel $lno.0 [expr {$lno + 1}].0
1380
+ if {[string index $m 1] ne {_}} {
1381
+ display_all_files_helper $ui_workdir $path \
1382
+ $icon_name [string index $m 1]
1383
}
1384
}
1385
@@ -1961,41 +1943,47 @@ static unsigned char file_merge_bits[] = {
1943
1944
set ui_index .vpane.files.index.list
1945
set ui_workdir .vpane.files.workdir.list
1946
+
1947
+set all_icons(_$ui_index) file_plain
1948
+set all_icons(A$ui_index) file_fulltick
1949
+set all_icons(M$ui_index) file_fulltick
1950
+set all_icons(D$ui_index) file_removed
1951
+set all_icons(U$ui_index) file_merge
1952
+
1953
+set all_icons(_$ui_workdir) file_plain
1954
+set all_icons(M$ui_workdir) file_mod
1955
+set all_icons(D$ui_workdir) file_question
1956
+set all_icons(O$ui_workdir) file_plain
1957
+
1958
set max_status_desc 0
1959
foreach i {
1966
- {__ i plain "Unmodified"}
1967
- {_M i mod "Modified"}
1968
- {M_ i fulltick "Added to commit"}
1969
- {MM i parttick "Partially included"}
1970
- {MD i question "Added (but gone)"}
1971
-
1972
- {_O o plain "Untracked"}
1973
- {A_ o fulltick "Added by commit"}
1974
- {AM o parttick "Partially added"}
1975
- {AD o question "Added (but gone)"}
1976
-
1977
- {_D i question "Missing"}
1978
- {DD i removed "Removed by commit"}
1979
- {D_ i removed "Removed by commit"}
1980
- {DO i removed "Removed (still exists)"}
1981
- {DM i removed "Removed (but modified)"}
1982
-
1983
- {UD i merge "Merge conflicts"}
1984
- {UM i merge "Merge conflicts"}
1985
- {U_ i merge "Merge conflicts"}
1960
+ {__ "Unmodified"}
1961
+ {_M "Modified"}
1962
+ {M_ "Added to commit"}
1963
+ {MM "Partially added"}
1964
+ {MD "Added (but gone)"}
1965
+
1966
+ {_O "Untracked"}
1967
+ {A_ "Added by commit"}
1968
+ {AM "Partially added"}
1969
+ {AD "Added (but gone)"}
1970
+
1971
+ {_D "Missing"}
1972
+ {DD "Removed by commit"}
1973
+ {D_ "Removed by commit"}
1974
+ {DO "Removed (still exists)"}
1975
+ {DM "Removed (but modified)"}
1976
+
1977
+ {UD "Merge conflicts"}
1978
+ {UM "Merge conflicts"}
1979
+ {U_ "Merge conflicts"}
1980
} {
1987
- if {$max_status_desc < [string length [lindex $i 3]]} {
1988
- set max_status_desc [string length [lindex $i 3]]
1981
+ if {$max_status_desc < [string length [lindex $i 1]]} {
1982
+ set max_status_desc [string length [lindex $i 1]]
1983
}
1990
- if {[lindex $i 1] eq {i}} {
1991
- set all_cols([lindex $i 0]) $ui_index
1992
- } else {
1993
- set all_cols([lindex $i 0]) $ui_workdir
1994
- }
1995
- set all_icons([lindex $i 0]) file_[lindex $i 2]
1996
- set all_descs([lindex $i 0]) [lindex $i 3]
1984
+ set all_descs([lindex $i 0]) [lindex $i 1]
1985
}
1998
-unset filemask i
1986
+unset i
1987
1988
######################################################################
1989
##
@@ -3302,7 +3290,7 @@ pack .vpane -anchor n -side top -fill both -expand 1
3290
# -- Index File List
3291
#
3292
frame .vpane.files.index -height 100 -width 400
3305
-label .vpane.files.index.title -text {Modified Files} \
3293
+label .vpane.files.index.title -text {Changes To Be Committed} \
3294
-background green \
3295
-font font_ui
3296
text $ui_index -background white -borderwidth 0 \
@@ -3320,7 +3308,7 @@ pack $ui_index -side left -fill both -expand 1
3308
# -- Working Directory File List
3309
#
3310
frame .vpane.files.workdir -height 100 -width 100
3323
-label .vpane.files.workdir.title -text {Untracked Files} \
3311
+label .vpane.files.workdir.title -text {Changed But Not Updated} \
3312
-background red \
3313
-font font_ui
3314
text $ui_workdir -background white -borderwidth 0 \