From 9c898a18ea37aa04a84c3a2d18794cf892862702 Mon Sep 17 00:00:00 2001 From: Heiko Voigt Date: Sun, 7 Feb 2010 22:47:56 +0100 Subject: [PATCH 01/11] git-gui: check whether systems nice command works or disable it This fixes issue 394 from msysgit. It seems that the Gnuwin32 project provides a nice command but it returns a "not implemented" error. To help users we now try to execute once and disable it in case it fails. Signed-off-by: Heiko Voigt Signed-off-by: Shawn O. Pearce --- git-gui.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/git-gui.sh b/git-gui.sh index 85fbc021fe..549f59ba73 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -388,6 +388,9 @@ proc _lappend_nice {cmd_var} { if {![info exists _nice]} { set _nice [_which nice] + if {[catch {exec $_nice git version}]} { + set _nice {} + } } if {$_nice ne {}} { lappend cmd $_nice From 13a3d637b2d83fceb432fe7b9e21f8c4d882fa41 Mon Sep 17 00:00:00 2001 From: Pat Thoyts Date: Sat, 10 Jul 2010 23:40:59 +0100 Subject: [PATCH 02/11] git-gui: Handle failure of core.worktree to identify the working directory. Commit 21985a11 'git-gui: handle non-standard worktree locations' attempts to use either GIT_WORK_TREE or core.worktree to set the _gitworktree variable but these may not be set which leads to a failure to launch gitk to review history. Use _gitdir to set the location for a standard git layout where the parent of the .git directory is the working tree. Signed-off-by: Pat Thoyts --- git-gui.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/git-gui.sh b/git-gui.sh index 8996d2d6bc..ec81b15595 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -1158,6 +1158,9 @@ apply_config # try to set work tree from environment, falling back to core.worktree if {[catch { set _gitworktree $env(GIT_WORK_TREE) }]} { set _gitworktree [get_config core.worktree] + if {$_gitworktree eq ""} { + set _gitworktree [file dirname [file normalize $_gitdir]] + } } if {$_prefix ne {}} { if {$_gitworktree eq {}} { From b963d11827c79fbd14f5b4438cca8298145192be Mon Sep 17 00:00:00 2001 From: Heiko Voigt Date: Sat, 20 Feb 2010 14:38:38 +0100 Subject: [PATCH 03/11] git-gui: fix usage of themed widgets variable There was one forgotten global so NS was not visible to the method which resulted in an error. Signed-off-by: Heiko Voigt --- lib/status_bar.tcl | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/status_bar.tcl b/lib/status_bar.tcl index 5fe3aad382..95cb44991f 100644 --- a/lib/status_bar.tcl +++ b/lib/status_bar.tcl @@ -39,6 +39,7 @@ method _oneline_pack {} { } constructor two_line {path} { + global NS set w $path set w_l $w.l set w_c $w.c From 2e0cda658e08482b804718bfa0f3e64e7af17ea7 Mon Sep 17 00:00:00 2001 From: Markus Heidelberg Date: Thu, 25 Feb 2010 01:14:22 +0100 Subject: [PATCH 04/11] git-gui: fix "Explore Working Copy" for Windows again It has already been fixed in commit 454efb47 (git-gui (Win): make "Explore Working Copy" more robust, 2009-04-01), but has been broken in commit 21985a11 (git-gui: handle non-standard worktree locations, 2010-01-23) by accidentally replacing too much with a new variable. The problem can be reproduced when starting git-gui from within a subdirectory. The solution is to convert the path name, explorer.exe is invoked with, to a platform native name. Signed-off-by: Markus Heidelberg Signed-off-by: Pat Thoyts --- git-gui.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-gui.sh b/git-gui.sh index ec81b15595..ed8bbe1804 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -2104,7 +2104,7 @@ proc do_explore {} { # freedesktop.org-conforming system is our best shot set explorer "xdg-open" } - eval exec $explorer $_gitworktree & + eval exec $explorer [list [file nativename $_gitworktree]] & } set is_quitting 0 From a197b1e89a1c779e69c5ce8746f13b48158030ac Mon Sep 17 00:00:00 2001 From: Heiko Voigt Date: Sat, 27 Feb 2010 21:45:51 +0100 Subject: [PATCH 05/11] git-gui: fix usage of _gitworktree when creating shortcut for windows This fixes msysGit issue 425. Signed-off-by: Heiko Voigt Signed-off-by: Johannes Schindelin Signed-off-by: Pat Thoyts --- lib/shortcut.tcl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/shortcut.tcl b/lib/shortcut.tcl index 79c1888e11..78878ef89d 100644 --- a/lib/shortcut.tcl +++ b/lib/shortcut.tcl @@ -16,7 +16,7 @@ proc do_windows_shortcut {} { [info nameofexecutable] \ [file normalize $::argv0] \ ] \ - [file normalize [$_gitworktree]] + [file normalize $_gitworktree] } err]} { error_popup [strcat [mc "Cannot write shortcut:"] "\n\n$err"] } @@ -57,7 +57,7 @@ proc do_cygwin_shortcut {} { $sh -c \ "CHERE_INVOKING=1 source /etc/profile;[sq $me] &" \ ] \ - [file normalize [$_gitworktree]] + [file normalize $_gitworktree] } err]} { error_popup [strcat [mc "Cannot write shortcut:"] "\n\n$err"] } From 4c79adc5c05de52a08f5e8a9615c9d6c9fe9a991 Mon Sep 17 00:00:00 2001 From: Heiko Voigt Date: Sat, 27 Feb 2010 21:47:42 +0100 Subject: [PATCH 06/11] git-gui: fix PATH environment for mingw development environment When creating a desktop shortcut from the gui the shortcut directly starts wish with the git-gui script. In the msysgit development environment some dll's reside in the mingw/bin directory which causes that git can not start because libiconv2.dll is not found. When using such a link the error is even more cryptic stating: "child killed: unknown signal" Signed-off-by: Heiko Voigt Signed-off-by: Johannes Schindelin Signed-off-by: Pat Thoyts --- windows/git-gui.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/windows/git-gui.sh b/windows/git-gui.sh index 66bbb2f8fa..b1845c5055 100644 --- a/windows/git-gui.sh +++ b/windows/git-gui.sh @@ -13,10 +13,11 @@ if { $argc >=2 && [lindex $argv 0] == "--working-dir" } { incr argc -2 } -set bindir [file dirname \ +set basedir [file dirname \ [file dirname \ [file dirname [info script]]]] -set bindir [file join $bindir bin] +set bindir [file join $basedir bin] +set bindir "$bindir;[file join $basedir mingw bin]" regsub -all ";" $bindir "\\;" bindir set env(PATH) "$bindir;$env(PATH)" unset bindir From fc17e5e5bdb5b4a36c10c2948b8b8db8a12a4b35 Mon Sep 17 00:00:00 2001 From: Heiko Voigt Date: Sat, 27 Feb 2010 21:48:48 +0100 Subject: [PATCH 07/11] git-gui: fix shortcut creation on cygwin When the user tried to create a desktop icon with git gui on cygwin wscript was complaining about an unknown option and displaying the non-native path as such. Signed-off-by: Heiko Voigt Signed-off-by: Johannes Schindelin Signed-off-by: Pat Thoyts --- lib/win32.tcl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/win32.tcl b/lib/win32.tcl index d7f93d045d..db91ab84a5 100644 --- a/lib/win32.tcl +++ b/lib/win32.tcl @@ -18,9 +18,9 @@ proc win32_create_lnk {lnk_path lnk_exec lnk_dir} { eval [list exec wscript.exe \ /E:jscript \ /nologo \ - [file join $oguilib win32_shortcut.js] \ + [file nativename [file join $oguilib win32_shortcut.js]] \ $lnk_path \ - [file join $oguilib git-gui.ico] \ + [file nativename [file join $oguilib git-gui.ico]] \ $lnk_dir \ $lnk_exec] $lnk_args } From 85123549f005ebdfb55a5cbd738c3237aaed6eff Mon Sep 17 00:00:00 2001 From: Pat Thoyts Date: Mon, 8 Mar 2010 12:43:27 +0000 Subject: [PATCH 08/11] git-gui: Avoid using the <> binding as a menu accelerator on win32 On Windows the Control-C binding is used to copy and is mapped to the Tk virtual event <>. In the initial git-gui dialog this is also bound as an accelerator for the Clone menu item. The effect is that both bindings run, copying the text but resetting the clone page or switching to the clone page when the user tries to copy text from one of the entry fields. This patch avoids this by using Control-L instead for Windows only. Signed-off-by: Pat Thoyts --- lib/choose_repository.tcl | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/choose_repository.tcl b/lib/choose_repository.tcl index 64f06748b6..fae119286d 100644 --- a/lib/choose_repository.tcl +++ b/lib/choose_repository.tcl @@ -100,12 +100,17 @@ constructor pick {} { $opts insert end [mc "Clone Existing Repository"] link_clone $opts insert end "\n" if {$m_repo ne {}} { + if {[tk windowingsystem] eq "win32"} { + set key L + } else { + set key C + } $m_repo add command \ -command [cb _next clone] \ - -accelerator $M1T-C \ + -accelerator $M1T-$key \ -label [mc "Clone..."] - bind $top <$M1B-c> [cb _next clone] - bind $top <$M1B-C> [cb _next clone] + bind $top <$M1B-[string tolower $key]> [cb _next clone] + bind $top <$M1B-[string toupper $key]> [cb _next clone] } $opts tag conf link_open -foreground blue -underline 1 From 1fbaccad4dd8d6a9a893843c73f3e47c4ba8b717 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Poulain?= Date: Fri, 30 Jul 2010 09:11:02 +0100 Subject: [PATCH 09/11] git-gui: use textconv filter for diff and blame MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Create a checkbox "Use Textconv For Diffs and Blame" in git-gui options. If checked and if the driver for the concerned file exists, git-gui calls diff and blame with --textconv option Signed-off-by: Clément Poulain Signed-off-by: Diane Gasselin Signed-off-by: Axel Bonnet Signed-off-by: Matthieu Moy Signed-off-by: Pat Thoyts --- git-gui.sh | 28 +++++++++++++++++++++++++++- lib/blame.tcl | 21 +++++++++++++++++++-- lib/diff.tcl | 5 ++++- lib/option.tcl | 1 + 4 files changed, 51 insertions(+), 4 deletions(-) diff --git a/git-gui.sh b/git-gui.sh index ed8bbe1804..88b3f8a086 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -269,6 +269,17 @@ proc is_config_true {name} { } } +proc is_config_false {name} { + global repo_config + if {[catch {set v $repo_config($name)}]} { + return 0 + } elseif {$v eq {false} || $v eq {0} || $v eq {no}} { + return 1 + } else { + return 0 + } +} + proc get_config {name} { global repo_config if {[catch {set v $repo_config($name)}]} { @@ -785,6 +796,7 @@ set default_config(user.email) {} set default_config(gui.encoding) [encoding system] set default_config(gui.matchtrackingbranch) false +set default_config(gui.textconv) true set default_config(gui.pruneduringfetch) false set default_config(gui.trustmtime) false set default_config(gui.fastcopyblame) false @@ -3411,6 +3423,19 @@ lappend diff_actions [list $ctxmsm entryconf [$ctxmsm index last] -state] $ctxmsm add separator create_common_diff_popup $ctxmsm +proc has_textconv {path} { + if {[is_config_false gui.textconv]} { + return 0 + } + set filter [gitattr $path diff set] + set textconv [get_config [join [list diff $filter textconv] .]] + if {$filter ne {set} && $textconv ne {}} { + return 1 + } else { + return 0 + } +} + proc popup_diff_menu {ctxm ctxmmg ctxmsm x y X Y} { global current_diff_path file_states set ::cursorX $x @@ -3446,7 +3471,8 @@ proc popup_diff_menu {ctxm ctxmmg ctxmsm x y X Y} { || {__} eq $state || {_O} eq $state || {_T} eq $state - || {T_} eq $state} { + || {T_} eq $state + || [has_textconv $current_diff_path]} { set s disabled } else { set s normal diff --git a/lib/blame.tcl b/lib/blame.tcl index 786b50b8c2..2137ec9684 100644 --- a/lib/blame.tcl +++ b/lib/blame.tcl @@ -449,11 +449,28 @@ method _load {jump} { $status show [mc "Reading %s..." "$commit:[escape_path $path]"] $w_path conf -text [escape_path $path] + + set do_textconv 0 + if {![is_config_false gui.textconv] && [git-version >= 1.7.2]} { + set filter [gitattr $path diff set] + set textconv [get_config [join [list diff $filter textconv] .]] + if {$filter ne {set} && $textconv ne {}} { + set do_textconv 1 + } + } if {$commit eq {}} { - set fd [open $path r] + if {$do_textconv ne 0} { + set fd [open |[list $textconv $path] r] + } else { + set fd [open $path r] + } fconfigure $fd -eofchar {} } else { - set fd [git_read cat-file blob "$commit:$path"] + if {$do_textconv ne 0} { + set fd [git_read cat-file --textconv "$commit:$path"] + } else { + set fd [git_read cat-file blob "$commit:$path"] + } } fconfigure $fd \ -blocking 0 \ diff --git a/lib/diff.tcl b/lib/diff.tcl index ec8c11eeb7..c628750276 100644 --- a/lib/diff.tcl +++ b/lib/diff.tcl @@ -55,7 +55,7 @@ proc handle_empty_diff {} { set path $current_diff_path set s $file_states($path) - if {[lindex $s 0] ne {_M}} return + if {[lindex $s 0] ne {_M} || [has_textconv $path]} return # Prevent infinite rescan loops incr diff_empty_count @@ -280,6 +280,9 @@ proc start_show_diff {cont_info {add_opts {}}} { lappend cmd diff-files } } + if {![is_config_false gui.textconv] && [git-version >= 1.6.1]} { + lappend cmd --textconv + } if {[string match {160000 *} [lindex $s 2]] || [string match {160000 *} [lindex $s 3]]} { diff --git a/lib/option.tcl b/lib/option.tcl index d4c5e45c8a..3807c8d283 100644 --- a/lib/option.tcl +++ b/lib/option.tcl @@ -148,6 +148,7 @@ proc do_options {} { {b gui.trustmtime {mc "Trust File Modification Timestamps"}} {b gui.pruneduringfetch {mc "Prune Tracking Branches During Fetch"}} {b gui.matchtrackingbranch {mc "Match Tracking Branches"}} + {b gui.textconv {mc "Use Textconv For Diffs and Blames"}} {b gui.fastcopyblame {mc "Blame Copy Only On Changed Files"}} {i-20..200 gui.copyblamethreshold {mc "Minimum Letters To Blame Copy On"}} {i-0..300 gui.blamehistoryctx {mc "Blame History Context Radius (days)"}} From 9cb268c426ccb2bb836418caad669476b5dd1933 Mon Sep 17 00:00:00 2001 From: Pat Thoyts Date: Mon, 2 Aug 2010 12:13:05 +0100 Subject: [PATCH 10/11] git-gui: mc cannot be used before msgcat has been loaded If someone attempts to use an older version that Tk 8.4 the error was masked by the lack of a mc command. Signed-off-by: Pat Thoyts --- git-gui.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-gui.sh b/git-gui.sh index 88b3f8a086..c3f6736132 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -38,7 +38,7 @@ if {[catch {package require Tcl 8.4} err] tk_messageBox \ -icon error \ -type ok \ - -title [mc "git-gui: fatal error"] \ + -title "git-gui: fatal error" \ -message $err exit 1 } From 2810a58dba6d06f4d1816fb06500c117feebd830 Mon Sep 17 00:00:00 2001 From: Pat Thoyts Date: Mon, 2 Aug 2010 13:42:45 +0100 Subject: [PATCH 11/11] git-gui: fix size and position of window panes on startup The themed panedwindow needs to have the sash position set after the widget has been mapped therefore apply this setting in the Map event binding. To avoid visible redraws as the application is constructed the main window should be withdrawn until all the widgets have been added Signed-off-by: Pat Thoyts --- git-gui.sh | 55 ++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 37 insertions(+), 18 deletions(-) diff --git a/git-gui.sh b/git-gui.sh index c3f6736132..bb104895a9 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -334,6 +334,8 @@ proc _trace_exec {cmd} { puts stderr $d } +#'" fix poor old emacs font-lock mode + proc _git_cmd {name} { global _git_cmd_path @@ -648,6 +650,7 @@ proc rmsel_tag {text} { return $text } +wm withdraw . set root_exists 0 bind . { bind . {} @@ -2919,6 +2922,7 @@ blame { set current_branch $head } + wm deiconify . switch -- $subcommand { browser { if {$jump_spec ne {}} usage @@ -3492,29 +3496,44 @@ $main_status show [mc "Initializing..."] # -- Load geometry # -catch { -set gm $repo_config(gui.geometry) -wm geometry . [lindex $gm 0] -if {$use_ttk} { - .vpane sashpos 0 [lindex $gm 1] - .vpane.files sashpos 0 [lindex $gm 2] -} else { - .vpane sash place 0 \ - [lindex $gm 1] \ - [lindex [.vpane sash coord 0] 1] - .vpane.files sash place 0 \ - [lindex [.vpane.files sash coord 0] 0] \ - [lindex $gm 2] +proc on_ttk_pane_mapped {w pane pos} { + bind $w {} + after 0 [list after idle [list $w sashpos $pane $pos]] } -unset gm +proc on_tk_pane_mapped {w pane x y} { + bind $w {} + after 0 [list after idle [list $w sash place $pane $x $y]] +} +proc on_application_mapped {} { + global repo_config use_ttk + bind . {} + set gm $repo_config(gui.geometry) + if {$use_ttk} { + bind .vpane \ + [list on_ttk_pane_mapped %W 0 [lindex $gm 1]] + bind .vpane.files \ + [list on_ttk_pane_mapped %W 0 [lindex $gm 2]] + } else { + bind .vpane \ + [list on_tk_pane_mapped %W 0 \ + [lindex $gm 1] \ + [lindex [.vpane sash coord 0] 1]] + bind .vpane.files \ + [list on_tk_pane_mapped %W 0 \ + [lindex [.vpane.files sash coord 0] 0] \ + [lindex $gm 2]] + } + wm geometry . [lindex $gm 0] +} +if {[info exists repo_config(gui.geometry)]} { + bind . [list on_application_mapped] + wm geometry . [lindex $repo_config(gui.geometry) 0] } # -- Load window state # -catch { -set gws $repo_config(gui.wmstate) -wm state . $gws -unset gws +if {[info exists repo_config(gui.wmstate)]} { + catch {wm state . $repo_config(gui.wmstate)} } # -- Key Bindings