Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPat Thoyts <patthoyts@users.sourceforge.net>2011-12-09 19:14:32 +0400
committerPat Thoyts <patthoyts@users.sourceforge.net>2011-12-09 19:14:32 +0400
commit7d076d56757c238aa1b90534cd0d2450528b3580 (patch)
tree416957a5a46a6ff8a5acfe38989ed42a19e55aa9
parent215d4fdbaa9d32459cc199667970dc7f63d94982 (diff)
git-gui: handle shell script text filters when loading for blame.
When loading a file into the blame window git-gui does all the work and must handle the text conversion filters if defined. On Windows it is necessary to detect the need for a shell script explicitly. Such filter commands are run using non-blocking I/O but this has the unfortunate side effect of losing any error that might be reported when the pipe is closed. Switching to blocking mode just before closing enables reporting of errors in the filter scripts to the user. Tested-by: Sebastian Schuberth <sschuberth@gmail.com> Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
-rwxr-xr-xgit-gui.sh29
-rw-r--r--lib/blame.tcl19
2 files changed, 37 insertions, 11 deletions
diff --git a/git-gui.sh b/git-gui.sh
index 2c57fb4a6b..ba4e5c1330 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -464,6 +464,35 @@ proc _which {what args} {
return {}
}
+# Test a file for a hashbang to identify executable scripts on Windows.
+proc is_shellscript {filename} {
+ if {![file exists $filename]} {return 0}
+ set f [open $filename r]
+ fconfigure $f -encoding binary
+ set magic [read $f 2]
+ close $f
+ return [expr {$magic eq "#!"}]
+}
+
+# Run a command connected via pipes on stdout.
+# This is for use with textconv filters and uses sh -c "..." to allow it to
+# contain a command with arguments. On windows we must check for shell
+# scripts specifically otherwise just call the filter command.
+proc open_cmd_pipe {cmd path} {
+ global env
+ if {![file executable [shellpath]]} {
+ set exe [auto_execok [lindex $cmd 0]]
+ if {[is_shellscript [lindex $exe 0]]} {
+ set run [linsert [auto_execok sh] end -c "$cmd \"\$0\"" $path]
+ } else {
+ set run [concat $exe [lrange $cmd 1 end] $path]
+ }
+ } else {
+ set run [list [shellpath] -c "$cmd \"\$0\"" $path]
+ }
+ return [open |$run r]
+}
+
proc _lappend_nice {cmd_var} {
global _nice
upvar $cmd_var cmd
diff --git a/lib/blame.tcl b/lib/blame.tcl
index b031e66a4b..324f7744c4 100644
--- a/lib/blame.tcl
+++ b/lib/blame.tcl
@@ -476,14 +476,7 @@ method _load {jump} {
}
if {$commit eq {}} {
if {$do_textconv ne 0} {
- # Run textconv with sh -c "..." to allow it to
- # contain command + arguments. On windows, just
- # call the filter command.
- if {![file executable [shellpath]]} {
- set fd [open |[linsert $textconv end $path] r]
- } else {
- set fd [open |[list [shellpath] -c "$textconv \"\$0\"" $path] r]
- }
+ set fd [open_cmd_pipe $textconv $path]
} else {
set fd [open $path r]
}
@@ -575,7 +568,11 @@ method _read_file {fd jump} {
foreach i $w_columns {$i conf -state disabled}
if {[eof $fd]} {
- close $fd
+ fconfigure $fd -blocking 1; # enable error reporting on close
+ if {[catch {close $fd} err]} {
+ tk_messageBox -icon error -title [mc Error] \
+ -message $err
+ }
# If we don't force Tk to update the widgets *right now*
# none of our jump commands will cause a change in the UI.
@@ -1065,7 +1062,7 @@ method _gitkcommit {} {
set radius [get_config gui.blamehistoryctx]
set cmdline [list --select-commit=$cmit]
- if {$radius > 0} {
+ if {$radius > 0} {
set author_time {}
set committer_time {}
@@ -1173,7 +1170,7 @@ method _read_diff_load_commit {fd cparent new_path tline} {
}
if {[eof $fd]} {
- close $fd;
+ close $fd
set current_fd {}
_load_new_commit $this \