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

Re: [RFC PATCH (GIT-GUI/CORE BUG)] git-gui: Avoid an infinite rescan loop in handle_empty_diff.

From
Keith Cascio <keith@cs.ucla.edu>
Date
Jan 24, 2009, 01:46 UTC
Message-ID
<alpine.GSO.2.00.0901231743360.11562@kiwi.cs.ucla.edu>
In-Reply-To
<200901240052.58259.angavrilov@gmail.com>

Teach git-gui to check diff's exit code in order to know whether a file actually changed or not.

Signed-off-by: Keith Cascio <keith@cs.ucla.edu>
---
Alexander,
I encountered the same problem and I tried a different way
to prevent it.  Could you please try this alternative patch
and see if it works in your setup?  If so, it might be
a lower-impact solution.  Even if it doesn't solve your
problem, I think it is still an improvement over what
exists and could co-exist with your patch.
                                     -- Keith Cascio
 git-gui/lib/diff.tcl |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/git-gui/lib/diff.tcl b/git-gui/lib/diff.tcl
index bbbf15c..94faf95 100644
--- a/git-gui/lib/diff.tcl
+++ b/git-gui/lib/diff.tcl
@@ -276,6 +276,7 @@ proc start_show_diff {cont_info {add_opts {}}} {
 	}
 
 	lappend cmd -p
+	lappend cmd --exit-code
 	lappend cmd --no-color
 	if {$repo_config(gui.diffcontext) >= 1} {
 		lappend cmd "-U$repo_config(gui.diffcontext)"
@@ -310,6 +311,7 @@ proc read_diff {fd cont_info} {
 	global ui_diff diff_active
 	global is_3way_diff is_conflict_diff current_diff_header
 	global current_diff_queue
+	global errorCode
 
 	$ui_diff conf -state normal
 	while {[gets $fd line] >= 0} {
@@ -397,7 +399,9 @@ proc read_diff {fd cont_info} {
 	$ui_diff conf -state disabled
 
 	if {[eof $fd]} {
-		close $fd
+		fconfigure $fd -blocking 1
+		catch { close $fd } err
+		set diff_exit_status $errorCode
 
 		if {$current_diff_queue ne {}} {
 			advance_diff_queue $cont_info
@@ -413,7 +417,7 @@ proc read_diff {fd cont_info} {
 		}
 		ui_ready
 
-		if {[$ui_diff index end] eq {2.0}} {
+		if {$diff_exit_status eq "NONE"} {
 			handle_empty_diff
 		}
 		set callback [lindex $cont_info 1]
-- 
1.6.1
Previous: Alexander GavrilovNext: Junio C Hamano
Message 2 of 3 in “git-gui: Avoid an infinite rescan loop in handle_empty_diff.”
  1. git-gui: Avoid an infinite rescan loop in handle_empty_diff.Alexander Gavrilov, Jan 23, 2009
  2. Keith CascioJan 24, 2009
  3. Junio C HamanoJan 24, 2009

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.