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>maint
parent
df75e86d73
commit
39816d60e1
21
gitk
21
gitk
|
@ -418,10 +418,12 @@ proc stop_rev_list {view} {
|
||||||
}
|
}
|
||||||
|
|
||||||
proc reset_pending_select {selid} {
|
proc reset_pending_select {selid} {
|
||||||
global pending_select mainheadid
|
global pending_select mainheadid selectheadid
|
||||||
|
|
||||||
if {$selid ne {}} {
|
if {$selid ne {}} {
|
||||||
set pending_select $selid
|
set pending_select $selid
|
||||||
|
} elseif {$selectheadid ne {}} {
|
||||||
|
set pending_select $selectheadid
|
||||||
} else {
|
} else {
|
||||||
set pending_select $mainheadid
|
set pending_select $mainheadid
|
||||||
}
|
}
|
||||||
|
@ -1609,6 +1611,7 @@ proc getcommit {id} {
|
||||||
proc readrefs {} {
|
proc readrefs {} {
|
||||||
global tagids idtags headids idheads tagobjid
|
global tagids idtags headids idheads tagobjid
|
||||||
global otherrefids idotherrefs mainhead mainheadid
|
global otherrefids idotherrefs mainhead mainheadid
|
||||||
|
global selecthead selectheadid
|
||||||
|
|
||||||
foreach v {tagids idtags headids idheads otherrefids idotherrefs} {
|
foreach v {tagids idtags headids idheads otherrefids idotherrefs} {
|
||||||
catch {unset $v}
|
catch {unset $v}
|
||||||
|
@ -1655,6 +1658,12 @@ proc readrefs {} {
|
||||||
set mainhead [string range $thehead 11 end]
|
set mainhead [string range $thehead 11 end]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
set selectheadid {}
|
||||||
|
if {$selecthead ne {}} {
|
||||||
|
catch {
|
||||||
|
set selectheadid [exec git rev-parse --verify $selecthead]
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# skip over fake commits
|
# skip over fake commits
|
||||||
|
@ -9865,6 +9874,9 @@ if {![file isdirectory $gitdir]} {
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
set selecthead {}
|
||||||
|
set selectheadid {}
|
||||||
|
|
||||||
set revtreeargs {}
|
set revtreeargs {}
|
||||||
set cmdline_files {}
|
set cmdline_files {}
|
||||||
set i 0
|
set i 0
|
||||||
|
@ -9876,6 +9888,9 @@ foreach arg $argv {
|
||||||
set cmdline_files [lrange $argv [expr {$i + 1}] end]
|
set cmdline_files [lrange $argv [expr {$i + 1}] end]
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
"--select-commit=*" {
|
||||||
|
set selecthead [string range $arg 16 end]
|
||||||
|
}
|
||||||
"--argscmd=*" {
|
"--argscmd=*" {
|
||||||
set revtreeargscmd [string range $arg 10 end]
|
set revtreeargscmd [string range $arg 10 end]
|
||||||
}
|
}
|
||||||
|
@ -9886,6 +9901,10 @@ foreach arg $argv {
|
||||||
incr i
|
incr i
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if {$selecthead eq "HEAD"} {
|
||||||
|
set selecthead {}
|
||||||
|
}
|
||||||
|
|
||||||
if {$i >= [llength $argv] && $revtreeargs ne {}} {
|
if {$i >= [llength $argv] && $revtreeargs ne {}} {
|
||||||
# no -- on command line, but some arguments (other than --argscmd)
|
# no -- on command line, but some arguments (other than --argscmd)
|
||||||
if {[catch {
|
if {[catch {
|
||||||
|
|
Loading…
Reference in New Issue