From: Alexander Gavrilov <angavrilov@gmail.com>
To: git@vger.kernel.org
Cc: "Shawn O. Pearce" <spearce@spearce.org>
Subject: [PATCH (GIT-GUI) 2/3] Kill the blame back-end on window close.
Date: Thu, 17 Jul 2008 00:48:08 +0400 [thread overview]
Message-ID: <200807170048.08909.angavrilov@gmail.com> (raw)
In-Reply-To: <200807170043.49016.angavrilov@gmail.com>
Currently 'git-gui blame' does not kill its back-end
process, hoping that it will die anyway when the pipe
is closed. However, in some cases the process works
for a long time without producing any output. This
behavior results in a runaway CPU hog.
Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
---
The -f flag is necessary for msysgit.
For this fix I submitted to msysgit a patch that includes
a Cygwin-compatible kill.exe in the installer.
-- Alexander
git-gui.sh | 14 ++++++++++++++
lib/blame.tcl | 16 ++++++++++++----
2 files changed, 26 insertions(+), 4 deletions(-)
diff --git a/git-gui.sh b/git-gui.sh
index b1ed0ec..83e2645 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -497,6 +497,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'"
diff --git a/lib/blame.tcl b/lib/blame.tcl
index 192505d..2c19048 100644
--- a/lib/blame.tcl
+++ b/lib/blame.tcl
@@ -326,19 +326,27 @@ constructor new {i_commit i_path} {
bind $w.file_pane <Configure> \
"if {{$w.file_pane} eq {%W}} {[cb _resize %h]}"
+ wm protocol $top WM_DELETE_WINDOW "destroy $top"
+ bind $top <Destroy> [cb _kill]
+
_load $this {}
}
+method _kill {} {
+ if {$current_fd ne {}} {
+ kill_file_process $current_fd
+ catch {close $current_fd}
+ set current_fd {}
+ }
+}
+
method _load {jump} {
variable group_colors
_hide_tooltip $this
if {$total_lines != 0 || $current_fd ne {}} {
- if {$current_fd ne {}} {
- catch {close $current_fd}
- set current_fd {}
- }
+ _kill $this
foreach i $w_columns {
$i conf -state normal
--
1.5.6.3.17.g3f148
next prev parent reply other threads:[~2008-07-16 20:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-16 20:42 [PATCH (GIT-GUI) 0/3] Improve gui blame usability for large repositories Alexander Gavrilov
2008-07-16 20:43 ` [PATCH (GIT-GUI) 1/3] Add options to control the search for copies in blame Alexander Gavrilov
2008-07-16 20:48 ` Alexander Gavrilov [this message]
2008-07-16 20:51 ` [PATCH (GIT-GUI) 3/3] Add a menu item to invoke full copy detection " Alexander Gavrilov
2008-07-17 2:16 ` [PATCH (GIT-GUI) 0/3] Improve gui blame usability for large repositories Shawn O. Pearce
2008-07-18 5:39 ` Alexander Gavrilov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200807170048.08909.angavrilov@gmail.com \
--to=angavrilov@gmail.com \
--cc=git@vger.kernel.org \
--cc=spearce@spearce.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).