@matheusbsbs / matheus-bagliano / commits / 39816d60e1
Fork 0

gitk: Add option to specify the default commit on command line

Other GUI tools may need to start gitk and make it automatically select a certain commit. This adds a new command-line option --select-commit=id to make that possible. Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com> Signed-off-by: Paul Mackerras <paulus@samba.org>

Alexander Gavrilov committed Aug 23, 2008 at 12:27 UTC 39816d60e14b4d3be6ab9cf55caf79d7596bdb29
1 file changed +20 -1
gitk
+20 -1
@@ -418,10 +418,12 @@ proc stop_rev_list {view} {
418 }
419
420 proc reset_pending_select {selid} {
421 - global pending_select mainheadid
421 + global pending_select mainheadid selectheadid
422
423 if {$selid ne {}} {
424 set pending_select $selid
425 + } elseif {$selectheadid ne {}} {
426 + set pending_select $selectheadid
427 } else {
428 set pending_select $mainheadid
429 }
@@ -1609,6 +1611,7 @@ proc getcommit {id} {
1611 proc readrefs {} {
1612 global tagids idtags headids idheads tagobjid
1613 global otherrefids idotherrefs mainhead mainheadid
1614 + global selecthead selectheadid
1615
1616 foreach v {tagids idtags headids idheads otherrefids idotherrefs} {
1617 catch {unset $v}
@@ -1655,6 +1658,12 @@ proc readrefs {} {
1658 set mainhead [string range $thehead 11 end]
1659 }
1660 }
1661 + set selectheadid {}
1662 + if {$selecthead ne {}} {
1663 + catch {
1664 + set selectheadid [exec git rev-parse --verify $selecthead]
1665 + }
1666 + }
1667 }
1668
1669 # skip over fake commits
@@ -9865,6 +9874,9 @@ if {![file isdirectory $gitdir]} {
9874 exit 1
9875 }
9876
9877 +set selecthead {}
9878 +set selectheadid {}
9879 +
9880 set revtreeargs {}
9881 set cmdline_files {}
9882 set i 0
@@ -9876,6 +9888,9 @@ foreach arg $argv {
9888 set cmdline_files [lrange $argv [expr {$i + 1}] end]
9889 break
9890 }
9891 + "--select-commit=*" {
9892 + set selecthead [string range $arg 16 end]
9893 + }
9894 "--argscmd=*" {
9895 set revtreeargscmd [string range $arg 10 end]
9896 }
@@ -9886,6 +9901,10 @@ foreach arg $argv {
9901 incr i
9902 }
9903
9904 +if {$selecthead eq "HEAD"} {
9905 + set selecthead {}
9906 +}
9907 +
9908 if {$i >= [llength $argv] && $revtreeargs ne {}} {
9909 # no -- on command line, but some arguments (other than --argscmd)
9910 if {[catch {