{"thread":{"id":"25631","subject":"[PULL] request pull for git-gui","startedAt":"2010-11-03T19:17:19Z","lastAt":"2010-11-05T17:41:19Z","messageCount":2,"participants":["Pat Thoyts","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"155081","messageId":"87bp66nrnk.fsf@fox.patthoyts.tk","threadId":"25631","inReplyTo":null,"subject":"[PULL] request pull for git-gui","fromName":"Pat Thoyts","fromEmail":"patthoyts@users.sourceforge.net","sentAt":"2010-11-03T19:17:19Z","receivedAt":"2010-11-03T19:17:19Z","isPatch":false,"sender":{"key":"patthoyts@users.sourceforge.net","avatar":"https://avatars.githubusercontent.com/u/30739?v=4"},"body":"Junio, please pull the master branch from the git-gui repository. This\ncontains some fixes for Windows and the color parsing that was discussed\non list recently.\n\nThe following changes since commit 00e9de72c8f9b7c048bb56a59be9567d69dc1e01:\n\n  git-gui 0.13 (2010-09-14 22:42:37 +0100)\n\nare available in the git repository at:\n  git://repo.or.cz/git-gui.git master\n\nPat Thoyts (7):\n      git-gui: show command-line errors in a messagebox on Windows\n      git-gui: enable the Tk console when tracing/debugging on Windows\n      git-gui: generic version trimming\n      git-gui: use full dialog width for old name when renaming branch\n      git-gui: correct assignment of work-tree\n      git-gui: use wordprocessor tab style to ensure tabs work as expected\n      git-gui: apply color information from git diff output\n\nSebastian Schuberth (1):\n      On Windows, avoid git-gui to call Cygwin's nice utility\n\n git-gui.sh            |   77 +++++++++++++++++++++++++++++++++++-------------\n lib/branch_rename.tcl |    2 +-\n lib/diff.tcl          |   34 +++++++++++++++++++++-\n 3 files changed, 90 insertions(+), 23 deletions(-)\n\ndiff --git a/git-gui.sh b/git-gui.sh\nindex 4617f29..d3acf0d 100755\n--- a/git-gui.sh\n+++ b/git-gui.sh\n@@ -83,6 +83,7 @@ if {![catch {set _verbose $env(GITGUI_VERBOSE)}]} {\n \t\tputs stderr \"source    $name\"\n \t\tuplevel 1 real__source $name\n \t}\n+\tif {[tk windowingsystem] eq \"win32\"} { console show }\n }\n \n ######################################################################\n@@ -444,6 +445,8 @@ proc _lappend_nice {cmd_var} {\n \t\tset _nice [_which nice]\n \t\tif {[catch {exec $_nice git version}]} {\n \t\t\tset _nice {}\n+\t\t} elseif {[is_Windows] && [file dirname $_nice] ne [file dirname $::_git]} {\n+\t\t\tset _nice {}\n \t\t}\n \t}\n \tif {$_nice ne {}} {\n@@ -673,6 +676,7 @@ bind . <Visibility> {\n if {[is_Windows]} {\n \twm iconbitmap . -default $oguilib/git-gui.ico\n \tset ::tk::AlwaysShowSelection 1\n+\tbind . <Control-F2> {console show}\n \n \t# Spoof an X11 display for SSH\n \tif {![info exists env(DISPLAY)]} {\n@@ -874,12 +878,19 @@ if {![regsub {^git version } $_git_version {} _git_version]} {\n \texit 1\n }\n \n+proc get_trimmed_version {s} {\n+    set r {}\n+    foreach x [split $s -._] {\n+        if {[string is integer -strict $x]} {\n+            lappend r $x\n+        } else {\n+            break\n+        }\n+    }\n+    return [join $r .]\n+}\n set _real_git_version $_git_version\n-regsub -- {[\\-\\.]dirty$} $_git_version {} _git_version\n-regsub {\\.[0-9]+\\.g[0-9a-f]+$} $_git_version {} _git_version\n-regsub {\\.[a-zA-Z]+\\.?[0-9]+$} $_git_version {} _git_version\n-regsub {\\.GIT$} $_git_version {} _git_version\n-regsub {\\.[a-zA-Z]+\\.?[0-9]+$} $_git_version {} _git_version\n+set _git_version [get_trimmed_version $_git_version]\n \n if {![regexp {^[1-9]+(\\.[0-9]+)+$} $_git_version]} {\n \tcatch {wm withdraw .}\n@@ -1183,13 +1194,22 @@ if {![file isdirectory $_gitdir]} {\n # _gitdir exists, so try loading the config\n load_config 0\n apply_config\n-# try to set work tree from environment, falling back to core.worktree\n-if {[catch { set _gitworktree $env(GIT_WORK_TREE) }]} {\n-\tset _gitworktree [get_config core.worktree]\n-\tif {$_gitworktree eq \"\"} {\n-\t\tset _gitworktree [file dirname [file normalize $_gitdir]]\n+\n+# v1.7.0 introduced --show-toplevel to return the canonical work-tree\n+if {[package vsatisfies $_git_version 1.7.0]} {\n+\tset _gitworktree [git rev-parse --show-toplevel]\n+} else {\n+\t# try to set work tree from environment, core.worktree or use\n+\t# cdup to obtain a relative path to the top of the worktree. If\n+\t# run from the top, the ./ prefix ensures normalize expands pwd.\n+\tif {[catch { set _gitworktree $env(GIT_WORK_TREE) }]} {\n+\t\tset _gitworktree [get_config core.worktree]\n+\t\tif {$_gitworktree eq \"\"} {\n+\t\t\tset _gitworktree [file normalize ./[git rev-parse --show-cdup]]\n+\t\t}\n \t}\n }\n+\n if {$_prefix ne {}} {\n \tif {$_gitworktree eq {}} {\n \t\tregsub -all {[^/]+/} $_prefix ../ cdup\n@@ -2861,7 +2881,8 @@ proc usage {} {\n \tset s \"usage: $::argv0 $::subcommand $::subcommand_args\"\n \tif {[tk windowingsystem] eq \"win32\"} {\n \t\twm withdraw .\n-\t\ttk_messageBox -icon info -title \"Usage\" -message $s\n+\t\ttk_messageBox -icon info -message $s \\\n+\t\t\t-title [mc \"Usage\"]\n \t} else {\n \t\tputs stderr $s\n \t}\n@@ -2934,7 +2955,11 @@ blame {\n \t\t\tif {[catch {\n \t\t\t\t\tset head [git rev-parse --verify $head]\n \t\t\t\t} err]} {\n-\t\t\t\tputs stderr $err\n+\t\t\t\tif {[tk windowingsystem] eq \"win32\"} {\n+\t\t\t\t\ttk_messageBox -icon error -title [mc Error] -message $err\n+\t\t\t\t} else {\n+\t\t\t\t\tputs stderr $err\n+\t\t\t\t}\n \t\t\t\texit 1\n \t\t\t}\n \t\t}\n@@ -2973,18 +2998,19 @@ blame {\n citool -\n gui {\n \tif {[llength $argv] != 0} {\n-\t\tputs -nonewline stderr \"usage: $argv0\"\n-\t\tif {$subcommand ne {gui}\n-\t\t\t&& [file tail $argv0] ne \"git-$subcommand\"} {\n-\t\t\tputs -nonewline stderr \" $subcommand\"\n-\t\t}\n-\t\tputs stderr {}\n-\t\texit 1\n+\t\tusage\n \t}\n \t# fall through to setup UI for commits\n }\n default {\n-\tputs stderr \"usage: $argv0 \\[{blame|browser|citool}\\]\"\n+\tset err \"usage: $argv0 \\[{blame|browser|citool}\\]\"\n+\tif {[tk windowingsystem] eq \"win32\"} {\n+\t\twm withdraw .\n+\t\ttk_messageBox -icon error -message $err \\\n+\t\t\t-title [mc \"Usage\"]\n+\t} else {\n+\t\tputs stderr $err\n+\t}\n \texit 1\n }\n }\n@@ -3286,6 +3312,7 @@ text $ui_diff -background white -foreground black \\\n \t-xscrollcommand {.vpane.lower.diff.body.sbx set} \\\n \t-yscrollcommand {.vpane.lower.diff.body.sby set} \\\n \t-state disabled\n+catch {$ui_diff configure -tabstyle wordprocessor}\n ${NS}::scrollbar .vpane.lower.diff.body.sbx -orient horizontal \\\n \t-command [list $ui_diff xview]\n ${NS}::scrollbar .vpane.lower.diff.body.sby -orient vertical \\\n@@ -3296,8 +3323,16 @@ pack $ui_diff -side left -fill both -expand 1\n pack .vpane.lower.diff.header -side top -fill x\n pack .vpane.lower.diff.body -side bottom -fill both -expand 1\n \n+foreach {n c} {0 black 1 red4 2 green4 3 yellow4 4 blue4 5 magenta4 6 cyan4 7 grey60} {\n+\t$ui_diff tag configure clr4$n -background $c\n+\t$ui_diff tag configure clri4$n -foreground $c\n+\t$ui_diff tag configure clr3$n -foreground $c\n+\t$ui_diff tag configure clri3$n -background $c\n+}\n+$ui_diff tag configure clr1 -font font_diffbold\n+\n $ui_diff tag conf d_cr -elide true\n-$ui_diff tag conf d_@ -foreground blue -font font_diffbold\n+$ui_diff tag conf d_@ -font font_diffbold\n $ui_diff tag conf d_+ -foreground {#00a000}\n $ui_diff tag conf d_- -foreground red\n \ndiff --git a/lib/branch_rename.tcl b/lib/branch_rename.tcl\nindex 6398877..6e510ec 100644\n--- a/lib/branch_rename.tcl\n+++ b/lib/branch_rename.tcl\n@@ -53,7 +53,7 @@ constructor dialog {} {\n \t\t\treturn 1\n \t\t}\n \n-\tgrid $w.rename.oldname_l $w.rename.oldname_m -sticky w  -padx {0 5}\n+\tgrid $w.rename.oldname_l $w.rename.oldname_m -sticky we -padx {0 5}\n \tgrid $w.rename.newname_l $w.rename.newname_t -sticky we -padx {0 5}\n \tgrid columnconfigure $w.rename 1 -weight 1\n \tpack $w.rename -anchor nw -fill x -pady 5 -padx 5\ndiff --git a/lib/diff.tcl b/lib/diff.tcl\nindex c628750..dcf0711 100644\n--- a/lib/diff.tcl\n+++ b/lib/diff.tcl\n@@ -294,7 +294,7 @@ proc start_show_diff {cont_info {add_opts {}}} {\n \t}\n \n \tlappend cmd -p\n-\tlappend cmd --no-color\n+\tlappend cmd --color\n \tif {$repo_config(gui.diffcontext) >= 1} {\n \t\tlappend cmd \"-U$repo_config(gui.diffcontext)\"\n \t}\n@@ -332,6 +332,23 @@ proc start_show_diff {cont_info {add_opts {}}} {\n \tfileevent $fd readable [list read_diff $fd $cont_info]\n }\n \n+proc parse_color_line {line} {\n+\tset start 0\n+\tset result \"\"\n+\tset markup [list]\n+\tset regexp {\\033\\[((?:\\d+;)*\\d+)?m}\n+\twhile {[regexp -indices -start $start $regexp $line match code]} {\n+\t\tforeach {begin end} $match break\n+\t\tappend result [string range $line $start [expr {$begin - 1}]]\n+\t\tlappend markup [string length $result] \\\n+\t\t\t[eval [linsert $code 0 string range $line]]\n+\t\tset start [incr end]\n+\t}\n+\tappend result [string range $line $start end]\n+\tif {[llength $markup] < 4} {set markup {}}\n+\treturn [list $result $markup]\n+}\n+\n proc read_diff {fd cont_info} {\n \tglobal ui_diff diff_active is_submodule_diff\n \tglobal is_3way_diff is_conflict_diff current_diff_header\n@@ -340,6 +357,9 @@ proc read_diff {fd cont_info} {\n \n \t$ui_diff conf -state normal\n \twhile {[gets $fd line] >= 0} {\n+\t\tforeach {line markup} [parse_color_line $line] break\n+\t\tset line [string map {\\033 ^} $line]\n+\n \t\t# -- Cleanup uninteresting diff header lines.\n \t\t#\n \t\tif {$::current_diff_inheader} {\n@@ -434,11 +454,23 @@ proc read_diff {fd cont_info} {\n \t\t\t}\n \t\t\t}\n \t\t}\n+\t\tset mark [$ui_diff index \"end - 1 line linestart\"]\n \t\t$ui_diff insert end $line $tags\n \t\tif {[string index $line end] eq \"\\r\"} {\n \t\t\t$ui_diff tag add d_cr {end - 2c}\n \t\t}\n \t\t$ui_diff insert end \"\\n\" $tags\n+\n+\t\tforeach {posbegin colbegin posend colend} $markup {\n+\t\t\tset prefix clr\n+\t\t\tforeach style [split $colbegin \";\"] {\n+\t\t\t\tif {$style eq \"7\"} {append prefix i; continue}\n+\t\t\t\tif {$style < 30 || $style > 47} {continue}\n+\t\t\t\tset a \"$mark linestart + $posbegin chars\"\n+\t\t\t\tset b \"$mark linestart + $posend chars\"\n+\t\t\t\tcatch {$ui_diff tag add $prefix$style $a $b}\n+\t\t\t}\n+\t\t}\n \t}\n \t$ui_diff conf -state disabled\n \n"},{"id":"155266","messageId":"7vhbfvsm68.fsf@alter.siamese.dyndns.org","threadId":"25631","inReplyTo":"87bp66nrnk.fsf@fox.patthoyts.tk","subject":"Re: [PULL] request pull for git-gui","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-11-05T17:41:19Z","receivedAt":"2010-11-05T17:41:19Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Pat Thoyts <patthoyts@users.sourceforge.net> writes:\n\n> Junio, please pull the master branch from the git-gui repository. This\n> contains some fixes for Windows and the color parsing that was discussed\n> on list recently.\n>\n> The following changes since commit 00e9de72c8f9b7c048bb56a59be9567d69dc1e01:\n>\n>   git-gui 0.13 (2010-09-14 22:42:37 +0100)\n\nThanks; will do.\n"}]}