From 7aecb128779ffd8258f01f4382df963900ae6acd Mon Sep 17 00:00:00 2001 From: Gerrit Pape Date: Fri, 29 Jun 2007 11:32:29 +0000 Subject: git-gui: properly popup error if gitk should be started but is not installed On 'Visualize ...', a gitk process is started. Since it is run in the background, catching a possible startup error doesn't work, and the error output goes to the console git-gui is started from. The most probable startup error is that gitk is not installed; so before trying to start, check for the existence of the gitk program, and popup an error message unless it's found. This was noticed and reported by Paul Wise through http://bugs.debian.org/429810 Signed-off-by: Gerrit Pape Signed-off-by: Shawn O. Pearce diff --git a/git-gui.sh b/git-gui.sh index 4fbc408..6b7321b 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -1042,15 +1042,17 @@ proc do_gitk {revs} { # lets us bypass using shell process on Windows systems. # set cmd [list [info nameofexecutable]] - lappend cmd [gitexec gitk] + set exe [gitexec gitk] + lappend cmd $exe if {$revs ne {}} { append cmd { } append cmd $revs } - if {[catch {eval exec $cmd &} err]} { - error_popup "Failed to start gitk:\n\n$err" + if {! [file exists $exe]} { + error_popup "Unable to start gitk:\n\n$exe does not exist" } else { + eval exec $cmd & set ui_status_value $starting_gitk_msg after 10000 { if {$ui_status_value eq $starting_gitk_msg} { -- cgit v0.10.2-6-g49f6 From c8e23aaf1814b95d64fc536fdf1acaa54bb28411 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Wed, 4 Jul 2007 02:29:32 -0400 Subject: git-gui: Unlock the index when cancelling merge dialog Pressing the escape key while in the merge dialog cancels the merge and correctly unlocks the index. Unfortunately this is not true of the Cancel button, using it closes the dialog but does not release the index lock, rendering git-gui frozen until you restart it. We now properly release the index lock when the Cancel button is used. Signed-off-by: Shawn O. Pearce diff --git a/lib/merge.tcl b/lib/merge.tcl index ae0389d..889182f 100644 --- a/lib/merge.tcl +++ b/lib/merge.tcl @@ -213,7 +213,9 @@ proc dialog {} { pack $w.buttons.visualize -side left button $w.buttons.create -text Merge -command $_start pack $w.buttons.create -side right - button $w.buttons.cancel -text {Cancel} -command [list destroy $w] + button $w.buttons.cancel \ + -text {Cancel} \ + -command "unlock_index;destroy $w" pack $w.buttons.cancel -side right -padx 5 pack $w.buttons -side bottom -fill x -pady 10 -padx 10 -- cgit v0.10.2-6-g49f6 From f1e031bbebb8910ef11f1d5d566b357b50050c56 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Thu, 5 Jul 2007 22:16:38 -0400 Subject: git-gui: Don't bind F5/M1-R in all windows We actually only want our F5/M1-R keystroke bound in the main window. Within a browser/blame/console window pressing these keys should not execute the rescan action. Signed-off-by: Shawn O. Pearce diff --git a/git-gui.sh b/git-gui.sh index 6b7321b..a1cf873 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -2149,9 +2149,9 @@ if {[is_enabled branch]} { bind . <$M1B-Key-N> do_create_branch } -bind all do_rescan -bind all <$M1B-Key-r> do_rescan -bind all <$M1B-Key-R> do_rescan +bind . do_rescan +bind . <$M1B-Key-r> do_rescan +bind . <$M1B-Key-R> do_rescan bind . <$M1B-Key-s> do_signoff bind . <$M1B-Key-S> do_signoff bind . <$M1B-Key-i> do_add_all -- cgit v0.10.2-6-g49f6 From 840bcfa7b55dd94bd97a2d19a250f38d9ce80c77 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Thu, 5 Jul 2007 22:15:00 -0400 Subject: git-gui: Bind M1-P to push action Users often need to be able to push the current branch so that they can publish their recent changes to anyone they are collaborating with on the project. Associating a keyboard action with this will make it easier for keyboard-oriented users to quickly activate the push features. Signed-off-by: Shawn O. Pearce diff --git a/git-gui.sh b/git-gui.sh index a1cf873..c22a431 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -1525,7 +1525,8 @@ if {[is_enabled transport]} { menu .mbar.push .mbar.push add command -label {Push...} \ - -command do_push_anywhere + -command do_push_anywhere \ + -accelerator $M1T-P } if {[is_MacOSX]} { @@ -2148,6 +2149,10 @@ if {[is_enabled branch]} { bind . <$M1B-Key-n> do_create_branch bind . <$M1B-Key-N> do_create_branch } +if {[is_enabled transport]} { + bind . <$M1B-Key-p> do_push_anywhere + bind . <$M1B-Key-P> do_push_anywhere +} bind . do_rescan bind . <$M1B-Key-r> do_rescan -- cgit v0.10.2-6-g49f6 From 87b49a533b0ee0da06c06fb466844885ae0d35bd Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Thu, 5 Jul 2007 22:19:33 -0400 Subject: git-gui: Include a Push action on the left toolbar Pushing changes to a remote system is a very common action for many users of git-gui, so much so that in some workflows a user is supposed to push immediately after they make a local commit so that their change(s) are immediately available for their teammates to view and build on top of. Including the push button right below the commit button on the left toolbar indicates that users should probably perform this action after they have performed the commit action. Signed-off-by: Shawn O. Pearce diff --git a/git-gui.sh b/git-gui.sh index c22a431..c38aa06 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -1822,6 +1822,10 @@ pack .vpane.lower.commarea.buttons.commit -side top -fill x lappend disable_on_lock \ {.vpane.lower.commarea.buttons.commit conf -state} +button .vpane.lower.commarea.buttons.push -text {Push} \ + -command do_push_anywhere +pack .vpane.lower.commarea.buttons.push -side top -fill x + # -- Commit Message Buffer # frame .vpane.lower.commarea.buffer -- cgit v0.10.2-6-g49f6 From 47282d4646372aa859908c3b9471b96c385abe5f Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Thu, 5 Jul 2007 18:39:40 -0400 Subject: git-gui: Ensure windows shortcuts always have .bat extension Apparently under some setups on Windows Tk is hiding our file extension recommendation of ".bat" from the user and that is allowing the user to create a shortcut file which has no file extension. Double clicking on such a file in Windows Explorer brings up the associate file dialog, as Windows does not know what application to launch. We now append the file extension ".bat" to the filename of the shortcut file if it has no extension or if it has one but it is not ".bat". Signed-off-by: Shawn O. Pearce diff --git a/lib/shortcut.tcl b/lib/shortcut.tcl index ebf72e4..a0a1b7d 100644 --- a/lib/shortcut.tcl +++ b/lib/shortcut.tcl @@ -9,6 +9,9 @@ proc do_windows_shortcut {} { -title "[appname] ([reponame]): Create Desktop Icon" \ -initialfile "Git [reponame].bat"] if {$fn != {}} { + if {[file extension $fn] ne {.bat}} { + set fn ${fn}.bat + } if {[catch { set fd [open $fn w] puts $fd "@ECHO Entering [reponame]" @@ -42,6 +45,9 @@ proc do_cygwin_shortcut {} { -initialdir $desktop \ -initialfile "Git [reponame].bat"] if {$fn != {}} { + if {[file extension $fn] ne {.bat}} { + set fn ${fn}.bat + } if {[catch { set fd [open $fn w] set sh [exec cygpath \ -- cgit v0.10.2-6-g49f6 From 88dce86f38bed84abadd73bbc40d9df92b7519db Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Sun, 8 Jul 2007 21:06:43 -0400 Subject: git-gui: Skip nicknames when selecting author initials Our blame viewer only grabbed the first initial of the git.git author string "Simon 'corecode' Schubert". Here the problem was we looked at Simon, pulled the S into the author initials, then saw the single quote as the start of the next name and did not like this character as it was not an uppercase letter. We now skip over single quoted nicknames placed within the author name field and grab the initials following it. So the above name will get the initials SS, rather than just S. Signed-off-by: Shawn O. Pearce diff --git a/lib/blame.tcl b/lib/blame.tcl index b523654..1d2caac 100644 --- a/lib/blame.tcl +++ b/lib/blame.tcl @@ -547,6 +547,10 @@ method _read_blame {fd cur_w cur_d cur_s} { set a_name {} catch {set a_name $header($cmit,author)} while {$a_name ne {}} { + if {$author_abbr ne {} + && [string index $a_name 0] eq {'}} { + regsub {^'[^']+'\s+} $a_name {} a_name + } if {![regexp {^([[:upper:]])} $a_name _a]} break append author_abbr $_a unset _a -- cgit v0.10.2-6-g49f6 From 56e29f597c8f85b0dfee9ba7408f8d09fd5adb5a Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Mon, 9 Jul 2007 11:55:45 -0400 Subject: git-gui: Correct ls-tree buffering problem in browser Our file browser was showing bad output as it did not properly buffer a partial record when read from `ls-tree -z`. This did not show up on my Mac OS X system as most trees are small, the pipe buffers generally big and `ls-tree -z` was generally fast enough that all data was ready before Tcl started to read. However on my Cygwin system one of my production repositories had a large enough tree and packfile that it took a couple of pipe buffers for `ls-tree -z` to complete its dump. Signed-off-by: Shawn O. Pearce diff --git a/lib/browser.tcl b/lib/browser.tcl index 3d6341b..e612247 100644 --- a/lib/browser.tcl +++ b/lib/browser.tcl @@ -11,6 +11,8 @@ field browser_status {Starting...} field browser_stack {} field browser_busy 1 +field ls_buf {}; # Buffered record output from ls-tree + constructor new {commit} { global cursor_ptr M1B make_toplevel top w @@ -160,7 +162,7 @@ method _click {was_double_click pos} { } method _ls {tree_id {name {}}} { - set browser_buffer {} + set ls_buf {} set browser_files {} set browser_busy 1 @@ -185,17 +187,19 @@ method _ls {tree_id {name {}}} { } method _read {fd} { - append browser_buffer [read $fd] - set pck [split $browser_buffer "\0"] - set browser_buffer [lindex $pck end] + append ls_buf [read $fd] + set pck [split $ls_buf "\0"] + set ls_buf [lindex $pck end] set n [llength $browser_files] $w conf -state normal foreach p [lrange $pck 0 end-1] { - set info [split $p "\t"] - set path [lindex $info 1] - set info [split [lindex $info 0] { }] - set type [lindex $info 1] + set tab [string first "\t" $p] + if {$tab == -1} continue + + set info [split [string range $p 0 [expr {$tab - 1}]] { }] + set path [string range $p [expr {$tab + 1}] end] + set type [lindex $info 1] set object [lindex $info 2] switch -- $type { @@ -225,7 +229,7 @@ method _read {fd} { close $fd set browser_status Ready. set browser_busy 0 - unset browser_buffer + set ls_buf {} if {$n > 0} { $w tag add in_sel 1.0 2.0 focus -force $w -- cgit v0.10.2-6-g49f6 From e87fb0f1b4a4b458394a65d664145a9a8001e821 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Mon, 9 Jul 2007 11:14:00 -0400 Subject: git-gui: Don't linewrap within console windows If we get more than 80 characters of text in a single line odds are it is output from git-fetch or git-push and its showing a lot of detail off to the right edge that is not so important to the average user. We still want to make sure we show everything we need, but we can get away with that information being off to the side with a horizontal scrollbar. Signed-off-by: Shawn O. Pearce diff --git a/lib/console.tcl b/lib/console.tcl index ce25d92..34de5d4 100644 --- a/lib/console.tcl +++ b/lib/console.tcl @@ -31,16 +31,20 @@ method _init {} { -background white -borderwidth 1 \ -relief sunken \ -width 80 -height 10 \ + -wrap none \ -font font_diff \ -state disabled \ + -xscrollcommand [list $w.m.sbx set] \ -yscrollcommand [list $w.m.sby set] label $w.m.s -text {Working... please wait...} \ -anchor w \ -justify left \ -font font_uibold + scrollbar $w.m.sbx -command [list $w.m.t xview] -orient h scrollbar $w.m.sby -command [list $w.m.t yview] pack $w.m.l1 -side top -fill x pack $w.m.s -side bottom -fill x + pack $w.m.sbx -side bottom -fill x pack $w.m.sby -side right -fill y pack $w.m.t -side left -fill both -expand 1 pack $w.m -side top -fill both -expand 1 -padx 5 -pady 10 -- cgit v0.10.2-6-g49f6 From 20f1a10bfb6c31a3728a74bf1c33cb3cc5ac0c7e Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Thu, 12 Jul 2007 02:31:28 -0400 Subject: git-gui: Work around bad interaction between Tcl and cmd.exe on ^{tree} From Johannes Sixt : > It seems that MSYS's wish does some quoting for Bourne shells, > in particular, escape the first '{' of the "^{tree}" suffix, but > then it uses cmd.exe to run "git rev-parse". However, cmd.exe does > not remove the backslash, so that the resulting rev expression > ends up in git's guts as unrecognizable garbage: rev-parse fails, > and git-gui hickups in a way that it must be restarted. Johannes originally submitted a patch to this section of commit.tcl to use `git rev-parse $PARENT:`, but not all versions of Git will accept that format. So I'm just taking the really simple approach here of scanning the first line of the commit to grab its tree. About the same cost, but works everywhere. Signed-off-by: Shawn O. Pearce diff --git a/lib/commit.tcl b/lib/commit.tcl index f9791f6..e139f4d 100644 --- a/lib/commit.tcl +++ b/lib/commit.tcl @@ -260,7 +260,18 @@ proc commit_committree {fd_wt curHEAD msg} { # -- Verify this wasn't an empty change. # if {$commit_type eq {normal}} { - set old_tree [git rev-parse "$PARENT^{tree}"] + set fd_ot [open "| git cat-file commit $PARENT" r] + fconfigure $fd_ot -encoding binary -translation lf + set old_tree [gets $fd_ot] + close $fd_ot + + if {[string equal -length 5 {tree } $old_tree] + && [string length $old_tree] == 45} { + set old_tree [string range $old_tree 5 end] + } else { + error "Commit $PARENT appears to be corrupt" + } + if {$tree_id eq $old_tree} { info_popup {No changes to commit. -- cgit v0.10.2-6-g49f6