]> asedeno.scripts.mit.edu Git - git.git/blobdiff - git-gui.sh
git-gui: Include browser in our usage message.
[git.git] / git-gui.sh
index f8d4db21a56b51f17ecfcc6ee04c118a20ad8f71..039e7bb93f554f55ea02ac58c306e403510176b5 100755 (executable)
@@ -4,7 +4,7 @@ exec wish "$0" -- "$@"
 
 set appvers {@@GITGUI_VERSION@@}
 set copyright {
-Copyright © 2006, 2007 Shawn Pearce, Paul Mackerras.
+Copyright © 2006, 2007 Shawn Pearce, et. al.
 
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
@@ -19,6 +19,9 @@ GNU General Public License for more details.
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA}
+set gitgui_credits {
+Paul Mackerras
+}
 
 ######################################################################
 ##
@@ -359,6 +362,24 @@ set _reponame [lindex [file split \
        [file normalize [file dirname $_gitdir]]] \
        end]
 
+######################################################################
+##
+## global init
+
+set current_diff_path {}
+set current_diff_side {}
+set diff_actions [list]
+set ui_status_value {Initializing...}
+
+set HEAD {}
+set PARENT {}
+set MERGE_HEAD [list]
+set commit_type {}
+set empty_tree {}
+set current_branch {}
+set current_diff_path {}
+set selected_commit_type new
+
 ######################################################################
 ##
 ## task management
@@ -682,8 +703,9 @@ proc reshow_diff {} {
        global current_diff_path current_diff_side
 
        set p $current_diff_path
-       if {$p eq {}
-               || $current_diff_side eq {}
+       if {$p eq {}} {
+               # No diff is being shown.
+       } elseif {$current_diff_side eq {}
                || [catch {set s $file_states($p)}]
                || [lsearch -sorted -exact $file_lists($current_diff_side) $p] == -1} {
                clear_diff
@@ -1916,11 +1938,24 @@ proc all_tracking_branches {} {
        return [lsort -unique $all_trackings]
 }
 
+proc load_all_tags {} {
+       set all_tags [list]
+       set fd [open "| git for-each-ref --format=%(refname) refs/tags" r]
+       while {[gets $fd line] > 0} {
+               if {![regsub ^refs/tags/ $line {} name]} continue
+               lappend all_tags $name
+       }
+       close $fd
+
+       return [lsort $all_tags]
+}
+
 proc do_create_branch_action {w} {
        global all_heads null_sha1 repo_config
        global create_branch_checkout create_branch_revtype
        global create_branch_head create_branch_trackinghead
        global create_branch_name create_branch_revexp
+       global create_branch_tag
 
        set newbranch $create_branch_name
        if {$newbranch eq {}
@@ -1959,6 +1994,7 @@ proc do_create_branch_action {w} {
        switch -- $create_branch_revtype {
        head {set rev $create_branch_head}
        tracking {set rev $create_branch_trackinghead}
+       tag {set rev $create_branch_tag}
        expression {set rev $create_branch_revexp}
        }
        if {[catch {set cmt [git rev-parse --verify "${rev}^0"]}]} {
@@ -2004,6 +2040,8 @@ trace add variable create_branch_head write \
        [list radio_selector create_branch_revtype head]
 trace add variable create_branch_trackinghead write \
        [list radio_selector create_branch_revtype tracking]
+trace add variable create_branch_tag write \
+       [list radio_selector create_branch_revtype tag]
 
 trace add variable delete_branch_head write \
        [list radio_selector delete_branch_checktype head]
@@ -2015,6 +2053,7 @@ proc do_create_branch {} {
        global create_branch_checkout create_branch_revtype
        global create_branch_head create_branch_trackinghead
        global create_branch_name create_branch_revexp
+       global create_branch_tag
 
        set w .branch_editor
        toplevel $w
@@ -2078,6 +2117,19 @@ proc do_create_branch {} {
                        $all_trackings
                grid $w.from.tracking_r $w.from.tracking_m -sticky w
        }
+       set all_tags [load_all_tags]
+       if {$all_tags ne {}} {
+               set create_branch_tag [lindex $all_tags 0]
+               radiobutton $w.from.tag_r \
+                       -text {Tag:} \
+                       -value tag \
+                       -variable create_branch_revtype \
+                       -font font_ui
+               eval tk_optionMenu $w.from.tag_m \
+                       create_branch_tag \
+                       $all_tags
+               grid $w.from.tag_r $w.from.tag_m -sticky w
+       }
        radiobutton $w.from.exp_r \
                -text {Revision Expression:} \
                -value expression \
@@ -3014,7 +3066,14 @@ proc new_browser {commit} {
        global next_browser_id cursor_ptr M1B
        global browser_commit browser_status browser_stack browser_path browser_busy
 
-       set w .browser[incr next_browser_id]
+       if {[winfo ismapped .]} {
+               set w .browser[incr next_browser_id]
+               set tl $w
+               toplevel $w
+       } else {
+               set w {}
+               set tl .
+       }
        set w_list $w.list.l
        set browser_commit($w_list) $commit
        set browser_status($w_list) {Starting...}
@@ -3022,7 +3081,6 @@ proc new_browser {commit} {
        set browser_path($w_list) $browser_commit($w_list):
        set browser_busy($w_list) 1
 
-       toplevel $w
        label $w.path -textvariable browser_path($w_list) \
                -anchor w \
                -justify left \
@@ -3072,8 +3130,8 @@ proc new_browser {commit} {
        bind $w_list <Left>            break
        bind $w_list <Right>           break
 
-       bind $w <Visibility> "focus $w"
-       bind $w <Destroy> "
+       bind $tl <Visibility> "focus $w"
+       bind $tl <Destroy> "
                array unset browser_buffer $w_list
                array unset browser_files $w_list
                array unset browser_status $w_list
@@ -3082,7 +3140,7 @@ proc new_browser {commit} {
                array unset browser_commit $w_list
                array unset browser_busy $w_list
        "
-       wm title $w "[appname] ([reponame]): File Browser"
+       wm title $tl "[appname] ([reponame]): File Browser"
        ls_tree $w_list $browser_commit($w_list) {}
 }
 
@@ -4422,6 +4480,61 @@ proc do_commit {} {
        commit_tree
 }
 
+proc do_credits {} {
+       global gitgui_credits
+
+       set w .credits_dialog
+
+       toplevel $w
+       wm geometry $w "+[winfo rootx .]+[winfo rooty .]"
+
+       label $w.header -text {git-gui Contributors} -font font_uibold
+       pack $w.header -side top -fill x
+
+       frame $w.buttons
+       button $w.buttons.close -text {Close} \
+               -font font_ui \
+               -command [list destroy $w]
+       pack $w.buttons.close -side right
+       pack $w.buttons -side bottom -fill x -pady 10 -padx 10
+
+       frame $w.credits
+       text $w.credits.t \
+               -background [$w.header cget -background] \
+               -yscrollcommand [list $w.credits.sby set] \
+               -width 20 \
+               -height 10 \
+               -wrap none \
+               -borderwidth 1 \
+               -relief solid \
+               -padx 5 -pady 5 \
+               -font font_ui
+       scrollbar $w.credits.sby -command [list $w.credits.t yview]
+       pack $w.credits.sby -side right -fill y
+       pack $w.credits.t -fill both -expand 1
+       pack $w.credits -side top -fill both -expand 1 -padx 5 -pady 5
+
+       label $w.desc \
+               -text "All portions are copyrighted by their respective authors
+and are distributed under the GNU General Public License." \
+               -padx 5 -pady 5 \
+               -justify left \
+               -anchor w \
+               -borderwidth 1 \
+               -relief solid \
+               -font font_ui
+       pack $w.desc -side top -fill x -padx 5 -pady 5
+
+       $w.credits.t insert end "[string trim $gitgui_credits]\n"
+       $w.credits.t conf -state disabled
+       $w.credits.t see 1.0
+
+       bind $w <Visibility> "grab $w; focus $w"
+       bind $w <Key-Escape> [list destroy $w]
+       wm title $w [$w.header cget -text]
+       tkwait window $w
+}
+
 proc do_about {} {
        global appvers copyright
        global tcl_patchLevel tk_patchLevel
@@ -4438,11 +4551,15 @@ proc do_about {} {
        button $w.buttons.close -text {Close} \
                -font font_ui \
                -command [list destroy $w]
+       button $w.buttons.credits -text {Contributors} \
+               -font font_ui \
+               -command do_credits
+       pack $w.buttons.credits -side left
        pack $w.buttons.close -side right
        pack $w.buttons -side bottom -fill x -pady 10 -padx 10
 
        label $w.desc \
-               -text "[appname] - a commit creation tool for Git.
+               -text "git-gui - a graphical user interface for Git.
 $copyright" \
                -padx 5 -pady 5 \
                -justify left \
@@ -4453,7 +4570,7 @@ $copyright" \
        pack $w.desc -side top -fill x -padx 5 -pady 5
 
        set v {}
-       append v "[appname] version $appvers\n"
+       append v "git-gui version $appvers\n"
        append v "[git version]\n"
        append v "\n"
        if {$tcl_patchLevel eq $tk_patchLevel} {
@@ -4513,7 +4630,7 @@ proc do_options {} {
        toplevel $w
        wm geometry $w "+[winfo rootx .]+[winfo rooty .]"
 
-       label $w.header -text "[appname] Options" \
+       label $w.header -text "Options" \
                -font font_uibold
        pack $w.header -side top -fill x
 
@@ -4987,6 +5104,9 @@ enable_option branch
 enable_option transport
 
 switch -- $subcommand {
+--version -
+version -
+browser -
 blame {
        disable_option multicommit
        disable_option branch
@@ -5219,7 +5339,7 @@ if {[is_MacOSX]} {
        .mbar.apple add command -label "About [appname]" \
                -command do_about \
                -font font_ui
-       .mbar.apple add command -label "[appname] Options..." \
+       .mbar.apple add command -label "Options..." \
                -command do_options \
                -font font_ui
 } else {
@@ -5278,7 +5398,7 @@ set doc_path [file dirname [gitexec]]
 set doc_path [file join $doc_path Documentation index.html]
 
 if {[is_Cygwin]} {
-       set doc_path [exec cygpath --windows $doc_path]
+       set doc_path [exec cygpath --mixed $doc_path]
 }
 
 if {$browser eq {}} {
@@ -5322,6 +5442,20 @@ bind all <$M1B-Key-W> {destroy [winfo toplevel %W]}
 # -- Not a normal commit type invocation?  Do that instead!
 #
 switch -- $subcommand {
+--version -
+version {
+       puts "git-gui version $appvers"
+       exit
+}
+browser {
+       if {[llength $argv] != 1} {
+               puts stderr "usage: $argv0 browser commit"
+               exit 1
+       }
+       set current_branch [lindex $argv 0]
+       new_browser $current_branch
+       return
+}
 blame {
        if {[llength $argv] != 2} {
                puts stderr "usage: $argv0 blame commit path"
@@ -5344,7 +5478,7 @@ gui {
        # fall through to setup UI for commits
 }
 default {
-       puts stderr "usage: $argv0 \[{blame|citool}\]"
+       puts stderr "usage: $argv0 \[{blame|browser|citool}\]"
        exit 1
 }
 }
@@ -5594,9 +5728,6 @@ bind_button3 $ui_comm "tk_popup $ctxm %X %Y"
 
 # -- Diff Header
 #
-set current_diff_path {}
-set current_diff_side {}
-set diff_actions [list]
 proc trace_current_diff_path {varname args} {
        global current_diff_path diff_actions file_states
        if {$current_diff_path eq {}} {
@@ -5789,7 +5920,6 @@ unset ui_diff_applyhunk
 
 # -- Status Bar
 #
-set ui_status_value {Initializing...}
 label .status -textvariable ui_status_value \
        -anchor w \
        -justify left \
@@ -5863,15 +5993,6 @@ unset i
 set file_lists($ui_index) [list]
 set file_lists($ui_workdir) [list]
 
-set HEAD {}
-set PARENT {}
-set MERGE_HEAD [list]
-set commit_type {}
-set empty_tree {}
-set current_branch {}
-set current_diff_path {}
-set selected_commit_type new
-
 wm title . "[appname] ([file normalize [file dirname [gitdir]]])"
 focus -force $ui_comm