git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH (GIT-GUI) 2/3] Kill the blame back-end on window close.

From
Alexander Gavrilov <angavrilov@gmail.com>
Date
Jul 16, 2008, 20:48 UTC
Message-ID
<200807170048.08909.angavrilov@gmail.com>
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
Previous: Alexander GavrilovNext: Alexander Gavrilov
Message 3 of 6 in “Improve gui blame usability for large repositories”
  1. 0/3 Improve gui blame usability for large repositoriesAlexander Gavrilov, Jul 16, 2008
  2. 1/3 Add options to control the search for copies in blame.Alexander Gavrilov, Jul 16, 2008
  3. 2/3 Kill the blame back-end on window close.Alexander Gavrilov, Jul 16, 2008
  4. 3/3 Add a menu item to invoke full copy detection in blame.Alexander Gavrilov, Jul 16, 2008
  5. Shawn O. PearceJul 17, 2008
  6. Alexander GavrilovJul 18, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.