@@ -261,8 +261,14 @@ unset -nocomplain v _junk act_maj act_min req_maj req_min
261
261
# #
262
262
# # repository setup
263
263
264
- if { [catch {set _gitdir $env(GIT_DIR) }]
265
- && [catch {set _gitdir [git rev-parse --git-dir]} err]} {
264
+ if {[catch {
265
+ set _gitdir $env(GIT_DIR)
266
+ set _prefix {}
267
+ }]
268
+ && [catch {
269
+ set _gitdir [git rev-parse --git-dir]
270
+ set _prefix [git rev-parse --show-prefix]
271
+ } err]} {
266
272
catch {wm withdraw .}
267
273
error_popup " Cannot find the git directory:\n\n $err "
268
274
exit 1
@@ -1288,7 +1294,7 @@ menu .mbar.repository
1288
1294
1289
1295
.mbar.repository add command \
1290
1296
-label {Browse Current Branch} \
1291
- -command {new_browser $current_branch }
1297
+ -command {browser::new $current_branch }
1292
1298
trace add variable current_branch write " .mbar.repository entryconf [ .mbar.repository index last] -label \" Browse \$ current_branch\" ;#"
1293
1299
.mbar.repository add separator
1294
1300
@@ -1572,25 +1578,67 @@ bind all <$M1B-Key-Q> do_quit
1572
1578
bind all <$M1B -Key-w> {destroy [winfo toplevel %W]}
1573
1579
bind all <$M1B -Key-W> {destroy [winfo toplevel %W]}
1574
1580
1581
+ set subcommand_args {}
1582
+ proc usage {} {
1583
+ puts stderr " usage: $::argv0 $::subcommand $::subcommand_args "
1584
+ exit 1
1585
+ }
1586
+
1575
1587
# -- Not a normal commit type invocation? Do that instead!
1576
1588
#
1577
1589
switch -- $subcommand {
1578
1590
browser {
1579
- if {[llength $argv ] != 1} {
1580
- puts stderr " usage: $argv0 browser commit"
1581
- exit 1
1591
+ set subcommand_args {rev?}
1592
+ switch [llength $argv ] {
1593
+ 0 {
1594
+ set current_branch [git symbolic-ref HEAD]
1595
+ regsub ^refs/((heads|tags|remotes)/)? \
1596
+ $current_branch {} current_branch
1597
+ }
1598
+ 1 {
1599
+ set current_branch [lindex $argv 0]
1582
1600
}
1583
- set current_branch [lindex $argv 0]
1584
- new_browser $current_branch
1601
+ default usage
1602
+ }
1603
+ browser::new $current_branch
1585
1604
return
1586
1605
}
1587
1606
blame {
1588
- if {[llength $argv ] != 2} {
1589
- puts stderr " usage: $argv0 blame commit path"
1590
- exit 1
1607
+ set subcommand_args {rev? path?}
1608
+ set head {}
1609
+ set path {}
1610
+ set is_path 0
1611
+ foreach a $argv {
1612
+ if {$is_path || [file exists $_prefix$a ]} {
1613
+ if {$path ne {}} usage
1614
+ set path $_prefix$a
1615
+ break
1616
+ } elseif {$a eq {--}} {
1617
+ if {$path ne {}} {
1618
+ if {$head ne {}} usage
1619
+ set head $path
1620
+ set path {}
1621
+ }
1622
+ set is_path 1
1623
+ } elseif {$head eq {}} {
1624
+ if {$head ne {}} usage
1625
+ set head $a
1626
+ } else {
1627
+ usage
1628
+ }
1629
+ }
1630
+ unset is_path
1631
+
1632
+ if {$head eq {}} {
1633
+ set current_branch [git symbolic-ref HEAD]
1634
+ regsub ^refs/((heads|tags|remotes)/)? \
1635
+ $current_branch {} current_branch
1636
+ } else {
1637
+ set current_branch $head
1591
1638
}
1592
- set current_branch [lindex $argv 0]
1593
- show_blame $current_branch [lindex $argv 1]
1639
+
1640
+ if {$path eq {}} usage
1641
+ blame::new $head $path
1594
1642
return
1595
1643
}
1596
1644
citool -
@@ -1638,7 +1686,7 @@ pack .vpane -anchor n -side top -fill both -expand 1
1638
1686
# -- Index File List
1639
1687
#
1640
1688
frame .vpane.files.index -height 100 -width 200
1641
- label .vpane.files.index.title -text {Changes To Be Committed} \
1689
+ label .vpane.files.index.title -text {Staged Changes (Will Be Committed) } \
1642
1690
-background green
1643
1691
text $ui_index -background white -borderwidth 0 \
1644
1692
-width 20 -height 10 \
@@ -1658,7 +1706,7 @@ pack $ui_index -side left -fill both -expand 1
1658
1706
# -- Working Directory File List
1659
1707
#
1660
1708
frame .vpane.files.workdir -height 100 -width 200
1661
- label .vpane.files.workdir.title -text {Changed But Not Updated } \
1709
+ label .vpane.files.workdir.title -text {Unstaged Changes (Will Not Be Committed) } \
1662
1710
-background red
1663
1711
text $ui_workdir -background white -borderwidth 0 \
1664
1712
-width 20 -height 10 \
0 commit comments