From 6e4ba05c7fee0d0140e2057b63f5ca4eea9a6053 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Sun, 2 Sep 2007 15:19:07 -0400 Subject: git-gui: Correct starting of git-remote to handle -w option Current versions of git-remote apparently are passing the -w option to Perl as part of the shbang line: #!/usr/bin/perl -w this caused a problem in git-gui and gave the user a Tcl error with the message: "git-remote not supported: #!/usr/bin/perl -w". The fix for this is to treat the shbang line as a Tcl list and look at the first element only for guessing the executable name. Once we know the executable name we use the remaining elements (if any exist) as arguments to the executable, before the script filename. Signed-off-by: Shawn O. Pearce diff --git a/git-gui.sh b/git-gui.sh index fa30ccc..e495046 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -261,7 +261,7 @@ proc _git_cmd {name} { set s [gets $f] close $f - switch -glob -- $s { + switch -glob -- [lindex $s 0] { #!*sh { set i sh } #!*perl { set i perl } #!*python { set i python } @@ -275,7 +275,7 @@ proc _git_cmd {name} { if {$interp eq {}} { error "git-$name requires $i (not in PATH)" } - set v [list $interp $p] + set v [concat [list $interp] [lrange $s 1 end] [list $p]] } else { # Assume it is builtin to git somehow and we # aren't actually able to see a file for it. -- cgit v0.10.2-6-g49f6 From 881d8f24cab5bf4e0fa71b17a3ab82e27b2e8ed7 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Sun, 2 Sep 2007 15:30:26 -0400 Subject: git-gui: Fix detaching current branch during checkout If the user tried to detach their HEAD while keeping the working directory on the same commit we actually did not completely do a detach operation internally. The problem was caused by git-gui not forcing the HEAD symbolic ref to be updated to a SHA-1 hash when we were not switching revisions. Now we update the HEAD ref if we aren't currently detached or the hashes don't match. Signed-off-by: Shawn O. Pearce diff --git a/lib/checkout_op.tcl b/lib/checkout_op.tcl index 170f737..76f04f2 100644 --- a/lib/checkout_op.tcl +++ b/lib/checkout_op.tcl @@ -396,7 +396,7 @@ method _after_readtree {} { set is_detached 0 } } else { - if {$new_hash ne $HEAD} { + if {!$is_detached || $new_hash ne $HEAD} { append log " to $new_expr" if {[catch { _detach_HEAD $log $new_hash -- cgit v0.10.2-6-g49f6 From 047d94d505c9837a60c28e121de65471dadce74b Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Sun, 2 Sep 2007 15:38:04 -0400 Subject: git-gui: Properly set the state of "Stage/Unstage Hunk" action Today I found yet another way for the "Stage Hunk" and "Unstage Hunk" context menu actions to leave the wrong state enabled in the UI. The problem this time was that I connected the state determination to the value of $::current_diff_side (the side the diff is from). When the user was last looking at a diff from the index side and unstages everything the diff panel goes empty, but the action stayed enabled as we always assumed unstaging was a valid action. This change moves the logic for determining when the action is enabled away from the individual side selection, as they really are two unrelated concepts. Signed-off-by: Shawn O. Pearce diff --git a/git-gui.sh b/git-gui.sh index e495046..44977aa 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -2441,20 +2441,17 @@ proc popup_diff_menu {ctxm x y X Y} { set ::cursorX $x set ::cursorY $y if {$::ui_index eq $::current_diff_side} { - set s normal set l "Unstage Hunk From Commit" } else { - if {$current_diff_path eq {} - || ![info exists file_states($current_diff_path)] - || {_O} eq [lindex $file_states($current_diff_path) 0]} { - set s disabled - } else { - set s normal - } set l "Stage Hunk For Commit" } - if {$::is_3way_diff} { + if {$::is_3way_diff + || $current_diff_path eq {} + || ![info exists file_states($current_diff_path)] + || {_O} eq [lindex $file_states($current_diff_path) 0]} { set s disabled + } else { + set s normal } $ctxm entryconf $::ui_diff_applyhunk -state $s -label $l tk_popup $ctxm $X $Y -- cgit v0.10.2-6-g49f6 From 0b883ab30c869c4f22a19e49aedc1604d335cd91 Mon Sep 17 00:00:00 2001 From: Gerrit Pape Date: Fri, 7 Sep 2007 17:16:59 +0000 Subject: git-gui: lib/index.tcl: handle files with % in the filename properly Steps to reproduce the bug: $ mkdir repo && cd repo && git init Initialized empty Git repository in .git/ $ touch 'foo%3Fsuite' $ git-gui Then click on the 'foo%3Fsuite' icon to include it in a changeset, a popup comes with: 'Error: bad field specifier "F"' Vincent Danjean noticed the problem and also suggested the fix, reported through http://bugs.debian.org/441167 Signed-off-by: Gerrit Pape Signed-off-by: Shawn O. Pearce diff --git a/lib/index.tcl b/lib/index.tcl index f47f929..cbbce13 100644 --- a/lib/index.tcl +++ b/lib/index.tcl @@ -13,7 +13,8 @@ proc update_indexinfo {msg pathList after} { if {$batch > 25} {set batch 25} ui_status [format \ - "$msg... %i/%i files (%.2f%%)" \ + "%s... %i/%i files (%.2f%%)" \ + $msg \ $update_index_cp \ $totalCnt \ 0.0] @@ -68,7 +69,8 @@ proc write_update_indexinfo {fd pathList totalCnt batch msg after} { } ui_status [format \ - "$msg... %i/%i files (%.2f%%)" \ + "%s... %i/%i files (%.2f%%)" \ + $msg \ $update_index_cp \ $totalCnt \ [expr {100.0 * $update_index_cp / $totalCnt}]] @@ -86,7 +88,8 @@ proc update_index {msg pathList after} { if {$batch > 25} {set batch 25} ui_status [format \ - "$msg... %i/%i files (%.2f%%)" \ + "%s... %i/%i files (%.2f%%)" \ + $msg \ $update_index_cp \ $totalCnt \ 0.0] @@ -145,7 +148,8 @@ proc write_update_index {fd pathList totalCnt batch msg after} { } ui_status [format \ - "$msg... %i/%i files (%.2f%%)" \ + "%s... %i/%i files (%.2f%%)" \ + $msg \ $update_index_cp \ $totalCnt \ [expr {100.0 * $update_index_cp / $totalCnt}]] @@ -163,7 +167,8 @@ proc checkout_index {msg pathList after} { if {$batch > 25} {set batch 25} ui_status [format \ - "$msg... %i/%i files (%.2f%%)" \ + "%s... %i/%i files (%.2f%%)" \ + $msg $update_index_cp \ $totalCnt \ 0.0] @@ -218,7 +223,8 @@ proc write_checkout_index {fd pathList totalCnt batch msg after} { } ui_status [format \ - "$msg... %i/%i files (%.2f%%)" \ + "%s... %i/%i files (%.2f%%)" \ + $msg \ $update_index_cp \ $totalCnt \ [expr {100.0 * $update_index_cp / $totalCnt}]] -- cgit v0.10.2-6-g49f6 From cff93397ab185898fd93b6a260cc6f3068c4ac30 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Sat, 8 Sep 2007 23:47:00 -0400 Subject: git-gui: Disable Tk send in all git-gui sessions The Tk designers blessed us with the "send" command, which on X11 will allow anyone who can connect to your X server to evaluate any Tcl code they desire within any running Tk process. This is just plain nuts. If git-gui wants someone running Tcl code within it then would ask someone to supply that Tcl code to it; waiting for someone to drop any random Tcl code into us is not fantastic idea. By renaming send to the empty name the procedure will be removed from the global namespace and Tk will stop responding to random Tcl evaluation requests sent through the X server. Since there is no facility to filter these requests it is unlikely that we will ever consider enabling this command. Signed-off-by: Shawn O. Pearce diff --git a/git-gui.sh b/git-gui.sh index 44977aa..6d67609 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -42,6 +42,8 @@ if {[catch {package require Tcl 8.4} err] exit 1 } +rename send {} ; # What an evil concept... + ###################################################################### ## ## enable verbose loading? -- cgit v0.10.2-6-g49f6 From c63fe3b2dc90120a4bdba7194f92efc2f3c342ed Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Sat, 8 Sep 2007 23:05:43 -0400 Subject: git-gui: Avoid use of libdir in Makefile Dmitry V. Levin pointed out that on GNU linux libdir is often used in Makefiles to mean "/usr/lib" or "/usr/lib64", a directory that is meant to hold platform-specific binary files. Using a different libdir meaning here in git-gui's Makefile breaks idomatic expressions like rpm specifile "make libdir=%_libdir". Originally I asked that the git.git Makefile undefine libdir before it calls git-gui's own Makefile but it turns out this is very hard to do, if not impossible. Renaming our libdir to gg_libdir resolves this case with a minimum amount of fuss on our part. Signed-off-by: Shawn O. Pearce diff --git a/Makefile b/Makefile index 1bac6fe..f11cf26 100644 --- a/Makefile +++ b/Makefile @@ -76,8 +76,8 @@ SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH)) TCL_PATH_SQ = $(subst ','\'',$(TCL_PATH)) TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH)) -libdir ?= $(sharedir)/git-gui/lib -libdir_SQ = $(subst ','\'',$(libdir)) +gg_libdir ?= $(sharedir)/git-gui/lib +libdir_SQ = $(subst ','\'',$(gg_libdir)) exedir = $(dir $(gitexecdir))share/git-gui/lib exedir_SQ = $(subst ','\'',$(exedir)) @@ -126,7 +126,7 @@ TRACK_VARS = \ $(subst ','\'',TCL_PATH='$(TCL_PATH_SQ)') \ $(subst ','\'',TCLTK_PATH='$(TCLTK_PATH_SQ)') \ $(subst ','\'',gitexecdir='$(gitexecdir_SQ)') \ - $(subst ','\'',libdir='$(libdir_SQ)') \ + $(subst ','\'',gg_libdir='$(libdir_SQ)') \ #end TRACK_VARS GIT-GUI-VARS: .FORCE-GIT-GUI-VARS -- cgit v0.10.2-6-g49f6 From 2d19f8e921a1cdc562783814747819b0d5a12641 Mon Sep 17 00:00:00 2001 From: Michele Ballabio Date: Sun, 9 Sep 2007 21:04:45 +0200 Subject: git-gui: show unstaged symlinks in diff viewer git-gui has a minor problem with regards to symlinks that point to directories. git init mkdir realdir ln -s realdir linkdir git gui Now clicking on file names in the "unstaged changes" window, there's a problem coming from the "linkdir" symlink: git-gui complains with error reading "file4": illegal operation on a directory ...even though git-gui can add that same symlink to the index just fine. This patch fix this by adding a check. [sp: Minor fix to use {link} instead of "link" in condition and to only open the path if it is not a symlink.] Signed-off-by: Michele Ballabio Signed-off-by: Shawn O. Pearce diff --git a/lib/diff.tcl b/lib/diff.tcl index e09e125..9eeff2e 100644 --- a/lib/diff.tcl +++ b/lib/diff.tcl @@ -85,11 +85,16 @@ proc show_diff {path w {lno {}}} { if {$m eq {_O}} { set max_sz [expr {128 * 1024}] if {[catch { - set fd [open $path r] - fconfigure $fd -eofchar {} - set content [read $fd $max_sz] - close $fd - set sz [file size $path] + if {[file type $path] == {link}} { + set content [file readlink $path] + set sz [string length $content] + } else { + set fd [open $path r] + fconfigure $fd -eofchar {} + set content [read $fd $max_sz] + close $fd + set sz [file size $path] + } } err ]} { set diff_active 0 unlock_index -- cgit v0.10.2-6-g49f6 From 4ed1a190d09c7d6a248038edb11addda77af7550 Mon Sep 17 00:00:00 2001 From: Michele Ballabio Date: Sun, 9 Sep 2007 21:09:07 +0200 Subject: git-gui: handle "deleted symlink" diff marker Signed-off-by: Michele Ballabio Signed-off-by: Shawn O. Pearce diff --git a/lib/diff.tcl b/lib/diff.tcl index 9eeff2e..a1d5e52 100644 --- a/lib/diff.tcl +++ b/lib/diff.tcl @@ -203,6 +203,7 @@ proc read_diff {fd} { if {[string match {mode *} $line] || [string match {new file *} $line] || [string match {deleted file *} $line] + || [string match {deleted symlink} $line] || [string match {Binary files * and * differ} $line] || $line eq {\ No newline at end of file} || [regexp {^\* Unmerged path } $line]} { -- cgit v0.10.2-6-g49f6 From 3b9dfde3d636aeb961318d41b3ab59f72414d010 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Sun, 9 Sep 2007 20:13:10 -0400 Subject: git-gui: Assume untracked directories are Git submodules If `git ls-files --others` returned us the name of a directory then it is because Git has decided that this directory itself contains a valid Git repository and its files shouldn't be listed as untracked for this repository. In such a case we should label the object as a Git repository and not just as a directory. Signed-off-by: Shawn O. Pearce diff --git a/lib/diff.tcl b/lib/diff.tcl index a1d5e52..694834a 100644 --- a/lib/diff.tcl +++ b/lib/diff.tcl @@ -84,17 +84,30 @@ proc show_diff {path w {lno {}}} { # if {$m eq {_O}} { set max_sz [expr {128 * 1024}] + set type unknown if {[catch { - if {[file type $path] == {link}} { + set type [file type $path] + switch -- $type { + directory { + set type submodule + set content {} + set sz 0 + } + link { set content [file readlink $path] set sz [string length $content] - } else { + } + file { set fd [open $path r] fconfigure $fd -eofchar {} set content [read $fd $max_sz] close $fd set sz [file size $path] } + default { + error "'$type' not supported" + } + } } err ]} { set diff_active 0 unlock_index @@ -103,7 +116,9 @@ proc show_diff {path w {lno {}}} { return } $ui_diff conf -state normal - if {![catch {set type [exec file $path]}]} { + if {$type eq {submodule}} { + $ui_diff insert end "* Git Repository (subproject)\n" d_@ + } elseif {![catch {set type [exec file $path]}]} { set n [string length $path] if {[string equal -length $n $path $type]} { set type [string range $type $n end] -- cgit v0.10.2-6-g49f6 From 8938410189315979255c1dfcc3c0b7a4bf9953e5 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Sun, 9 Sep 2007 20:38:05 -0400 Subject: git-gui: Trim trailing slashes from untracked submodule names Oddly enough `git ls-files --others` supplies us the name of an untracked submodule by including the trailing slash but that same git version will not accept the name with a trailing slash through `git update-index --stdin`. Stripping off that final slash character before loading it into our file lists allows git-gui to stage changes to submodules just like any other file. This change should give git-gui users some basic submodule support, but it is strictly at the plumbing level as we do not actually know about calling the git-submodule porcelain that is a recent addition to git 1.5.3. Signed-off-by: Shawn O. Pearce diff --git a/git-gui.sh b/git-gui.sh index 6d67609..26eb5ac 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -1010,7 +1010,11 @@ proc read_ls_others {fd after} { set pck [split $buf_rlo "\0"] set buf_rlo [lindex $pck end] foreach p [lrange $pck 0 end-1] { - merge_state [encoding convertfrom $p] ?O + set p [encoding convertfrom $p] + if {[string index $p end] eq {/}} { + set p [string range $p 0 end-1] + } + merge_state $p ?O } rescan_done $fd buf_rlo $after } -- cgit v0.10.2-6-g49f6 From 63c4024ff080430004967fa27b8af8fe243e2ea3 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Tue, 11 Sep 2007 13:37:45 -0400 Subject: git-gui: Don't delete send on Windows as it doesn't exist The Windows port of Tk does not have the send command so we cannot delete it from our global namespace, but the Mac OS X and X11 ports do have it. Switching this delete attempt into a catch makes send go away, or stay away. Signed-off-by: Shawn O. Pearce diff --git a/git-gui.sh b/git-gui.sh index 26eb5ac..e221d5b 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -42,7 +42,7 @@ if {[catch {package require Tcl 8.4} err] exit 1 } -rename send {} ; # What an evil concept... +catch {rename send {}} ; # What an evil concept... ###################################################################### ## -- cgit v0.10.2-6-g49f6 From e7034d66ecd9c16ae8bd8d331fc41efc48e925f1 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Thu, 13 Sep 2007 19:04:14 -0400 Subject: git-gui: Make backporting changes from i18n version easier This is a very trivial hack to define a global mc procedure that does not actually perform i18n translations on its input strings. By declaring an mc procedure here in our maint version of git-gui we can take patches that are intended for the latest development version of git-gui and easily backport them without needing to tweak the mc calls first. Signed-off-by: Shawn O. Pearce diff --git a/git-gui.sh b/git-gui.sh index e221d5b..31a36cb 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -64,6 +64,18 @@ if {![catch {set _verbose $env(GITGUI_VERBOSE)}]} { ###################################################################### ## +## Fake internationalization to ease backporting of changes. + +proc mc {fmt args} { + set cmk [string first @@ $fmt] + if {$cmk > 0} { + set fmt [string range $fmt 0 [expr {$cmk - 1}]] + } + return [eval [list format $fmt] $args] +} + +###################################################################### +## ## read only globals set _appname [lindex [file split $argv0] end] -- cgit v0.10.2-6-g49f6 From afe2098ddd3e21d1d1afc428d3c8d91f37b01692 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Thu, 13 Sep 2007 19:07:46 -0400 Subject: git-gui: Font chooser to handle a large number of font families Simon Sasburg noticed that on X11 if there are more fonts than can fit in the height of the screen Tk's native tk_optionMenu does not offer scroll arrows to the user and it is not possible to review all choices or to select those that are off-screen. On Mac OS X the tk_optionMenu works properly but is awkward to navigate if the list is long. This is a rewrite of our font selection by providing a new modal dialog that the user can launch from the git-gui Options panel. The dialog offers the user a scrolling list of fonts in a pane. An example text shows the user what the font looks like at the size they have selected. But I have to admit the example pane is less than ideal. For example in the case of our diff font we really should show the user an example diff complete with our native diff syntax coloring. Signed-off-by: Shawn O. Pearce Acked-by: Simon Sasburg diff --git a/lib/choose_font.tcl b/lib/choose_font.tcl new file mode 100644 index 0000000..b69215c --- /dev/null +++ b/lib/choose_font.tcl @@ -0,0 +1,165 @@ +# git-gui font chooser +# Copyright (C) 2007 Shawn Pearce + +class choose_font { + +field w +field w_family ; # UI widget of all known family names +field w_example ; # Example to showcase the chosen font + +field f_family ; # Currently chosen family name +field f_size ; # Currently chosen point size + +field v_family ; # Name of global variable for family +field v_size ; # Name of global variable for size + +variable all_families [list] ; # All fonts known to Tk + +constructor pick {path title a_family a_size} { + variable all_families + + set v_family $a_family + set v_size $a_size + + upvar #0 $v_family pv_family + upvar #0 $v_size pv_size + + set f_family $pv_family + set f_size $pv_size + + make_toplevel top w + wm title $top "[appname] ([reponame]): $title" + wm geometry $top "+[winfo rootx $path]+[winfo rooty $path]" + + label $w.header -text $title -font font_uibold + pack $w.header -side top -fill x + + frame $w.buttons + button $w.buttons.select \ + -text [mc Select] \ + -default active \ + -command [cb _select] + button $w.buttons.cancel \ + -text [mc Cancel] \ + -command [list destroy $w] + pack $w.buttons.select -side right + pack $w.buttons.cancel -side right -padx 5 + pack $w.buttons -side bottom -fill x -pady 10 -padx 10 + + frame $w.inner + + frame $w.inner.family + label $w.inner.family.l \ + -text [mc "Font Family"] \ + -anchor w + set w_family $w.inner.family.v + text $w_family \ + -background white \ + -borderwidth 1 \ + -relief sunken \ + -cursor $::cursor_ptr \ + -wrap none \ + -width 30 \ + -height 10 \ + -yscrollcommand [list $w.inner.family.sby set] + scrollbar $w.inner.family.sby -command [list $w_family yview] + pack $w.inner.family.l -side top -fill x + pack $w.inner.family.sby -side right -fill y + pack $w_family -fill both -expand 1 + + frame $w.inner.size + label $w.inner.size.l \ + -text [mc "Font Size"] \ + -anchor w + spinbox $w.inner.size.v \ + -textvariable @f_size \ + -from 2 -to 80 -increment 1 \ + -width 3 + bind $w.inner.size.v {%W selection range 0 end} + pack $w.inner.size.l -fill x -side top + pack $w.inner.size.v -fill x -padx 2 + + grid configure $w.inner.family $w.inner.size -sticky nsew + grid rowconfigure $w.inner 0 -weight 1 + grid columnconfigure $w.inner 0 -weight 1 + pack $w.inner -fill both -expand 1 -padx 5 -pady 5 + + frame $w.example + label $w.example.l \ + -text [mc "Font Example"] \ + -anchor w + set w_example $w.example.t + text $w_example \ + -background white \ + -borderwidth 1 \ + -relief sunken \ + -height 3 \ + -width 40 + $w_example tag conf example -justify center + $w_example insert end [mc "This is example text.\nIf you like this text, it can be your font."] example + $w_example conf -state disabled + pack $w.example.l -fill x + pack $w_example -fill x + pack $w.example -fill x -padx 5 + + if {$all_families eq {}} { + set all_families [lsort [font families]] + } + + $w_family tag conf pick + $w_family tag bind pick [cb _pick_family %x %y]\;break + $w_family tag conf cpck -background lightgray + foreach f $all_families { + set sel [list pick] + if {$f eq $f_family} { + lappend sel cpck + } + $w_family insert end "$f\n" $sel + } + $w_family conf -state disabled + _update $this + + trace add variable @f_size write [cb _update] + bind $w [list destroy $w] + bind $w [cb _select]\;break + bind $w " + grab $w + focus $w + " + tkwait window $w +} + +method _select {} { + upvar #0 $v_family pv_family + upvar #0 $v_size pv_size + + set pv_family $f_family + set pv_size $f_size + + destroy $w +} + +method _pick_family {x y} { + variable all_families + + set i [lindex [split [$w_family index @$x,$y] .] 0] + set n [lindex $all_families [expr {$i - 1}]] + if {$n ne {}} { + $w_family tag remove cpck 0.0 end + $w_family tag add cpck $i.0 [expr {$i + 1}].0 + set f_family $n + _update $this + } +} + +method _update {args} { + variable all_families + + set i [lsearch -exact $all_families $f_family] + if {$i < 0} return + + $w_example tag conf example -font [list $f_family $f_size] + $w_family see [expr {$i + 1}].0 +} + +} diff --git a/lib/option.tcl b/lib/option.tcl index aa9f783..063f5df 100644 --- a/lib/option.tcl +++ b/lib/option.tcl @@ -255,17 +255,23 @@ proc do_options {} { frame $w.global.$name label $w.global.$name.l -text "$text:" - pack $w.global.$name.l -side left -anchor w -fill x - eval tk_optionMenu $w.global.$name.family \ - global_config_new(gui.$font^^family) \ - $all_fonts - spinbox $w.global.$name.size \ - -textvariable global_config_new(gui.$font^^size) \ - -from 2 -to 80 -increment 1 \ - -width 3 - bind $w.global.$name.size {%W selection range 0 end} - pack $w.global.$name.size -side right -anchor e - pack $w.global.$name.family -side right -anchor e + button $w.global.$name.b \ + -text [mc "Change Font"] \ + -command [list \ + choose_font::pick \ + $w \ + [mc "Choose %s" $text] \ + global_config_new(gui.$font^^family) \ + global_config_new(gui.$font^^size) \ + ] + label $w.global.$name.f -textvariable global_config_new(gui.$font^^family) + label $w.global.$name.s -textvariable global_config_new(gui.$font^^size) + label $w.global.$name.pt -text [mc "pt."] + pack $w.global.$name.l -side left -anchor w + pack $w.global.$name.b -side right -anchor e + pack $w.global.$name.pt -side right -anchor w + pack $w.global.$name.s -side right -anchor w + pack $w.global.$name.f -side right -anchor w pack $w.global.$name -side top -anchor w -fill x } -- cgit v0.10.2-6-g49f6 From 042f53c569c92b40e63c6993c8998d2aac22e383 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Thu, 13 Sep 2007 19:50:35 -0400 Subject: git-gui: Provide 'uninstall' Makefile target to undo an installation Several users have requested a "make uninstall" target be provided in the stock git-gui Makefile so that they can undo an install if git-gui goes to the wrong place during the initial install, or if they are unhappy with the tool and want to remove it from their system. We currently assume that the complete set of files we need to delete are those defined by our Makefile and current source directory. This could differ from what the user actually has installed if they installed one version then attempt to use another to perform the uninstall. Right now I'm just going to say that is "pilot error". Users should uninstall git-gui using the same version of source that they used to make the installation. Perhaps in the future we could read tclIndex and base our uninstall decisions on its contents. Signed-off-by: Shawn O. Pearce diff --git a/Makefile b/Makefile index f11cf26..18e6750 100644 --- a/Makefile +++ b/Makefile @@ -31,6 +31,9 @@ ifndef INSTALL INSTALL = install endif +RM_F ?= rm -f +RMDIR ?= rmdir + INSTALL_D0 = $(INSTALL) -d -m755 # space is required here INSTALL_D1 = INSTALL_R0 = $(INSTALL) -m644 # space is required here @@ -42,6 +45,12 @@ INSTALL_L1 = && ln # space is required here INSTALL_L2 = INSTALL_L3 = +REMOVE_D0 = $(RMDIR) # space is required here +REMOVE_D1 = || true +REMOVE_F0 = $(RM_F) # space is required here +REMOVE_F1 = +CLEAN_DST = true + ifndef V QUIET = @ QUIET_GEN = $(QUIET)echo ' ' GEN $@ && @@ -60,6 +69,12 @@ ifndef V INSTALL_L1 = && src= INSTALL_L2 = && dst= INSTALL_L3 = && echo ' ' 'LINK ' `basename "$$dst"` '->' `basename "$$src"` && rm -f "$$dst" && ln "$$src" "$$dst" + + CLEAN_DST = echo ' ' UNINSTALL + REMOVE_D0 = dir= + REMOVE_D1 = && echo ' ' REMOVE $$dir && test -d "$$dir" && $(RMDIR) "$$dir" || true + REMOVE_F0 = dst= + REMOVE_F1 = && echo ' ' REMOVE `basename "$$dst"` && $(RM_F) "$$dst" endif TCL_PATH ?= tclsh @@ -146,6 +161,17 @@ install: all $(QUIET)$(INSTALL_R0)lib/tclIndex $(INSTALL_R1) '$(DESTDIR_SQ)$(libdir_SQ)' $(QUIET)$(foreach p,$(ALL_LIBFILES), $(INSTALL_R0)$p $(INSTALL_R1) '$(DESTDIR_SQ)$(libdir_SQ)' &&) true +uninstall: + $(QUIET)$(CLEAN_DST) '$(DESTDIR_SQ)$(gitexecdir_SQ)' + $(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/git-gui $(REMOVE_F1) + $(QUIET)$(foreach p,$(GITGUI_BUILT_INS), $(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/$p $(REMOVE_F1) &&) true + $(QUIET)$(CLEAN_DST) '$(DESTDIR_SQ)$(libdir_SQ)' + $(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(libdir_SQ)'/tclIndex $(REMOVE_F1) + $(QUIET)$(foreach p,$(ALL_LIBFILES), $(REMOVE_F0)'$(DESTDIR_SQ)$(libdir_SQ)'/$(notdir $p) $(REMOVE_F1) &&) true + $(QUIET)$(REMOVE_D0)'$(DESTDIR_SQ)$(gitexecdir_SQ)' $(REMOVE_D1) + $(QUIET)$(REMOVE_D0)'$(DESTDIR_SQ)$(libdir_SQ)' $(REMOVE_D1) + $(QUIET)$(REMOVE_D0)`dirname '$(DESTDIR_SQ)$(libdir_SQ)'` $(REMOVE_D1) + dist-version: @mkdir -p $(TARDIR) @echo $(GITGUI_VERSION) > $(TARDIR)/version @@ -154,6 +180,6 @@ clean:: rm -f $(ALL_PROGRAMS) lib/tclIndex rm -f GIT-VERSION-FILE GIT-GUI-VARS -.PHONY: all install dist-version clean +.PHONY: all install uninstall dist-version clean .PHONY: .FORCE-GIT-VERSION-FILE .PHONY: .FORCE-GIT-GUI-VARS -- cgit v0.10.2-6-g49f6 From 55bad4f096b1f18eec94169c864c39bf0abda1db Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Thu, 13 Sep 2007 20:08:53 -0400 Subject: git-gui: Paper bag fix "Commit->Revert" format arguments The recent bug fix to correctly handle filenames with %s (or any other valid Tcl format specifier) missed a \ on this line and caused the remaining format arguments to not be supplied when we updated the status bar. This caused a Tcl error anytime the user was trying to perform a file revert. Signed-off-by: Shawn O. Pearce diff --git a/lib/index.tcl b/lib/index.tcl index cbbce13..44689ab 100644 --- a/lib/index.tcl +++ b/lib/index.tcl @@ -168,7 +168,7 @@ proc checkout_index {msg pathList after} { ui_status [format \ "%s... %i/%i files (%.2f%%)" \ - $msg + $msg \ $update_index_cp \ $totalCnt \ 0.0] -- cgit v0.10.2-6-g49f6 From 3849bfba84fb5b0e9d46920f62105b4e1dd97e63 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Sun, 16 Sep 2007 23:12:19 -0400 Subject: git-gui: Disable native platform text selection in "lists" Sometimes we use a Tk text widget as though it were a listbox. This happens typically when we want to show an icon to the left of the text label or just when a text widget is generally a better choice then the native listbox widget. In these cases if we want the user to have control over the selection we implement our own "in_sel" tag that shows the selected region and we perform our own selection management in the background via keybindings and mouse bindings. In such uses we don't want the user to be able to activate the native platform selection by dragging their mouse through the text widget. Doing so creates a very confusing display and the user is left wondering what it may mean to have two different types of selection in the same widget. Tk doesn't allow us to delete the "sel" tag that it uses internally to manage the native selection but it will allow us to make it invisible by setting the tag to have the same display properties as unselected text. So long as we don't actually use the "sel" tag for anything in code its effectively invisible. Signed-off-by: Shawn O. Pearce diff --git a/git-gui.sh b/git-gui.sh index 31a36cb..f789e91 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -481,6 +481,16 @@ proc tk_optionMenu {w varName args} { return $m } +proc rmsel_tag {text} { + $text tag conf sel \ + -background [$text cget -background] \ + -foreground [$text cget -foreground] \ + -borderwidth 0 + $text tag conf in_sel -background lightgray + bind $text break + return $text +} + ###################################################################### ## ## find git @@ -2151,8 +2161,8 @@ pack $ui_workdir -side left -fill both -expand 1 .vpane.files add .vpane.files.workdir -sticky nsew foreach i [list $ui_index $ui_workdir] { - $i tag conf in_diff -background lightgray - $i tag conf in_sel -background lightgray + rmsel_tag $i + $i tag conf in_diff -background [$i tag cget in_sel -background] } unset i diff --git a/lib/browser.tcl b/lib/browser.tcl index 888db3c..3134900 100644 --- a/lib/browser.tcl +++ b/lib/browser.tcl @@ -47,9 +47,7 @@ constructor new {commit {path {}}} { -width 70 \ -xscrollcommand [list $w.list.sbx set] \ -yscrollcommand [list $w.list.sby set] - $w_list tag conf in_sel \ - -background [$w_list cget -foreground] \ - -foreground [$w_list cget -background] + rmsel_tag $w_list scrollbar $w.list.sbx -orient h -command [list $w_list xview] scrollbar $w.list.sby -orient v -command [list $w_list yview] pack $w.list.sbx -side bottom -fill x diff --git a/lib/choose_font.tcl b/lib/choose_font.tcl index b69215c..0c4051b 100644 --- a/lib/choose_font.tcl +++ b/lib/choose_font.tcl @@ -62,6 +62,7 @@ constructor pick {path title a_family a_size} { -width 30 \ -height 10 \ -yscrollcommand [list $w.inner.family.sby set] + rmsel_tag $w_family scrollbar $w.inner.family.sby -command [list $w_family yview] pack $w.inner.family.l -side top -fill x pack $w.inner.family.sby -side right -fill y @@ -95,6 +96,7 @@ constructor pick {path title a_family a_size} { -relief sunken \ -height 3 \ -width 40 + rmsel_tag $w_example $w_example tag conf example -justify center $w_example insert end [mc "This is example text.\nIf you like this text, it can be your font."] example $w_example conf -state disabled @@ -108,11 +110,10 @@ constructor pick {path title a_family a_size} { $w_family tag conf pick $w_family tag bind pick [cb _pick_family %x %y]\;break - $w_family tag conf cpck -background lightgray foreach f $all_families { set sel [list pick] if {$f eq $f_family} { - lappend sel cpck + lappend sel in_sel } $w_family insert end "$f\n" $sel } @@ -145,8 +146,8 @@ method _pick_family {x y} { set i [lindex [split [$w_family index @$x,$y] .] 0] set n [lindex $all_families [expr {$i - 1}]] if {$n ne {}} { - $w_family tag remove cpck 0.0 end - $w_family tag add cpck $i.0 [expr {$i + 1}].0 + $w_family tag remove in_sel 0.0 end + $w_family tag add in_sel $i.0 [expr {$i + 1}].0 set f_family $n _update $this } -- cgit v0.10.2-6-g49f6