Skip to contentSkip to conversation

git-gui - simplify _open_stdout_stderr

PATCH In review Mark Levedahl 2 participants 3 messages Sep 22, 2023 – Apr 1, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 git-gui - simplify _open_stdout_stderr

From: "Mark Levedahl Date: Tue, 19 Sep 2023" <[email protected]>

Since b792230 ("git-gui: Show a progress meter for checking out files", 2007-07-08), git-gui includes a workaround for Tcl that does not support using 2>@1 to redirect stderr to stdout. Tcl added such support in 8.4.7, released in 2004, while the later 8.4.14 still predated git-gui. But, Cygwin was stuck on an 8.4.1 Tcl variant until 2011, hence the need for this workaround. Commit 7145c65 recently removed much other specific code for that obsolete Cygwin Tcl/Tk, but missed this piece.

Also, Tcl since 8.5 explicitly supports 2>@1 across all platforms, and git-gui requires Tcl >= 8.5, further evidence the workaround is obsolete. (I did test that 2>@1 works as-expected on current Linux, Cygwin, and Git For Windows Tcl packages).

Remove the workaround and exploit concat's documented capability to handle both scalar and list arguments, leaving a much simpler function. This eliminates any question that cmd might be executed twice.

---
 git-gui.sh | 21 ++-------------------
 1 file changed, 2 insertions(+), 19 deletions(-)
git-gui.sh +2 -19
index 8bc8892..a5d008d 100755
@@ -583,25 +583,8 @@ proc git {args} {
 
 proc _open_stdout_stderr {cmd} {
 	_trace_exec $cmd
-	if {[catch {
-			set fd [open [concat [list | ] $cmd] r]
-		} err]} {
-		if {   [lindex $cmd end] eq {2>@1}
-		    && $err eq {can not find channel named "1"}
-			} {
-			# Older versions of Tcl 8.4 don't have this 2>@1 IO
-			# redirect operator.  Fallback to |& cat for those.
-			# The command was not actually started, so its safe
-			# to try to start it a second time.
-			#
-			set fd [open [concat \
-				[list | ] \
-				[lrange $cmd 0 end-1] \
-				[list |& cat] \
-				] r]
-		} else {
-			error $err
-		}
+	if {[catch {set fd [open [concat | $cmd] r]} err]} {
+		error $err
 	}
 	fconfigure $fd -eofchar {}
 	return $fd
Signature · 1 line
2.41.0.99.19
#1 lore raw

Hi Mark,

this patch is still relevant, right? I am Cc:ing Johannes Sixt for awareness.

Ciao,
Johannes

Quoted 60 lines · Mark Levedahl

From: "Mark Levedahl Date: Tue, 19 Sep 2023" <[email protected]>

Since b792230 ("git-gui: Show a progress meter for checking out files", 2007-07-08), git-gui includes a workaround for Tcl that does not support using 2>@1 to redirect stderr to stdout. Tcl added such support in 8.4.7, released in 2004, while the later 8.4.14 still predated git-gui. But, Cygwin was stuck on an 8.4.1 Tcl variant until 2011, hence the need for this workaround. Commit 7145c65 recently removed much other specific code for that obsolete Cygwin Tcl/Tk, but missed this piece.

Also, Tcl since 8.5 explicitly supports 2>@1 across all platforms, and git-gui requires Tcl >= 8.5, further evidence the workaround is obsolete. (I did test that 2>@1 works as-expected on current Linux, Cygwin, and Git For Windows Tcl packages).

Remove the workaround and exploit concat's documented capability to handle both scalar and list arguments, leaving a much simpler function. This eliminates any question that cmd might be executed twice.

---
 git-gui.sh | 21 ++-------------------
 1 file changed, 2 insertions(+), 19 deletions(-)
git-gui.sh +2 -20
index 8bc8892..a5d008d 100755
@@ -583,25 +583,8 @@ proc git {args} {
 
 proc _open_stdout_stderr {cmd} {
 	_trace_exec $cmd
-	if {[catch {
-			set fd [open [concat [list | ] $cmd] r]
-		} err]} {
-		if {   [lindex $cmd end] eq {2>@1}
-		    && $err eq {can not find channel named "1"}
-			} {
-			# Older versions of Tcl 8.4 don't have this 2>@1 IO
-			# redirect operator.  Fallback to |& cat for those.
-			# The command was not actually started, so its safe
-			# to try to start it a second time.
-			#
-			set fd [open [concat \
-				[list | ] \
-				[lrange $cmd 0 end-1] \
-				[list |& cat] \
-				] r]
-		} else {
-			error $err
-		}
+	if {[catch {set fd [open [concat | $cmd] r]} err]} {
+		error $err
 	}
 	fconfigure $fd -eofchar {}
 	return $fd
--

2.41.0.99.19

#2 lore raw
Quoted 4 lines · Johannes Schindelin

Hi Mark,

this patch is still relevant, right? I am Cc:ing Johannes Sixt for awareness.

Absolutely. I have a number of commits in my tree removing compatibility for unsupportable Tcl/Tk and git versions, I should clean these up now there is a real maintainer.

Mark