1 # git-gui revision chooser
2 # Copyright (C) 2006, 2007 Shawn Pearce
6 field w
; # our megawidget path
7 field revtype
{}; # type of revision chosen
9 field c_head
{}; # selected local branch head
10 field c_trck
{}; # selected tracking branch
11 field c_tag
{}; # selected tag
12 field c_expr
{}; # current revision expression
14 constructor new
{path
{title
{}}} {
15 global all_heads current_branch
20 labelframe $w -text $title
24 bind $w <Destroy
> [cb _delete
%W
]
26 if {$all_heads ne
{}} {
27 set c_head
$current_branch
28 radiobutton $w.head_r
\
29 -text {Local Branch
:} \
32 eval tk_optionMenu $w.head_m
@c_head
$all_heads
33 grid $w.head_r
$w.head_m
-sticky w
37 trace add
variable @c_head write
[cb _select head
]
40 set all_trackings
[all_tracking_branches
]
41 if {$all_trackings ne
{}} {
42 set c_trck
[lindex $all_trackings 0]
43 radiobutton $w.trck_r
\
44 -text {Tracking Branch
:} \
47 eval tk_optionMenu $w.trck_m
@c_trck
$all_trackings
48 grid $w.trck_r
$w.trck_m
-sticky w
52 trace add
variable @c_trck write
[cb _select trck
]
55 set all_tags
[load_all_tags
]
56 if {$all_tags ne
{}} {
57 set c_tag
[lindex $all_tags 0]
58 radiobutton $w.tag_r
\
62 eval tk_optionMenu $w.tag_m
@c_tag
$all_tags
63 grid $w.tag_r
$w.tag_m
-sticky w
67 trace add
variable @c_tag write
[cb _select tag
]
70 radiobutton $w.expr_r
\
71 -text {Revision Expression
:} \
78 -textvariable @c_expr
\
80 -validatecommand [cb _validate
%d
%S
]
81 grid $w.expr_r
$w.expr_t
-sticky we
-padx {0 5}
86 grid columnconfigure
$w 1 -weight 1
92 head
{ return $c_head }
93 trck
{ return $c_trck }
95 expr { return $c_expr }
96 default { error "unknown type of revision" }
100 method get_commit
{} {
102 return [git rev-parse
--verify "${rev}^0"]
105 method _validate
{d S
} {
107 if {[regexp {\s
} $S]} {
110 if {[string length
$S] > 0} {
117 method _select
{value args
} {
121 method _delete
{current
} {
122 if {$current eq
$w} {