Code

git gui: show diffs with a minimum of 1 context line
[git.git] / git-gui.sh
index 940677cbd8558574fd9f9fb5812a0bbf46198588..86402d49f72c56d793f2f1958a9e3d3f8300f367 100755 (executable)
@@ -52,7 +52,11 @@ catch {rename send {}} ; # What an evil concept...
 set oguilib {@@GITGUI_LIBDIR@@}
 set oguirel {@@GITGUI_RELATIVE@@}
 if {$oguirel eq {1}} {
-       set oguilib [file dirname [file dirname [file normalize $argv0]]]
+       set oguilib [file dirname [file normalize $argv0]]
+       if {[file tail $oguilib] eq {git-core}} {
+               set oguilib [file dirname $oguilib]
+       }
+       set oguilib [file dirname $oguilib]
        set oguilib [file join $oguilib share git-gui lib]
        set oguimsg [file join $oguilib msgs]
 } elseif {[string match @@* $oguirel]} {
@@ -317,7 +321,7 @@ proc _git_cmd {name} {
        return $v
 }
 
-proc _which {what} {
+proc _which {what args} {
        global env _search_exe _search_path
 
        if {$_search_path eq {}} {
@@ -340,8 +344,14 @@ proc _which {what} {
                }
        }
 
+       if {[is_Windows] && [lsearch -exact $args -script] >= 0} {
+               set suffix {}
+       } else {
+               set suffix $_search_exe
+       }
+
        foreach p $_search_path {
-               set p [file join $p $what$_search_exe]
+               set p [file join $p $what$suffix]
                if {[file exists $p]} {
                        return [file normalize $p]
                }
@@ -473,10 +483,10 @@ proc githook_read {hook_name args} {
        set pchook [gitdir hooks $hook_name]
        lappend args 2>@1
 
-       # On Cygwin [file executable] might lie so we need to ask
+       # On Windows [file executable] might lie so we need to ask
        # the shell if the hook is executable.  Yes that's annoying.
        #
-       if {[is_Cygwin]} {
+       if {[is_Windows]} {
                upvar #0 _sh interp
                if {![info exists interp]} {
                        set interp [_which sh]
@@ -497,6 +507,20 @@ proc githook_read {hook_name args} {
        return {}
 }
 
+proc kill_file_process {fd} {
+       set process [pid $fd]
+
+       catch {
+               if {[is_Windows]} {
+                       # Use a Cygwin-specific flag to allow killing
+                       # native Windows processes
+                       exec kill -f $process
+               } else {
+                       exec kill $process
+               }
+       }
+}
+
 proc sq {value} {
        regsub -all ' $value "'\\''" value
        return "'$value'"
@@ -642,6 +666,8 @@ set default_config(user.email) {}
 set default_config(gui.matchtrackingbranch) false
 set default_config(gui.pruneduringfetch) false
 set default_config(gui.trustmtime) false
+set default_config(gui.fastcopyblame) false
+set default_config(gui.copyblamethreshold) 40
 set default_config(gui.diffcontext) 5
 set default_config(gui.commitmsgwidth) 75
 set default_config(gui.newbranchtemplate) {}
@@ -1670,10 +1696,10 @@ proc do_gitk {revs} {
        # -- Always start gitk through whatever we were loaded with.  This
        #    lets us bypass using shell process on Windows systems.
        #
-       set exe [file join [file dirname $::_git] gitk]
+       set exe [_which gitk -script]
        set cmd [list [info nameofexecutable] $exe]
-       if {! [file exists $exe]} {
-               error_popup [mc "Unable to start gitk:\n\n%s does not exist" $exe]
+       if {$exe eq {}} {
+               error_popup [mc "Couldn't find gitk in PATH"]
        } else {
                global env
 
@@ -1906,7 +1932,7 @@ proc show_more_context {} {
 
 proc show_less_context {} {
        global repo_config
-       if {$repo_config(gui.diffcontext) >= 1} {
+       if {$repo_config(gui.diffcontext) > 1} {
                incr repo_config(gui.diffcontext) -1
                reshow_diff
        }
@@ -2909,6 +2935,7 @@ if {[is_enabled transport]} {
        populate_fetch_menu
        set n [expr {[.mbar.remote index end] - $n}]
        if {$n > 0} {
+               if {[.mbar.remote type 0] eq "tearoff"} { incr n }
                .mbar.remote insert $n separator
        }
        unset n