Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/git-gui/lib/branch_checkout.tcl # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / git-gui / lib / branch_checkout.tcl` 92 lines ยท 2215 bytes Raw Blame History 1 # git-gui branch checkout support 2 # Copyright (C) 2007 Shawn Pearce 3 4 class branch_checkout { 5 6 field w ; # widget path 7 field w_rev ; # mega-widget to pick the initial revision 8 9 field opt_fetch 1; # refetch tracking branch if used? 10 field opt_detach 0; # force a detached head case? 11 12 constructor dialog {} { 13 make_dialog top w 14 wm withdraw $w 15 wm title $top [mc "%s (%s): Checkout Branch" [appname] [reponame]] 16 if {$top ne {.}} { 17 wm geometry $top "+[winfo rootx .]+[winfo rooty .]" 18 } 19 20 ttk::label $w.header -text [mc "Checkout Branch"] \ 21 -font font_uibold -anchor center 22 pack $w.header -side top -fill x 23 24 ttk::frame $w.buttons 25 ttk::button $w.buttons.create -text [mc Checkout] \ 26 -default active \ 27 -command [cb _checkout] 28 pack $w.buttons.create -side right 29 ttk::button $w.buttons.cancel -text [mc Cancel] \ 30 -command [list destroy $w] 31 pack $w.buttons.cancel -side right -padx 5 32 pack $w.buttons -side bottom -fill x -pady 10 -padx 10 33 34 set w_rev [::choose_rev::new $w.rev [mc Revision]] 35 $w_rev bind_listbox [cb _checkout] 36 pack $w.rev -anchor nw -fill both -expand 1 -pady 5 -padx 5 37 38 ttk::labelframe $w.options -text [mc Options] 39 40 ttk::checkbutton $w.options.fetch \ 41 -text [mc "Fetch Tracking Branch"] \ 42 -variable @opt_fetch 43 pack $w.options.fetch -anchor nw 44 45 ttk::checkbutton $w.options.detach \ 46 -text [mc "Detach From Local Branch"] \ 47 -variable @opt_detach 48 pack $w.options.detach -anchor nw 49 50 pack $w.options -anchor nw -fill x -pady 5 -padx 5 51 52 bind $w [cb _visible] 53 bind $w [list destroy $w] 54 bind $w [cb _checkout]\;break 55 wm deiconify $w 56 tkwait window $w 57 } 58 59 method _checkout {} { 60 set spec [$w_rev get_tracking_branch] 61 if {$spec ne {} && $opt_fetch} { 62 set new {} 63 } elseif {[catch {set new [$w_rev commit_or_die]}]} { 64 return 65 } 66 67 if {$opt_detach} { 68 set ref {} 69 } else { 70 set ref [$w_rev get_local_branch] 71 } 72 73 set co [::checkout_op::new [$w_rev get] $new $ref] 74 $co parent $w 75 $co enable_checkout 1 76 if {$spec ne {} && $opt_fetch} { 77 $co enable_fetch $spec 78 } 79 80 if {[$co run]} { 81 destroy $w 82 } else { 83 $w_rev focus_filter 84 } 85 } 86 87 method _visible {} { 88 grab $w 89 $w_rev focus_filter 90 } 91 92 }